diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..db49633
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,8 @@
+require 'rake'
+require 'rake/testtask'
+
+Rake::TestTask.new do |t|
+ t.test_files = %w(test/twine_test.rb)
+end
+
+task :default => :test
diff --git a/test/fixtures/en-1.strings b/test/fixtures/en-1.strings
new file mode 100644
index 0000000..35cb6ca
--- /dev/null
+++ b/test/fixtures/en-1.strings
@@ -0,0 +1,10 @@
+/**
+ * iOS Strings File
+ * Generated by Twine
+ * Language: en
+ */
+
+/* My Strings */
+"key1" = "key1-english";
+"key3" = "key3-english";
+"key5" = "A new string";
diff --git a/test/fixtures/fr-1.xml b/test/fixtures/fr-1.xml
new file mode 100644
index 0000000..78cd8f3
--- /dev/null
+++ b/test/fixtures/fr-1.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+ key1-french
+ key2-french
+ key3-french
+
diff --git a/test/fixtures/strings-1.txt b/test/fixtures/strings-1.txt
new file mode 100644
index 0000000..ec5da60
--- /dev/null
+++ b/test/fixtures/strings-1.txt
@@ -0,0 +1,16 @@
+[[My Strings]]
+ [key1]
+ en = key1-english
+ tags = tag1
+ es = key1-spanish
+ fr = key1-french
+ [key2]
+ en = key2-english
+ tags = tag2
+ fr = key2-french
+ [key3]
+ en = key3-english
+ tags = tag1,tag2
+ es = key3-spanish
+ [key4]
+ en = key4-english
diff --git a/test/fixtures/test-output-1.txt b/test/fixtures/test-output-1.txt
new file mode 100644
index 0000000..ccadd5a
--- /dev/null
+++ b/test/fixtures/test-output-1.txt
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+ key1-french
+ key2-french
+ key3-english
+
diff --git a/test/fixtures/test-output-2.txt b/test/fixtures/test-output-2.txt
new file mode 100644
index 0000000..7eef3b7
--- /dev/null
+++ b/test/fixtures/test-output-2.txt
@@ -0,0 +1,9 @@
+/**
+ * iOS Strings File
+ * Generated by Twine
+ * Language: en
+ */
+
+/* My Strings */
+"key1" = "key1-english";
+"key3" = "key3-english";
diff --git a/test/fixtures/test-output-3.txt b/test/fixtures/test-output-3.txt
new file mode 100644
index 0000000..1f26afe
--- /dev/null
+++ b/test/fixtures/test-output-3.txt
@@ -0,0 +1,17 @@
+[[My Strings]]
+ [key1]
+ en = key1-english
+ tags = tag1
+ es = key1-spanish
+ fr = key1-french
+ [key2]
+ en = key2-english
+ tags = tag2
+ fr = key2-french
+ [key3]
+ en = key3-english
+ tags = tag1,tag2
+ es = key3-spanish
+ fr = key3-french
+ [key4]
+ en = key4-english
diff --git a/test/fixtures/test-output-4.txt b/test/fixtures/test-output-4.txt
new file mode 100644
index 0000000..98f81f2
--- /dev/null
+++ b/test/fixtures/test-output-4.txt
@@ -0,0 +1,20 @@
+[[Uncategorized]]
+ [key5]
+ en = A new string
+
+[[My Strings]]
+ [key1]
+ en = key1-english
+ tags = tag1
+ es = key1-spanish
+ fr = key1-french
+ [key2]
+ en = key2-english
+ tags = tag2
+ fr = key2-french
+ [key3]
+ en = key3-english
+ tags = tag1,tag2
+ es = key3-spanish
+ [key4]
+ en = key4-english
diff --git a/test/twine_test.rb b/test/twine_test.rb
new file mode 100644
index 0000000..9839b06
--- /dev/null
+++ b/test/twine_test.rb
@@ -0,0 +1,40 @@
+require 'test/unit'
+require 'twine'
+
+class TwineTest < Test::Unit::TestCase
+ def test_generate_string_file_1
+ Dir.mktmpdir do |dir|
+ output_path = File.join(dir, 'fr.xml')
+ Twine::Runner.run(%W(generate-string-file test/fixtures/strings-1.txt #{output_path}))
+ assert_equal(File.read('test/fixtures/test-output-1.txt'), File.read(output_path))
+ end
+ end
+
+ def test_generate_string_file_2
+ Dir.mktmpdir do |dir|
+ output_path = File.join(dir, 'en.strings')
+ Twine::Runner.run(%W(generate-string-file test/fixtures/strings-1.txt #{output_path} -t tag1))
+ assert_equal(File.read('test/fixtures/test-output-2.txt'), File.read(output_path))
+ end
+ end
+
+ def test_consume_string_file_1
+ Dir.mktmpdir do |dir|
+ output_path = File.join(dir, 'strings.txt')
+ Twine::Runner.run(%W(consume-string-file test/fixtures/strings-1.txt test/fixtures/fr-1.xml -o #{output_path} -l fr))
+ assert_equal(File.read('test/fixtures/test-output-3.txt'), File.read(output_path))
+ end
+ end
+
+ def test_consume_string_file_2
+ Dir.mktmpdir do |dir|
+ output_path = File.join(dir, 'strings.txt')
+ Twine::Runner.run(%W(consume-string-file test/fixtures/strings-1.txt test/fixtures/en-1.strings -o #{output_path} -l en -a))
+ assert_equal(File.read('test/fixtures/test-output-4.txt'), File.read(output_path))
+ end
+ end
+
+ def test_generate_report_1
+ Twine::Runner.run(%w(generate-report test/fixtures/strings-1.txt))
+ end
+end
diff --git a/twine.gemspec b/twine.gemspec
index 774da5f..b9e3b38 100644
--- a/twine.gemspec
+++ b/twine.gemspec
@@ -15,7 +15,9 @@ Gem::Specification.new do |s|
s.files += Dir.glob("lib/**/*")
s.files += Dir.glob("bin/**/*")
+ s.required_ruby_version = ">= 1.8.7"
s.add_runtime_dependency('rubyzip', "~> 0.9.5")
+ s.add_development_dependency('rake', "~> 0.9.2")
s.executables = %w( twine )
s.description = <