|
24 | 24 | end |
25 | 25 |
|
26 | 26 | describe '#ignored?' do |
27 | | - context 'when using a string' do |
28 | | - it do |
29 | | - TranslationIO::YamlEntry.ignored?('en.faker.yo').should be true |
30 | | - TranslationIO::YamlEntry.ignored?('en.faker').should be true |
31 | | - TranslationIO::YamlEntry.ignored?('en.faker.aa.aa.bb').should be true |
32 | | - TranslationIO::YamlEntry.ignored?('en.yo').should be false |
33 | | - TranslationIO::YamlEntry.ignored?('en.fakeryo').should be false |
34 | | - TranslationIO::YamlEntry.ignored?('fr.faker').should be true |
35 | | - |
36 | | - TranslationIO.config.ignored_key_prefixes = ['world'] |
37 | | - |
38 | | - TranslationIO::YamlEntry.ignored?('en.world').should be true |
39 | | - TranslationIO::YamlEntry.ignored?('en.world.hello').should be true |
40 | | - TranslationIO::YamlEntry.ignored?('en.worldbla').should be false |
41 | | - TranslationIO::YamlEntry.ignored?('fr.world.hello').should be true |
42 | | - |
43 | | - TranslationIO.config.ignored_key_prefixes = ['world.'] |
44 | | - |
45 | | - TranslationIO::YamlEntry.ignored?('en.world').should be false |
46 | | - TranslationIO::YamlEntry.ignored?('en.world.hello').should be true |
47 | | - TranslationIO::YamlEntry.ignored?('en.worldbla').should be false |
48 | | - TranslationIO::YamlEntry.ignored?('fr.world.hello').should be true |
49 | | - |
50 | | - # check "." on ignored key prefix is not used as special char in the regexp |
51 | | - TranslationIO::YamlEntry.ignored?('fr.worlda').should be false |
52 | | - end |
| 27 | + it 'works with default ignored keys' do |
| 28 | + TranslationIO::YamlEntry.ignored?('en.faker.yo' ).should be true |
| 29 | + TranslationIO::YamlEntry.ignored?('en.faker' ).should be true |
| 30 | + TranslationIO::YamlEntry.ignored?('en.faker.aa.aa.bb').should be true |
| 31 | + TranslationIO::YamlEntry.ignored?('en.yo' ).should be false |
| 32 | + TranslationIO::YamlEntry.ignored?('en.fakeryo' ).should be false |
| 33 | + TranslationIO::YamlEntry.ignored?('fr.faker' ).should be true |
53 | 34 | end |
54 | 35 |
|
55 | | - context 'when using a regular expression' do |
56 | | - it do |
57 | | - TranslationIO::YamlEntry.ignored?('en.faker.yo').should be true |
58 | | - TranslationIO::YamlEntry.ignored?('en.faker').should be true |
59 | | - TranslationIO::YamlEntry.ignored?('en.faker.aa.aa.bb').should be true |
60 | | - TranslationIO::YamlEntry.ignored?('en.yo').should be false |
61 | | - TranslationIO::YamlEntry.ignored?('en.fakeryo').should be false |
62 | | - TranslationIO::YamlEntry.ignored?('fr.faker').should be true |
63 | | - |
64 | | - TranslationIO.config.ignored_key_prefixes = [ |
65 | | - /\.do_not_translate$/, |
66 | | - /^world$|^world\..+$/, |
67 | | - ] |
68 | | - |
69 | | - TranslationIO::YamlEntry.ignored?('en.world').should be true |
70 | | - TranslationIO::YamlEntry.ignored?('en.world.hello').should be true |
71 | | - TranslationIO::YamlEntry.ignored?('en.worldbla').should be false |
72 | | - TranslationIO::YamlEntry.ignored?('fr.world.hello').should be true |
73 | | - TranslationIO::YamlEntry.ignored?('fr.yet.another.world.hello').should be false |
74 | | - TranslationIO::YamlEntry.ignored?('fr.mars.hello.do_not_translate').should be true |
75 | | - end |
| 36 | + it 'works with ignored prefix strings' do |
| 37 | + TranslationIO.config.ignored_key_prefixes = ['world'] |
| 38 | + |
| 39 | + TranslationIO::YamlEntry.ignored?('en.world' ).should be true |
| 40 | + TranslationIO::YamlEntry.ignored?('en.world.hello').should be true |
| 41 | + TranslationIO::YamlEntry.ignored?('en.worldbla' ).should be false |
| 42 | + TranslationIO::YamlEntry.ignored?('fr.world.hello').should be true |
| 43 | + |
| 44 | + TranslationIO.config.ignored_key_prefixes = ['world.'] |
| 45 | + |
| 46 | + TranslationIO::YamlEntry.ignored?('en.world' ).should be false |
| 47 | + TranslationIO::YamlEntry.ignored?('en.world.hello').should be true |
| 48 | + TranslationIO::YamlEntry.ignored?('en.worldbla' ).should be false |
| 49 | + TranslationIO::YamlEntry.ignored?('fr.world.hello').should be true |
| 50 | + |
| 51 | + # check "." on ignored key prefix is not used as special char in the regexp |
| 52 | + TranslationIO::YamlEntry.ignored?('fr.worlda').should be false |
| 53 | + end |
| 54 | + |
| 55 | + it 'works with ignored regular expression' do |
| 56 | + TranslationIO.config.ignored_key_prefixes = [ |
| 57 | + /\.do_not_translate$/, |
| 58 | + /^world$|^world\..+$/, |
| 59 | + ] |
| 60 | + |
| 61 | + TranslationIO::YamlEntry.ignored?('en.world' ).should be true |
| 62 | + TranslationIO::YamlEntry.ignored?('en.world.hello' ).should be true |
| 63 | + TranslationIO::YamlEntry.ignored?('en.worldbla' ).should be false |
| 64 | + TranslationIO::YamlEntry.ignored?('fr.world.hello' ).should be true |
| 65 | + TranslationIO::YamlEntry.ignored?('fr.yet.another.world.hello' ).should be false |
| 66 | + TranslationIO::YamlEntry.ignored?('fr.mars.hello.do_not_translate').should be true |
76 | 67 | end |
77 | 68 |
|
78 | | - context 'when using a mix of regular expression and strings' do |
79 | | - it do |
80 | | - TranslationIO.config.ignored_key_prefixes = [ |
81 | | - /\.do_not_translate$/, |
82 | | - /^world$|^world\..+$/, |
83 | | - "mars" |
84 | | - ] |
85 | | - |
86 | | - TranslationIO::YamlEntry.ignored?('en.world').should be true |
87 | | - TranslationIO::YamlEntry.ignored?('en.world.hello').should be true |
88 | | - TranslationIO::YamlEntry.ignored?('en.worldbla').should be false |
89 | | - TranslationIO::YamlEntry.ignored?('fr.world.hello').should be true |
90 | | - TranslationIO::YamlEntry.ignored?('fr.yet.another.world.hello').should be false |
91 | | - TranslationIO::YamlEntry.ignored?('fr.mars.hello').should be true |
92 | | - TranslationIO::YamlEntry.ignored?('fr.mars.hello.do_not_translate').should be true |
93 | | - TranslationIO::YamlEntry.ignored?('fr.mars_attacks.world').should be false |
94 | | - end |
| 69 | + it 'works when using a mix of ignored prefix strings and regular expressions' do |
| 70 | + TranslationIO.config.ignored_key_prefixes = [ |
| 71 | + /\.do_not_translate$/, |
| 72 | + /^world$|^world\..+$/, |
| 73 | + "mars" |
| 74 | + ] |
| 75 | + |
| 76 | + TranslationIO::YamlEntry.ignored?('en.world' ).should be true |
| 77 | + TranslationIO::YamlEntry.ignored?('en.world.hello' ).should be true |
| 78 | + TranslationIO::YamlEntry.ignored?('en.worldbla' ).should be false |
| 79 | + TranslationIO::YamlEntry.ignored?('fr.world.hello' ).should be true |
| 80 | + TranslationIO::YamlEntry.ignored?('fr.yet.another.world.hello' ).should be false |
| 81 | + TranslationIO::YamlEntry.ignored?('fr.mars.hello' ).should be true |
| 82 | + TranslationIO::YamlEntry.ignored?('fr.mars.hello.do_not_translate').should be true |
| 83 | + TranslationIO::YamlEntry.ignored?('fr.mars_attacks.world' ).should be false |
95 | 84 | end |
96 | 85 | end |
97 | 86 |
|
|
0 commit comments