diff --git a/lib/twine/runner.rb b/lib/twine/runner.rb index 3b91d19..14ef211 100644 --- a/lib/twine/runner.rb +++ b/lib/twine/runner.rb @@ -211,7 +211,7 @@ module Twine errors << "None of your strings have tags." elsif keys_without_tags.length > 0 error_body = keys_without_tags.to_a.join("\n ") - errors << "Found strings(s) without tags:\n #{error_body}" + errors << "Found strings without tags:\n #{error_body}" end if errors.length > 0 diff --git a/test/test_validate_strings_file.rb b/test/test_validate_strings_file.rb new file mode 100644 index 0000000..f6274c0 --- /dev/null +++ b/test/test_validate_strings_file.rb @@ -0,0 +1,45 @@ +require 'command_test_case' + +class TestValidateStringsFile < CommandTestCase + def setup + super + @options = { strings_file: 'input.txt' } + + @twine_file = build_twine_file 'en' do + add_section 'Section 1' do + add_row key1: 'value1', tags: ['tag1'] + add_row key2: 'value2', tags: ['tag1'] + end + + add_section 'Section 2' do + add_row key3: 'value3', tags: ['tag1', 'tag2'] + add_row key4: 'value4', tags: ['tag2'] + end + end + end + + def random_row + @twine_file.strings_map[@twine_file.strings_map.keys.sample] + end + + def test_recognizes_valid_file + Twine::Runner.new(@options, @twine_file).validate_strings_file + assert_equal "input.txt is valid.\n", Twine::stdout.string + end + + def test_reports_duplicate_keys + @twine_file.sections[0].rows << random_row + + assert_raises Twine::Error do + Twine::Runner.new(@options, @twine_file).validate_strings_file + end + end + + def test_reports_missing_tags + random_row.tags.clear + + assert_raises Twine::Error do + Twine::Runner.new(@options, @twine_file).validate_strings_file + end + end +end