i18n-spec 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -0
- data/VERSION +1 -1
- data/i18n-spec.gemspec +4 -2
- data/lib/i18n-spec/matchers/be_a_subset_of_matcher.rb +14 -0
- data/lib/i18n-spec/models/locale_file.rb +10 -4
- data/spec/fixtures/not_subset.yml +9 -0
- data/spec/lib/i18n-spec/matchers_spec.rb +3 -0
- metadata +13 -11
data/README.md
CHANGED
@@ -31,6 +31,12 @@ Even better, you can run all of these tests for every file in a directory like s
|
|
31
31
|
|
32
32
|
## Testing the validity of your translation data
|
33
33
|
|
34
|
+
To test that your locale file is a subset of the default locale file
|
35
|
+
|
36
|
+
describe "config/locales/fr.yml" do
|
37
|
+
it { should be_a_subset_of 'config/locales/en.yml' }
|
38
|
+
end
|
39
|
+
|
34
40
|
If you need to test that all translations have been completed :
|
35
41
|
|
36
42
|
describe "config/locales/fr.yml" do
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
data/i18n-spec.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{i18n-spec}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Christopher Dell}]
|
12
|
-
s.date = %q{2011-12-
|
12
|
+
s.date = %q{2011-12-15}
|
13
13
|
s.description = %q{Includes a number of rspec matchers to make specing your locale files easy peasy.}
|
14
14
|
s.email = %q{chris@tigrish.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
"i18n-spec.gemspec",
|
31
31
|
"lib/i18n-spec.rb",
|
32
32
|
"lib/i18n-spec/matchers/be_a_complete_translation_of_matcher.rb",
|
33
|
+
"lib/i18n-spec/matchers/be_a_subset_of_matcher.rb",
|
33
34
|
"lib/i18n-spec/matchers/be_named_like_top_level_namespace_matcher.rb",
|
34
35
|
"lib/i18n-spec/matchers/be_parseable_matcher.rb",
|
35
36
|
"lib/i18n-spec/matchers/have_one_top_level_namespace_matcher.rb",
|
@@ -41,6 +42,7 @@ Gem::Specification.new do |s|
|
|
41
42
|
"spec/fixtures/fr.yml",
|
42
43
|
"spec/fixtures/invalid_pluralization_keys.yml",
|
43
44
|
"spec/fixtures/multiple_top_levels.yml",
|
45
|
+
"spec/fixtures/not_subset.yml",
|
44
46
|
"spec/fixtures/unparseable.yml",
|
45
47
|
"spec/lib/i18n-spec/matchers_spec.rb",
|
46
48
|
"spec/spec_helper.rb"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
RSpec::Matchers.define :be_a_subset_of do |expected|
|
2
|
+
match do |actual|
|
3
|
+
@locale_file = I18nSpec::LocaleFile.new(actual)
|
4
|
+
@default_locale = I18nSpec::LocaleFile.new(expected)
|
5
|
+
@superset = @locale_file.flattened_translations.keys.reject do |key|
|
6
|
+
@default_locale.flattened_translations.keys.include?(key)
|
7
|
+
end
|
8
|
+
@superset.empty?
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message_for_should do |player|
|
12
|
+
"expected #{@locale_file.filepath} to not include :\n- " << @superset.join("\n- ")#{@superset.join"
|
13
|
+
end
|
14
|
+
end
|
@@ -2,10 +2,20 @@ module I18nSpec
|
|
2
2
|
class LocaleFile
|
3
3
|
PLURALIZATION_KEYS = %w{zero one two few many other}
|
4
4
|
|
5
|
+
attr_accessor :filepath
|
6
|
+
|
5
7
|
def initialize(filepath)
|
6
8
|
@filepath = filepath
|
7
9
|
end
|
8
10
|
|
11
|
+
def translations
|
12
|
+
@translations ||= Psych.load_file(@filepath)
|
13
|
+
end
|
14
|
+
|
15
|
+
def flattened_translations
|
16
|
+
@flattened_translations ||= flatten_tree(translations.values.first)
|
17
|
+
end
|
18
|
+
|
9
19
|
def is_parseable?
|
10
20
|
begin
|
11
21
|
Psych.load_file(@filepath)
|
@@ -39,10 +49,6 @@ module I18nSpec
|
|
39
49
|
|
40
50
|
protected
|
41
51
|
|
42
|
-
def translations
|
43
|
-
@translations ||= Psych.load_file(@filepath)
|
44
|
-
end
|
45
|
-
|
46
52
|
def flatten_tree(data, prefix = '', result = {})
|
47
53
|
data.each do |key, value|
|
48
54
|
current_prefix = prefix.empty? ? key.to_s : "#{prefix}.#{key}"
|
@@ -9,14 +9,17 @@ describe "Invalid files" do
|
|
9
9
|
it { 'spec/fixtures/invalid_pluralization_keys.yml'.should_not have_valid_pluralization_keys }
|
10
10
|
it { 'spec/fixtures/multiple_top_levels.yml'.should_not have_one_top_level_namespace }
|
11
11
|
it { 'spec/fixtures/multiple_top_levels.yml'.should_not be_named_like_top_level_namespace }
|
12
|
+
it { 'spec/fixtures/not_subset.yml'.should_not be_a_subset_of 'spec/fixtures/en.yml' }
|
12
13
|
end
|
13
14
|
|
14
15
|
describe "Translated files" do
|
15
16
|
describe 'spec/fixtures/fr.yml' do
|
17
|
+
it { should be_a_subset_of 'spec/fixtures/en.yml' }
|
16
18
|
it { should be_a_complete_translation_of 'spec/fixtures/en.yml' }
|
17
19
|
end
|
18
20
|
|
19
21
|
describe 'spec/fixtures/es.yml' do
|
22
|
+
it { should be_a_subset_of 'spec/fixtures/en.yml' }
|
20
23
|
it { should_not be_a_complete_translation_of 'spec/fixtures/en.yml'}
|
21
24
|
end
|
22
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n-spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-15 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70124619322000 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.3.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70124619322000
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &70124619321520 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.10
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70124619321520
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jeweler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70124619321040 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.6.4
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70124619321040
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rcov
|
49
|
-
requirement: &
|
49
|
+
requirement: &70124619320560 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70124619320560
|
58
58
|
description: Includes a number of rspec matchers to make specing your locale files
|
59
59
|
easy peasy.
|
60
60
|
email: chris@tigrish.com
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- i18n-spec.gemspec
|
78
78
|
- lib/i18n-spec.rb
|
79
79
|
- lib/i18n-spec/matchers/be_a_complete_translation_of_matcher.rb
|
80
|
+
- lib/i18n-spec/matchers/be_a_subset_of_matcher.rb
|
80
81
|
- lib/i18n-spec/matchers/be_named_like_top_level_namespace_matcher.rb
|
81
82
|
- lib/i18n-spec/matchers/be_parseable_matcher.rb
|
82
83
|
- lib/i18n-spec/matchers/have_one_top_level_namespace_matcher.rb
|
@@ -88,6 +89,7 @@ files:
|
|
88
89
|
- spec/fixtures/fr.yml
|
89
90
|
- spec/fixtures/invalid_pluralization_keys.yml
|
90
91
|
- spec/fixtures/multiple_top_levels.yml
|
92
|
+
- spec/fixtures/not_subset.yml
|
91
93
|
- spec/fixtures/unparseable.yml
|
92
94
|
- spec/lib/i18n-spec/matchers_spec.rb
|
93
95
|
- spec/spec_helper.rb
|
@@ -106,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
108
|
version: '0'
|
107
109
|
segments:
|
108
110
|
- 0
|
109
|
-
hash:
|
111
|
+
hash: 284635574898228492
|
110
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
113
|
none: false
|
112
114
|
requirements:
|