i18n-spec 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1 +1,4 @@
1
- rvm: 1.9.2
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
data/Gemfile CHANGED
@@ -4,5 +4,6 @@ group :development do
4
4
  gem "rspec", ">= 2.4.0"
5
5
  gem "bundler", "> 1.0.10" # so that we know we have Psych
6
6
  gem "jeweler", "~> 1.6.4"
7
- gem "rcov", ">= 0"
7
+ gem "rdoc"
8
+ gem "rcov", ">= 0" if RUBY_VERSION < '1.9'
8
9
  end
data/Gemfile.lock CHANGED
@@ -7,8 +7,10 @@ GEM
7
7
  bundler (~> 1.0)
8
8
  git (>= 1.2.5)
9
9
  rake
10
+ json (1.6.6)
10
11
  rake (0.9.2.2)
11
- rcov (0.9.11)
12
+ rdoc (3.12)
13
+ json (~> 1.4)
12
14
  rspec (2.9.0)
13
15
  rspec-core (~> 2.9.0)
14
16
  rspec-expectations (~> 2.9.0)
@@ -24,5 +26,5 @@ PLATFORMS
24
26
  DEPENDENCIES
25
27
  bundler (> 1.0.10)
26
28
  jeweler (~> 1.6.4)
27
- rcov
29
+ rdoc
28
30
  rspec (>= 2.4.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.2.0
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.1.3"
8
+ s.version = "0.2.0"
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{2012-03-26}
12
+ s.date = %q{2012-03-28}
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 = [
@@ -64,18 +64,18 @@ Gem::Specification.new do |s|
64
64
  s.add_development_dependency(%q<rspec>, [">= 2.4.0"])
65
65
  s.add_development_dependency(%q<bundler>, ["> 1.0.10"])
66
66
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
67
- s.add_development_dependency(%q<rcov>, [">= 0"])
67
+ s.add_development_dependency(%q<rdoc>, [">= 0"])
68
68
  else
69
69
  s.add_dependency(%q<rspec>, [">= 2.4.0"])
70
70
  s.add_dependency(%q<bundler>, ["> 1.0.10"])
71
71
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
72
- s.add_dependency(%q<rcov>, [">= 0"])
72
+ s.add_dependency(%q<rdoc>, [">= 0"])
73
73
  end
74
74
  else
75
75
  s.add_dependency(%q<rspec>, [">= 2.4.0"])
76
76
  s.add_dependency(%q<bundler>, ["> 1.0.10"])
77
77
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
78
- s.add_dependency(%q<rcov>, [">= 0"])
78
+ s.add_dependency(%q<rdoc>, [">= 0"])
79
79
  end
80
80
  end
81
81
 
@@ -1,6 +1,6 @@
1
1
  RSpec::Matchers.define :have_legacy_interpolations do |expected|
2
2
  match do |actual|
3
3
  locale_file = I18nSpec::LocaleFile.new(actual)
4
- locale_file.content =~ /{{.+}}/
4
+ locale_file.content =~ /\{\{.+\}\}/
5
5
  end
6
6
  end
@@ -15,7 +15,7 @@ module I18nSpec
15
15
  end
16
16
 
17
17
  def translations
18
- @translations ||= Psych.load(content)
18
+ @translations ||= yaml_load_content
19
19
  end
20
20
 
21
21
  def flattened_translations
@@ -23,9 +23,15 @@ module I18nSpec
23
23
  end
24
24
 
25
25
  def pluralizations
26
- flatten_tree(translations).select do |key, value|
26
+ result = flatten_tree(translations).select do |key, value|
27
27
  value.is_a?(Hash)
28
28
  end
29
+
30
+ if result.is_a?(Array)
31
+ Hash[result]
32
+ else
33
+ result
34
+ end
29
35
  end
30
36
 
31
37
  def invalid_pluralization_keys
@@ -41,9 +47,12 @@ module I18nSpec
41
47
 
42
48
  def is_parseable?
43
49
  begin
44
- Psych.load(content)
50
+ yaml_load_content
45
51
  true
46
- rescue Psych::SyntaxError => e
52
+ rescue YAML::ParseError => e
53
+ @errors[:unparseable] = e.to_s
54
+ false
55
+ rescue ArgumentError => e
47
56
  @errors[:unparseable] = e.to_s
48
57
  false
49
58
  end
@@ -76,5 +85,13 @@ module I18nSpec
76
85
  keys.any? {|k| PLURALIZATION_KEYS.include?(k) }
77
86
  end
78
87
 
88
+ def yaml_load_content
89
+ if defined? Psych
90
+ Psych.load(content)
91
+ else
92
+ YAML.load(content)
93
+ end
94
+ end
95
+
79
96
  end
80
97
  end
data/lib/i18n-spec.rb CHANGED
@@ -1,4 +1,7 @@
1
- require 'psych'
1
+ if defined?(Psych) and !defined?(YAML::ParseError)
2
+ YAML::ParseError = Psych::SyntaxError
3
+ end
4
+
2
5
  Dir[File.dirname(__FILE__) + '/i18n-spec/models/*.rb'].each {|file| require file }
3
6
  Dir[File.dirname(__FILE__) + '/i18n-spec/matchers/*.rb'].each {|file| require file }
4
- Dir[File.dirname(__FILE__) + '/i18n-spec/shared_examples/*.rb'].each {|file| require file }
7
+ Dir[File.dirname(__FILE__) + '/i18n-spec/shared_examples/*.rb'].each {|file| require file }
@@ -74,12 +74,18 @@ describe I18nSpec::LocaleFile do
74
74
  let(:locale_file) { locale_file_with_content(content) }
75
75
 
76
76
  it "returns the parent that contains invalid pluralizations" do
77
- locale_file.invalid_pluralization_keys.should == ['en.cats', 'en.dogs']
77
+ locale_file.invalid_pluralization_keys.size.should == 2
78
+ locale_file.invalid_pluralization_keys.should be_include 'en.cats'
79
+ locale_file.invalid_pluralization_keys.should be_include 'en.dogs'
80
+ locale_file.invalid_pluralization_keys.should_not be_include 'en.birds'
78
81
  end
79
82
 
80
83
  it "adds a :invalid_pluralization_keys error with each invalid key" do
81
84
  locale_file.invalid_pluralization_keys
82
- locale_file.errors[:invalid_pluralization_keys].should == ['en.cats', 'en.dogs']
85
+ locale_file.invalid_pluralization_keys.size.should == 2
86
+ locale_file.invalid_pluralization_keys.should be_include 'en.cats'
87
+ locale_file.invalid_pluralization_keys.should be_include 'en.dogs'
88
+ locale_file.invalid_pluralization_keys.should_not be_include 'en.birds'
83
89
  end
84
90
  end
85
- end
91
+ 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.1.3
4
+ version: 0.2.0
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: 2012-03-26 00:00:00.000000000 Z
12
+ date: 2012-03-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70114168057380 !ruby/object:Gem::Requirement
16
+ requirement: &70303016673480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.4.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70114168057380
24
+ version_requirements: *70303016673480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &70114168056480 !ruby/object:Gem::Requirement
27
+ requirement: &70303016672820 !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: *70114168056480
35
+ version_requirements: *70303016672820
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &70114168416980 !ruby/object:Gem::Requirement
38
+ requirement: &70303016688620 !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: *70114168416980
46
+ version_requirements: *70303016688620
47
47
  - !ruby/object:Gem::Dependency
48
- name: rcov
49
- requirement: &70114168415980 !ruby/object:Gem::Requirement
48
+ name: rdoc
49
+ requirement: &70303016687780 !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: *70114168415980
57
+ version_requirements: *70303016687780
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
@@ -112,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  segments:
114
114
  - 0
115
- hash: 3463321469502897838
115
+ hash: -3260796434736364746
116
116
  required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements: