Skip to content

Commit

Permalink
Merge pull request #107 from sebastianludwig/new_tests
Browse files Browse the repository at this point in the history
New unit tests
  • Loading branch information
scelis committed Nov 27, 2015
2 parents 3b638f9 + d3128cd commit 0689b81
Show file tree
Hide file tree
Showing 62 changed files with 804 additions and 615 deletions.
1 change: 0 additions & 1 deletion Rakefile
Expand Up @@ -3,7 +3,6 @@ require 'rake/testtask'

Rake::TestTask.new do |t|
t.libs = ['lib', 'test']
t.pattern = 'test/**/*_test.rb'
end

task :default => :test
5 changes: 3 additions & 2 deletions lib/twine/runner.rb
Expand Up @@ -7,9 +7,10 @@ module Twine
VALID_COMMANDS = ['generate-string-file', 'generate-all-string-files', 'consume-string-file', 'consume-all-string-files', 'generate-loc-drop', 'consume-loc-drop', 'validate-strings-file']

class Runner
def initialize(args)
@options = {}
def initialize(args, options = nil)
@options = options || {}
@args = args
@strings = StringsFile.new
end

def self.run(args)
Expand Down
19 changes: 19 additions & 0 deletions test/command_test_case.rb
@@ -0,0 +1,19 @@
require 'twine_test_case'

class CommandTestCase < TwineTestCase
def prepare_mock_formatter(formatter_class)
formatter = formatter_class.new(@mock_strings, {})
formatter_class.stubs(:new).returns(formatter)
formatter
end

def setup
super

@known_languages = %w(en fr de es)

@mock_strings = Twine::StringsFile.new
@mock_strings.language_codes.concat @known_languages
Twine::StringsFile.stubs(:new).returns(@mock_strings)
end
end
5 changes: 0 additions & 5 deletions test/fixtures/en-1.json

This file was deleted.

16 changes: 0 additions & 16 deletions test/fixtures/en-1.po

This file was deleted.

10 changes: 0 additions & 10 deletions test/fixtures/en-1.strings

This file was deleted.

23 changes: 0 additions & 23 deletions test/fixtures/en-2.po

This file was deleted.

8 changes: 0 additions & 8 deletions test/fixtures/en-3.xml

This file was deleted.

15 changes: 15 additions & 0 deletions test/fixtures/formatter_android.xml
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Android Strings File -->
<!-- Generated by Twine <%= Twine::VERSION %> -->
<!-- Language: en -->
<resources>
<!-- SECTION: Section 1 -->
<!-- comment key1 -->
<string name="key1">value1-english</string>
<string name="key2">value2-english</string>

<!-- SECTION: Section 2 -->
<string name="key3">value3-english</string>
<!-- comment key4 -->
<string name="key4">value4-english</string>
</resources>
20 changes: 20 additions & 0 deletions test/fixtures/formatter_apple.strings
@@ -0,0 +1,20 @@
/**
* Apple Strings File
* Generated by Twine <%= Twine::VERSION %>
* Language: en
*/

/********** Section 1 **********/

/* comment key1 */
"key1" = "value1-english";

"key2" = "value2-english";


/********** Section 2 **********/

"key3" = "value3-english";

/* comment key4 */
"key4" = "value4-english";
27 changes: 27 additions & 0 deletions test/fixtures/formatter_gettext.po
@@ -0,0 +1,27 @@
msgid ""
msgstr ""
"Language: en\n"
"X-Generator: Twine <%= Twine::VERSION %>\n"


# SECTION: Section 1
#. "comment key1"
msgctxt "key1"
msgid "value1-english"
msgstr "value1-english"

msgctxt "key2"
msgid "value2-english"
msgstr "value2-english"


# SECTION: Section 2
msgctxt "key3"
msgid "value3-english"
msgstr "value3-english"

#. "comment key4"
msgctxt "key4"
msgid "value4-english"
msgstr "value4-english"

7 changes: 7 additions & 0 deletions test/fixtures/formatter_jquery.json
@@ -0,0 +1,7 @@
{
"key1":"value1-english",
"key2":"value2-english",

"key3":"value3-english",
"key4":"value4-english"
}
15 changes: 15 additions & 0 deletions test/fixtures/formatter_tizen.xml
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Tizen Strings File -->
<!-- Generated by Twine <%= Twine::VERSION %> -->
<!-- Language: en -->
<string_table Bversion="2.0.0.201311071819" Dversion="20120315">
<!-- SECTION: Section 1 -->
<!-- comment key1 -->
<text id="IDS_KEY1">value1-english</text>
<text id="IDS_KEY2">value2-english</text>

<!-- SECTION: Section 2 -->
<text id="IDS_KEY3">value3-english</text>
<!-- comment key4 -->
<text id="IDS_KEY4">value4-english</text>
</string_table>
10 changes: 0 additions & 10 deletions test/fixtures/fr-1.xml

This file was deleted.

10 changes: 10 additions & 0 deletions test/fixtures/gettext_multiline.po
@@ -0,0 +1,10 @@
msgid ""
msgstr ""
"Language: en\n"
"X-Generator: Twine\n"

msgctxt "key1"
msgid "key1"
msgstr "multi"
"line\n"
"string"
17 changes: 0 additions & 17 deletions test/fixtures/strings-1.txt

This file was deleted.

5 changes: 0 additions & 5 deletions test/fixtures/strings-2.txt

This file was deleted.

5 changes: 0 additions & 5 deletions test/fixtures/strings-3.txt

This file was deleted.

20 changes: 0 additions & 20 deletions test/fixtures/strings-4-references.txt

This file was deleted.

5 changes: 0 additions & 5 deletions test/fixtures/test-json-line-breaks/consumed.txt

This file was deleted.

3 changes: 0 additions & 3 deletions test/fixtures/test-json-line-breaks/generated.json

This file was deleted.

3 changes: 0 additions & 3 deletions test/fixtures/test-json-line-breaks/line-breaks.json

This file was deleted.

4 changes: 0 additions & 4 deletions test/fixtures/test-json-line-breaks/line-breaks.txt

This file was deleted.

12 changes: 0 additions & 12 deletions test/fixtures/test-output-1.txt

This file was deleted.

9 changes: 0 additions & 9 deletions test/fixtures/test-output-10.txt

This file was deleted.

9 changes: 0 additions & 9 deletions test/fixtures/test-output-11.txt

This file was deleted.

12 changes: 0 additions & 12 deletions test/fixtures/test-output-12.txt

This file was deleted.

10 changes: 0 additions & 10 deletions test/fixtures/test-output-13.txt

This file was deleted.

17 changes: 0 additions & 17 deletions test/fixtures/test-output-14-references.txt

This file was deleted.

9 changes: 0 additions & 9 deletions test/fixtures/test-output-14.txt

This file was deleted.

12 changes: 0 additions & 12 deletions test/fixtures/test-output-2.txt

This file was deleted.

0 comments on commit 0689b81

Please sign in to comment.