i18n-spec 0.0.4 → 0.0.5

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.
data/README.md CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  [![Build Status](https://secure.travis-ci.org/tigrish/i18n-spec.png)](http://travis-ci.org/tigrish/i18n-spec)
4
4
 
5
- ## RSpec matchers for I18n files
5
+ i18n-spec provides RSpec matchers for testing your locale files and their translations.
6
6
 
7
- i18n-spec provides RSpec matchers for testing your locale files.
7
+ ## Testing the validity of your locale files
8
8
 
9
- ## Implemented matchers
9
+ There are a few matchers available; the subject of the spec is always a path to a locale file.
10
10
 
11
11
  describe "config/locales/en.yml" do
12
12
  it { should be_parseable }
@@ -15,13 +15,13 @@ i18n-spec provides RSpec matchers for testing your locale files.
15
15
  it { should be_named_like_top_level_namespace }
16
16
  end
17
17
 
18
- All of these tests can be ran with a shared example :
18
+ All of these tests can be ran in one line with a shared example :
19
19
 
20
20
  describe "A locale file" do
21
21
  it_behaves_like 'a valid locale file', 'config/locales/en.yml'
22
22
  end
23
23
 
24
- You can run all of these tests for every file in a directory like so :
24
+ Even better, you can run all of these tests for every file in a directory like so :
25
25
 
26
26
  Dir.glob('config/locale/*.yml') do |locale_file|
27
27
  describe "a locale file" do
@@ -29,9 +29,10 @@ You can run all of these tests for every file in a directory like so :
29
29
  end
30
30
  end
31
31
 
32
- ## TODO
32
+ ## Testing the validity of your translation data
33
+
34
+ If you need to test that all translations have been completed :
33
35
 
34
36
  describe "config/locales/fr.yml" do
35
- it { should be_a_subset_of('config/locales/en.yml')
36
- it { should be_a_complete_translation_of('config/locales/en.yml') }
37
+ it { should be_a_complete_translation_of 'config/locales/en.yml' }
37
38
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
data/i18n-spec.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{i18n-spec}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
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}]
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
29
29
  "VERSION",
30
30
  "i18n-spec.gemspec",
31
31
  "lib/i18n-spec.rb",
32
+ "lib/i18n-spec/matchers/be_a_complete_translation_of_matcher.rb",
32
33
  "lib/i18n-spec/matchers/be_named_like_top_level_namespace_matcher.rb",
33
34
  "lib/i18n-spec/matchers/be_parseable_matcher.rb",
34
35
  "lib/i18n-spec/matchers/have_one_top_level_namespace_matcher.rb",
@@ -36,6 +37,8 @@ Gem::Specification.new do |s|
36
37
  "lib/i18n-spec/models/locale_file.rb",
37
38
  "lib/i18n-spec/shared_examples/valid_locale_file.rb",
38
39
  "spec/fixtures/en.yml",
40
+ "spec/fixtures/es.yml",
41
+ "spec/fixtures/fr.yml",
39
42
  "spec/fixtures/invalid_pluralization_keys.yml",
40
43
  "spec/fixtures/multiple_top_levels.yml",
41
44
  "spec/fixtures/unparseable.yml",
@@ -0,0 +1,6 @@
1
+ RSpec::Matchers.define :be_a_complete_translation_of do |expected|
2
+ match do |actual|
3
+ locale_file = I18nSpec::LocaleFile.new(actual)
4
+ locale_file.is_a_complete_tranlsation_of? expected
5
+ end
6
+ end
@@ -30,6 +30,11 @@ module I18nSpec
30
30
  translations.keys.first == File.basename(@filepath, File.extname(@filepath))
31
31
  end
32
32
 
33
+ def is_a_complete_tranlsation_of?(default_locale_filepath)
34
+ default_locale = LocaleFile.new(default_locale_filepath)
35
+ translations.keys.sort == default_locale.translations.keys.sort
36
+ end
37
+
33
38
  protected
34
39
 
35
40
  def translations
@@ -0,0 +1,9 @@
1
+ es:
2
+ cats:
3
+ zero: 'no gatos'
4
+ one: 'un gato'
5
+ other: '%{count} gatos'
6
+ itteh:
7
+ bitteh:
8
+ ceiling:
9
+ kitteh: 'te mira'
@@ -0,0 +1,10 @@
1
+ en:
2
+ hello: 'osalu'
3
+ cats:
4
+ zero: 'pas de chats'
5
+ one: 'un chat'
6
+ other: '%{count} chats'
7
+ itteh:
8
+ bitteh:
9
+ ceiling:
10
+ kitteh: 'te regarde'
@@ -9,4 +9,14 @@ 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
+ end
13
+
14
+ describe "Translated files" do
15
+ describe 'spec/fixtures/fr.yml' do
16
+ it { should be_a_complete_translation_of 'spec/fixtures/en.yml' }
17
+ end
18
+
19
+ describe 'spec/fixtures/es.yml' do
20
+ it { should_not be_a_complete_translation_of 'spec/fixtures/en.yml'}
21
+ end
12
22
  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
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-12-14 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70124559385520 !ruby/object:Gem::Requirement
16
+ requirement: &70175620524520 !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: *70124559385520
24
+ version_requirements: *70175620524520
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &70124559385040 !ruby/object:Gem::Requirement
27
+ requirement: &70175620524040 !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: *70124559385040
35
+ version_requirements: *70175620524040
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &70124559384560 !ruby/object:Gem::Requirement
38
+ requirement: &70175620523560 !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: *70124559384560
46
+ version_requirements: *70175620523560
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rcov
49
- requirement: &70124559384080 !ruby/object:Gem::Requirement
49
+ requirement: &70175620540200 !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: *70124559384080
57
+ version_requirements: *70175620540200
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
@@ -76,6 +76,7 @@ files:
76
76
  - VERSION
77
77
  - i18n-spec.gemspec
78
78
  - lib/i18n-spec.rb
79
+ - lib/i18n-spec/matchers/be_a_complete_translation_of_matcher.rb
79
80
  - lib/i18n-spec/matchers/be_named_like_top_level_namespace_matcher.rb
80
81
  - lib/i18n-spec/matchers/be_parseable_matcher.rb
81
82
  - lib/i18n-spec/matchers/have_one_top_level_namespace_matcher.rb
@@ -83,6 +84,8 @@ files:
83
84
  - lib/i18n-spec/models/locale_file.rb
84
85
  - lib/i18n-spec/shared_examples/valid_locale_file.rb
85
86
  - spec/fixtures/en.yml
87
+ - spec/fixtures/es.yml
88
+ - spec/fixtures/fr.yml
86
89
  - spec/fixtures/invalid_pluralization_keys.yml
87
90
  - spec/fixtures/multiple_top_levels.yml
88
91
  - spec/fixtures/unparseable.yml
@@ -103,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
106
  version: '0'
104
107
  segments:
105
108
  - 0
106
- hash: -4198525936416785934
109
+ hash: 3986797986859654700
107
110
  required_rubygems_version: !ruby/object:Gem::Requirement
108
111
  none: false
109
112
  requirements: