i18n_interpolation_spec 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +46 -0
- data/Rakefile +2 -0
- data/i18n_interpolation_spec.gemspec +25 -0
- data/lib/i18n_interpolation_spec.rb +7 -0
- data/lib/i18n_interpolation_spec/checker.rb +65 -0
- data/lib/i18n_interpolation_spec/locale_file.rb +29 -0
- data/lib/i18n_interpolation_spec/matchers/be_a_complete_interpolation_of.rb +22 -0
- data/lib/i18n_interpolation_spec/matchers/have_mutual_interpolation_of.rb +22 -0
- data/lib/i18n_interpolation_spec/version.rb +9 -0
- data/spec/fixtures/base.yml +5 -0
- data/spec/fixtures/complete.yml +5 -0
- data/spec/fixtures/incomplete.yml +5 -0
- data/spec/lib/i18n_interpolation_spec/checker_spec.rb +132 -0
- data/spec/lib/i18n_interpolation_spec/locale_file_spec.rb +81 -0
- data/spec/lib/i18n_interpolation_spec/matchers/be_a_complete_interpolation_of_spec.rb +27 -0
- data/spec/lib/i18n_interpolation_spec/matchers/have_mutual_interpolation_of_spec.rb +31 -0
- data/spec/spec_helper.rb +10 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3c8467ae5c07c2e23012dfa774dea5738ba563d2
|
4
|
+
data.tar.gz: 6645ce1d131d67bbc47ae39ceabc4d3c8406d30b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 77226457dc91514362ea632ea407447009c06b94f702d60e4d672cbe5cb09fe8c059e9c7edddced953772cfc57b0e8d458fcff511c1879b88554044a6abe9963
|
7
|
+
data.tar.gz: 42c18de0594a5c78ba95f8afc70329df7b268ca3e1dd8c06a2ff101351ab24720da6d3ba2e840bb3f426108c37c69b43b9c42d0127cd35ce9567135b20119cce
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.0
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Yuki Iwanaga
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
i18n_interpolation_spec
|
2
|
+
=======================
|
3
|
+
|
4
|
+
**i18n_interpolation_spec provides RSpec matchers for testing the completeness of interpolation arguments in locale files.**
|
5
|
+
It's great to use with [tigrish/i18n-spec](https://github.com/tigrish/i18n-spec).
|
6
|
+
|
7
|
+
|
8
|
+
Installation
|
9
|
+
------------
|
10
|
+
|
11
|
+
Add the gem to your Gemfile.
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'i18n_interpolation_spec', group: :test
|
15
|
+
```
|
16
|
+
|
17
|
+
|
18
|
+
Matchers
|
19
|
+
--------
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
describe 'config/locales/fr.yml' do
|
23
|
+
it { is_expected.to be_a_complete_interpolation_of 'config/locales/en.yml' }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'config/locales/it.yml' do
|
27
|
+
it { is_expected.to have_mutual_interpolation_of 'config/locales/en.yml' }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'config/locales/es.yml' do
|
31
|
+
it {
|
32
|
+
is_expected.to be_a_complete_interpolation_of 'config/locales/en.yml',
|
33
|
+
except: [
|
34
|
+
'some.key.to.ignore',
|
35
|
+
/^some\.patt[e3]rn\.to\.ignore/,
|
36
|
+
]
|
37
|
+
}
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
|
42
|
+
License
|
43
|
+
-------
|
44
|
+
|
45
|
+
This project is copyright by [Creasty](http://creasty.com), released under the MIT license.
|
46
|
+
See `LICENSE` file for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'i18n_interpolation_spec/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'i18n_interpolation_spec'
|
8
|
+
spec.version = I18nInterpolationSpec::VERSION
|
9
|
+
spec.authors = ['Yuki Iwanaga']
|
10
|
+
spec.email = ['yuki@creasty.com']
|
11
|
+
spec.summary = %q{RSpec matchers for testing the completeness of interpolation arguments in locale files}
|
12
|
+
spec.description = %q{RSpec matchers for testing the completeness of interpolation arguments in locale files}
|
13
|
+
spec.homepage = 'https://github.com/creasty/i18n_interpolation_spec'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'rspec', '>= 3.0'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
require_relative 'i18n_interpolation_spec/version'
|
2
|
+
require_relative 'i18n_interpolation_spec/checker'
|
3
|
+
require_relative 'i18n_interpolation_spec/locale_file'
|
4
|
+
require_relative 'i18n_interpolation_spec/matchers/have_mutual_interpolation_of'
|
5
|
+
require_relative 'i18n_interpolation_spec/matchers/be_a_complete_interpolation_of'
|
6
|
+
|
7
|
+
module I18nInterpolationSpec; end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module I18nInterpolationSpec
|
2
|
+
module Checker
|
3
|
+
class << self
|
4
|
+
|
5
|
+
def except?(patterns, key)
|
6
|
+
patterns.any? { |pattern| pattern === key }
|
7
|
+
end
|
8
|
+
|
9
|
+
def check(t1, t2, except, &checker)
|
10
|
+
i1, i2 = interpolations(t1), interpolations(t2)
|
11
|
+
|
12
|
+
missing_keys = {}
|
13
|
+
|
14
|
+
(i1.keys & i2.keys).each do |key|
|
15
|
+
a1, a2 = i1[key], i2[key]
|
16
|
+
diff = (a1 - a2) | (a2 - a1)
|
17
|
+
next if except? except, key
|
18
|
+
missing_keys[key] = diff if checker[key, a1, a2, diff]
|
19
|
+
end
|
20
|
+
|
21
|
+
missing_keys
|
22
|
+
end
|
23
|
+
|
24
|
+
def strict_check(t1, t2, except: [])
|
25
|
+
check t1, t2, except do |key, a1, a2, diff|
|
26
|
+
diff.any?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def loose_check(t1, t2, except: [])
|
31
|
+
check t1, t2, except do |key, a1, a2, diff|
|
32
|
+
a1.any? && a2.any? && (diff == a1 | a2)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def interpolations(t)
|
37
|
+
result = {}
|
38
|
+
|
39
|
+
rec = ->(t, scopes) do
|
40
|
+
if t.is_a? Hash
|
41
|
+
t.each do |(k, v)|
|
42
|
+
rec.call v, [*scopes, k]
|
43
|
+
end
|
44
|
+
elsif t.is_a? Array
|
45
|
+
t.each_with_index do |v, i|
|
46
|
+
rec.call v, [*scopes, i]
|
47
|
+
end
|
48
|
+
else
|
49
|
+
args = extract_args t
|
50
|
+
result[scopes.join('.')] = args
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
rec.call t, []
|
55
|
+
|
56
|
+
result
|
57
|
+
end
|
58
|
+
|
59
|
+
def extract_args(translation)
|
60
|
+
translation.to_s.scan(/(?<!%)%\{([^\}]+)\}/).flatten
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module I18nInterpolationSpec
|
4
|
+
class LocaleFile
|
5
|
+
|
6
|
+
attr_accessor :filepath
|
7
|
+
|
8
|
+
def initialize(filepath)
|
9
|
+
@filepath = filepath
|
10
|
+
end
|
11
|
+
|
12
|
+
def content
|
13
|
+
@content ||= File.read @filepath
|
14
|
+
end
|
15
|
+
|
16
|
+
def content_yaml
|
17
|
+
@content_yaml ||= YAML.load(content).freeze
|
18
|
+
end
|
19
|
+
|
20
|
+
def locale
|
21
|
+
@locale ||= content_yaml.keys.first
|
22
|
+
end
|
23
|
+
|
24
|
+
def translations
|
25
|
+
content_yaml[locale]
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
RSpec::Matchers.define :be_a_complete_interpolation_of do |subject_filepath, except: []|
|
2
|
+
|
3
|
+
match do |object_filepath|
|
4
|
+
object_locale = I18nInterpolationSpec::LocaleFile.new object_filepath
|
5
|
+
subject_locale = I18nInterpolationSpec::LocaleFile.new subject_filepath
|
6
|
+
|
7
|
+
t1, t2 = subject_locale.translations, object_locale.translations
|
8
|
+
|
9
|
+
@missing_args = I18nInterpolationSpec::Checker.strict_check t1, t2, except: except
|
10
|
+
@missing_args.empty?
|
11
|
+
end
|
12
|
+
|
13
|
+
failure_message do |filepath|
|
14
|
+
listed = @missing_args.map do |(scope, args)|
|
15
|
+
args = args.map { |arg| '%%{%s}' % arg }.join ', '
|
16
|
+
"\n - %s should have %s" % [scope, args]
|
17
|
+
end
|
18
|
+
|
19
|
+
"expected #{filepath} to contain the following interpolation arguments:#{listed.join}"
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
RSpec::Matchers.define :have_mutual_interpolation_of do |subject_filepath, except: []|
|
2
|
+
|
3
|
+
match do |object_filepath|
|
4
|
+
object_locale = I18nInterpolationSpec::LocaleFile.new object_filepath
|
5
|
+
subject_locale = I18nInterpolationSpec::LocaleFile.new subject_filepath
|
6
|
+
|
7
|
+
t1, t2 = subject_locale.translations, object_locale.translations
|
8
|
+
|
9
|
+
@missing_args = I18nInterpolationSpec::Checker.loose_check t1, t2, except: except
|
10
|
+
@missing_args.empty?
|
11
|
+
end
|
12
|
+
|
13
|
+
failure_message do |filepath|
|
14
|
+
listed = @missing_args.map do |(scope, args)|
|
15
|
+
args = args.map { |arg| '%%{%s}' % arg }.join ', '
|
16
|
+
"\n - %s should have %s" % [scope, args]
|
17
|
+
end
|
18
|
+
|
19
|
+
"expected #{filepath} to contain the following interpolation arguments:#{listed.join}"
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe I18nInterpolationSpec::Checker do
|
4
|
+
|
5
|
+
describe '::extract_args' do
|
6
|
+
|
7
|
+
it 'should extract interpolation arguments' do
|
8
|
+
text = 'non_arg %{arg_1} {non_arg} %{arg_2}'
|
9
|
+
args = %w[arg_1 arg_2]
|
10
|
+
|
11
|
+
expect(I18nInterpolationSpec::Checker.extract_args(text)).to eq args
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should not extract arguments of interpolation-like syntax with escaped %' do
|
15
|
+
text = '%{arg} %%{non_arg}'
|
16
|
+
non_arg = 'non_arg'
|
17
|
+
|
18
|
+
expect(I18nInterpolationSpec::Checker.extract_args(text)).not_to include non_arg
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '::interpolations' do
|
24
|
+
|
25
|
+
it 'should return pairs of scope and interpolation arguments' do
|
26
|
+
translations = {
|
27
|
+
a: { aa: '%{a_aa}', ab: '%{a_ab}' },
|
28
|
+
b: { ba: '%{b_ba}' },
|
29
|
+
c: [{ ca: '%{c_0_ca}' }],
|
30
|
+
}
|
31
|
+
|
32
|
+
args = {
|
33
|
+
'a.aa' => %w[a_aa],
|
34
|
+
'a.ab' => %w[a_ab],
|
35
|
+
'b.ba' => %w[b_ba],
|
36
|
+
'c.0.ca' => %w[c_0_ca],
|
37
|
+
}
|
38
|
+
|
39
|
+
expect(I18nInterpolationSpec::Checker.interpolations(translations)).to eq args
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should include empty array for translations without interpolations' do
|
43
|
+
translations = {
|
44
|
+
a: { aa: '%{a_aa}' },
|
45
|
+
b: { ba: 'no interpolations here' },
|
46
|
+
}
|
47
|
+
|
48
|
+
args = {
|
49
|
+
'a.aa' => %w[a_aa],
|
50
|
+
'b.ba' => %w[],
|
51
|
+
}
|
52
|
+
|
53
|
+
expect(I18nInterpolationSpec::Checker.interpolations(translations)).to eq args
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
let(:t1) do
|
59
|
+
{
|
60
|
+
a: { aa: '%{a_aa}', ab: '%{a_ab}' },
|
61
|
+
b: { ba: '%{b_ba}' },
|
62
|
+
c: [{ ca: '%{c_0_ca}' }],
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
let(:t2) do
|
67
|
+
{
|
68
|
+
a: { aa: '%{a_aa}', ab: '%{a_ab}' },
|
69
|
+
b: { ba: '%{b_ba}' },
|
70
|
+
c: [{ ca: '%{c_0_ca}' }],
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '::strict_check' do
|
75
|
+
|
76
|
+
it 'should return an empty hash if interpolation arguments are fully contained in both arg lists' do
|
77
|
+
expect(I18nInterpolationSpec::Checker.strict_check(t1, t2)).to eq({})
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should ignore translations that only exists in either hash' do
|
81
|
+
t1[:d] = { only_1: '%{only_1}' }
|
82
|
+
t2[:d] = { only_2: '%{only_2}' }
|
83
|
+
|
84
|
+
expect(I18nInterpolationSpec::Checker.strict_check(t1, t2)).to eq({})
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should return a hash of missing translations arguments if interpolation arguments are not fully contained in both arg lists' do
|
88
|
+
t1[:c][0][:ca] = ''
|
89
|
+
t2[:a][:ab] = '%{A_AB}'
|
90
|
+
t2[:b][:ba] = ''
|
91
|
+
|
92
|
+
args = {
|
93
|
+
'a.ab' => %w[a_ab A_AB],
|
94
|
+
'b.ba' => %w[b_ba],
|
95
|
+
"c.0.ca" => %w[c_0_ca],
|
96
|
+
}
|
97
|
+
|
98
|
+
expect(I18nInterpolationSpec::Checker.strict_check(t1, t2)).to eq args
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
describe '::loose_check' do
|
104
|
+
|
105
|
+
it 'should return an empty hash if interpolation arguments are fully contained in both arg lists' do
|
106
|
+
expect(I18nInterpolationSpec::Checker.loose_check(t1, t2)).to eq({})
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'should ignore translations that only exists in either hash' do
|
110
|
+
t1[:d] = { only_1: '%{only_1}' }
|
111
|
+
t2[:d] = { only_2: '%{only_2}' }
|
112
|
+
|
113
|
+
expect(I18nInterpolationSpec::Checker.loose_check(t1, t2)).to eq({})
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'should return a hash of missing translations arguments if interpolation arguments are not fully contained in both arg lists' do
|
117
|
+
t1[:a][:aa] = '%{a_aa} %{only}'
|
118
|
+
t1[:c][0][:ca] = ''
|
119
|
+
t2[:a][:ab] = '%{A_AB}'
|
120
|
+
t2[:b][:ba] = '%{B_BA} %{only}'
|
121
|
+
|
122
|
+
args = {
|
123
|
+
'a.ab' => %w[a_ab A_AB],
|
124
|
+
'b.ba' => %w[b_ba B_BA only],
|
125
|
+
}
|
126
|
+
|
127
|
+
expect(I18nInterpolationSpec::Checker.loose_check(t1, t2)).to eq args
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module LocaleFileHelper
|
4
|
+
|
5
|
+
def locale_file_with_content(content)
|
6
|
+
locale_file = I18nInterpolationSpec::LocaleFile.new 'test.yml'
|
7
|
+
expect(locale_file).to receive(:content).and_return(content)
|
8
|
+
locale_file
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
describe I18nInterpolationSpec::LocaleFile do
|
15
|
+
include LocaleFileHelper
|
16
|
+
|
17
|
+
describe '#content' do
|
18
|
+
|
19
|
+
it 'should return the content of the file' do
|
20
|
+
content = <<-YAML
|
21
|
+
en:
|
22
|
+
hello: world
|
23
|
+
YAML
|
24
|
+
|
25
|
+
locale_file = locale_file_with_content content
|
26
|
+
|
27
|
+
expect(locale_file.content).to eq(content)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#content_yaml' do
|
33
|
+
|
34
|
+
it 'should return a hash object of translations' do
|
35
|
+
locale_file = locale_file_with_content <<-YAML
|
36
|
+
en:
|
37
|
+
hello: world
|
38
|
+
YAML
|
39
|
+
|
40
|
+
hash = {
|
41
|
+
'en' => {
|
42
|
+
'hello' => 'world'
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
expect(locale_file.content_yaml).to eq(hash)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#locale' do
|
52
|
+
|
53
|
+
it 'should return the locale code of the file' do
|
54
|
+
locale_file = locale_file_with_content <<-YAML
|
55
|
+
en:
|
56
|
+
hello: world
|
57
|
+
YAML
|
58
|
+
|
59
|
+
expect(locale_file.locale).to eq('en')
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#translations' do
|
65
|
+
|
66
|
+
it 'should return a hash object of translations' do
|
67
|
+
locale_file = locale_file_with_content <<-YAML
|
68
|
+
en:
|
69
|
+
hello: world
|
70
|
+
YAML
|
71
|
+
|
72
|
+
hash = {
|
73
|
+
'hello' => 'world'
|
74
|
+
}
|
75
|
+
|
76
|
+
expect(locale_file.translations).to eq(hash)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'be_a_complete_interpolation_of' do
|
4
|
+
|
5
|
+
describe 'spec/fixtures/complete.yml' do
|
6
|
+
it { is_expected.to be_a_complete_interpolation_of 'spec/fixtures/base.yml' }
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'spec/fixtures/incomplete.yml' do
|
10
|
+
it { is_expected.not_to be_a_complete_interpolation_of 'spec/fixtures/base.yml' }
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'With exceptions' do
|
14
|
+
|
15
|
+
describe 'spec/fixtures/incomplete.yml' do
|
16
|
+
it do
|
17
|
+
is_expected.to be_a_complete_interpolation_of 'spec/fixtures/base.yml',
|
18
|
+
except: [
|
19
|
+
'foo.text_1',
|
20
|
+
'foo.text_2',
|
21
|
+
]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'have_mutual_interpolation_of' do
|
4
|
+
|
5
|
+
describe 'spec/fixtures/complete.yml' do
|
6
|
+
it { is_expected.to have_mutual_interpolation_of 'spec/fixtures/base.yml' }
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'spec/fixtures/incomplete.yml' do
|
10
|
+
it { is_expected.to have_mutual_interpolation_of 'spec/fixtures/base.yml' }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'spec/fixtures/complete.yml' do
|
14
|
+
it { is_expected.not_to be_a_complete_interpolation_of 'spec/fixtures/incomplete.yml' }
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'With exceptions' do
|
18
|
+
|
19
|
+
describe 'spec/fixtures/complete.yml' do
|
20
|
+
it do
|
21
|
+
is_expected.to be_a_complete_interpolation_of 'spec/fixtures/incomplete.yml',
|
22
|
+
except: [
|
23
|
+
'foo.text_1',
|
24
|
+
'foo.text_2',
|
25
|
+
]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
2
|
+
$LOAD_PATH.unshift File.dirname(__FILE__)
|
3
|
+
|
4
|
+
require 'rspec'
|
5
|
+
require 'i18n_interpolation_spec'
|
6
|
+
|
7
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: i18n_interpolation_spec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yuki Iwanaga
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: RSpec matchers for testing the completeness of interpolation arguments
|
56
|
+
in locale files
|
57
|
+
email:
|
58
|
+
- yuki@creasty.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".ruby-version"
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- i18n_interpolation_spec.gemspec
|
71
|
+
- lib/i18n_interpolation_spec.rb
|
72
|
+
- lib/i18n_interpolation_spec/checker.rb
|
73
|
+
- lib/i18n_interpolation_spec/locale_file.rb
|
74
|
+
- lib/i18n_interpolation_spec/matchers/be_a_complete_interpolation_of.rb
|
75
|
+
- lib/i18n_interpolation_spec/matchers/have_mutual_interpolation_of.rb
|
76
|
+
- lib/i18n_interpolation_spec/version.rb
|
77
|
+
- spec/fixtures/base.yml
|
78
|
+
- spec/fixtures/complete.yml
|
79
|
+
- spec/fixtures/incomplete.yml
|
80
|
+
- spec/lib/i18n_interpolation_spec/checker_spec.rb
|
81
|
+
- spec/lib/i18n_interpolation_spec/locale_file_spec.rb
|
82
|
+
- spec/lib/i18n_interpolation_spec/matchers/be_a_complete_interpolation_of_spec.rb
|
83
|
+
- spec/lib/i18n_interpolation_spec/matchers/have_mutual_interpolation_of_spec.rb
|
84
|
+
- spec/spec_helper.rb
|
85
|
+
homepage: https://github.com/creasty/i18n_interpolation_spec
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.4.5
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: RSpec matchers for testing the completeness of interpolation arguments in
|
109
|
+
locale files
|
110
|
+
test_files:
|
111
|
+
- spec/fixtures/base.yml
|
112
|
+
- spec/fixtures/complete.yml
|
113
|
+
- spec/fixtures/incomplete.yml
|
114
|
+
- spec/lib/i18n_interpolation_spec/checker_spec.rb
|
115
|
+
- spec/lib/i18n_interpolation_spec/locale_file_spec.rb
|
116
|
+
- spec/lib/i18n_interpolation_spec/matchers/be_a_complete_interpolation_of_spec.rb
|
117
|
+
- spec/lib/i18n_interpolation_spec/matchers/have_mutual_interpolation_of_spec.rb
|
118
|
+
- spec/spec_helper.rb
|