rspec-i18n 1.1.0 → 1.2.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.
Files changed (64) hide show
  1. data/.gitignore +2 -0
  2. data/Gemfile +6 -0
  3. data/History.rdoc +40 -2
  4. data/License.txt +0 -1
  5. data/README.rdoc +19 -19
  6. data/Rakefile +54 -4
  7. data/TODO.txt +5 -24
  8. data/Tasks +3 -0
  9. data/VERSION.yml +3 -3
  10. data/bin/rspec-i18n +4 -13
  11. data/cucumber.yml +1 -0
  12. data/examples/i18n/de/german_spec.rb +39 -0
  13. data/examples/i18n/pt/{person_spec.rb → portuguese_spec.rb} +39 -7
  14. data/features/command_line/list_languages.feature +113 -0
  15. data/features/support/env.rb +13 -0
  16. data/lib/spec-i18n/command_line/language_help_formatter.rb +64 -58
  17. data/lib/spec-i18n/command_line/main.rb +1 -6
  18. data/lib/spec-i18n/command_line/options.rb +31 -17
  19. data/lib/spec-i18n/dsl/main.rb +23 -4
  20. data/lib/spec-i18n/example.rb +1 -0
  21. data/lib/spec-i18n/example/before_and_after_hooks.rb +26 -8
  22. data/lib/spec-i18n/example/example_group_methods.rb +9 -6
  23. data/lib/spec-i18n/example/pending.rb +19 -0
  24. data/lib/spec-i18n/example/subject.rb +2 -4
  25. data/lib/spec-i18n/expectations/extensions/kernel.rb +6 -4
  26. data/lib/spec-i18n/languages.yml +88 -50
  27. data/lib/spec-i18n/matchers.rb +0 -2
  28. data/lib/spec-i18n/matchers/be.rb +36 -49
  29. data/lib/spec-i18n/matchers/method_missing.rb +33 -17
  30. data/lib/spec-i18n/matchers/register_all_matchers.rb +1 -2
  31. data/lib/spec-i18n/matchers/translate_basic_matchers.rb +40 -14
  32. data/lib/spec-i18n/parser/natural_language.rb +228 -27
  33. data/lib/spec-i18n/platform.rb +0 -2
  34. data/lib/spec-i18n/runner/configuration.rb +64 -6
  35. data/lib/spec-i18n/spec_language.rb +29 -2
  36. data/rspec-i18n.gemspec +30 -20
  37. data/spec/spec-i18n/command_line/language_help_formatter_spec.rb +74 -49
  38. data/spec/spec-i18n/command_line/options_spec.rb +11 -2
  39. data/spec/spec-i18n/dsl/main_spec.rb +54 -12
  40. data/spec/spec-i18n/example/before_and_after_hooks_spec.rb +210 -88
  41. data/spec/spec-i18n/example/example_group_methods_spec.rb +26 -8
  42. data/spec/spec-i18n/example/pending_spec.rb +41 -0
  43. data/spec/spec-i18n/example/subject_spec.rb +27 -41
  44. data/spec/spec-i18n/expectations/kernel_spec.rb +29 -15
  45. data/spec/spec-i18n/matchers/be_close_spec.rb +7 -5
  46. data/spec/spec-i18n/matchers/be_instance_of_spec.rb +4 -5
  47. data/spec/spec-i18n/matchers/be_kind_of_spec.rb +3 -6
  48. data/spec/spec-i18n/matchers/be_spec.rb +255 -89
  49. data/spec/spec-i18n/matchers/eql_spec.rb +4 -6
  50. data/spec/spec-i18n/matchers/equal_spec.rb +28 -7
  51. data/spec/spec-i18n/matchers/exist_spec.rb +4 -5
  52. data/spec/spec-i18n/matchers/have_spec.rb +1 -1
  53. data/spec/spec-i18n/matchers/include_spec.rb +6 -8
  54. data/spec/spec-i18n/matchers/match_spec.rb +4 -5
  55. data/spec/spec-i18n/matchers/raise_error_spec.rb +5 -4
  56. data/spec/spec-i18n/matchers/satisfy_spec.rb +4 -5
  57. data/spec/spec-i18n/parser/natural_language_spec.rb +420 -58
  58. data/spec/spec-i18n/runner/{runner_spec.rb → rspec_i18n_language_spec.rb} +0 -0
  59. data/spec/spec-i18n/runner/{configuration_spec.rb → rspec_i18n_spec.rb} +28 -7
  60. data/spec/spec-i18n/spec_examples/pt/pessoa_spec.rb +63 -5
  61. data/spec/spec-i18n/spec_language_spec.rb +24 -10
  62. data/spec/spec.opts +1 -2
  63. data/spec/spec_helper.rb +26 -18
  64. metadata +102 -44
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ include Spec::Example
4
+
5
+ describe Pending do
6
+
7
+ describe 'in portuguese for example' do
8
+
9
+ before(:each) do
10
+ @keywords = { "pending" => 'pendente|pendencia'}
11
+ stub_language!('pt', @keywords)
12
+ end
13
+
14
+ it "should have the translate pending method" do
15
+ Pending.translate_pending_keywords
16
+ name_methods = methods.to_symbols
17
+ [:pendente, :pendencia].each do |translated_pending_method|
18
+ name_methods.should include(translated_pending_method)
19
+ end
20
+ end
21
+
22
+ end
23
+
24
+ describe 'in spanish for example' do
25
+
26
+ before(:each) do
27
+ @keywords = { "pending" => 'spec_pendente|pendenciaa'}
28
+ stub_language!('es', @keywords)
29
+ end
30
+
31
+ it "should have the translate pending method" do
32
+ Pending.translate_pending_keywords
33
+ name_methods = methods.to_symbols
34
+ [:spec_pendente, :pendenciaa].each do |translated_pending_method|
35
+ name_methods.should include(translated_pending_method)
36
+ end
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -5,29 +5,30 @@ module Spec
5
5
  describe "implicit subject" do
6
6
 
7
7
  before(:each) do
8
- @pt = portuguese_language({'subject' => 'assunto', 'should' => 'deve',
9
- 'should_not' => 'nao_deve','matchers' => {}})
10
- Subject::ExampleMethods.register_subjects
11
- @es = spanish_language({'subject' => 'asunto', 'should' => 'deve',
12
- 'should_not' => 'nao_deve', 'matchers' => {}})
8
+ @keywords = {'subject' => 'assunto|asunto',
9
+ 'should' => 'deve|deveria',
10
+ 'should_not' => 'nao_deve|nao_deveria','matchers' => {}}
11
+ stub_language!("pt", @keywords)
13
12
  Subject::ExampleMethods.register_subjects
13
+ @name_methods = Subject::ExampleMethods.instance_methods.to_symbols
14
14
  end
15
15
 
16
16
  it 'should have the subject translated' do
17
- values = @pt['subject'].split('|')
18
- values << @es['subject'].split('|')
19
- values.flatten.each do |value_method|
20
- Subject::ExampleMethods.instance_methods.should be_include(value_method)
17
+ [:assunto, :asunto].each do |translated_subject|
18
+ @name_methods.should include(translated_subject)
19
+ end
20
+ end
21
+
22
+ it "should have the 'should' method translated in subject" do
23
+ [:deve, :deveria].each do |should_method|
24
+ @name_methods.should include(should_method)
21
25
  end
22
26
  end
23
27
 
24
28
  it "should have the should and should_not method trasnlated" do
25
- values = @pt['should'].split('|')
26
- other_values = @pt['should_not'].split('|')
27
- values << other_values
28
- values.flatten.each do |value_method|
29
- Subject::ExampleMethods.instance_methods.should be_include(value_method)
30
- end
29
+ [:nao_deve, :nao_deveria].each do |should_not_method|
30
+ @name_methods.should include(should_not_method)
31
+ end
31
32
  end
32
33
 
33
34
  describe "with a class" do
@@ -64,15 +65,7 @@ module Spec
64
65
  @group = Class.new do
65
66
  extend Spec::Example::Subject::ExampleGroupMethods
66
67
  include Spec::Example::Subject::ExampleMethods
67
- class << self
68
- def described_class
69
- Array
70
- end
71
- end
72
- def described_class
73
- self.class.described_class
74
- end
75
-
68
+
76
69
  subject {
77
70
  [1,2,3]
78
71
  }
@@ -91,7 +84,7 @@ module Spec
91
84
  doubly_nested_group = Class.new(nested_group)
92
85
 
93
86
  example = doubly_nested_group.new
94
- example.subject.should == [1,2,3]
87
+ example.asunto.should == [1,2,3]
95
88
  end
96
89
 
97
90
  end
@@ -99,26 +92,19 @@ module Spec
99
92
  describe ".its (to access subject's attributes)" do
100
93
 
101
94
  before(:each) do
102
- @its_examples = {'subject' => 'assunto', 'its' => 'exemplos', 'matchers' => {}}
103
- @pt = portuguese_language(@its_examples)
104
- Subject::ExampleGroupMethods.register_subjects
105
- @es = spanish_language({'subject' => 'assunto', 'its' => 'ejemplos', 'matchers' => {}})
95
+ @keywords = {'subject' => 'assunto', 'its' => 'exemplos', 'matchers' => {}}
96
+ stub_language!("pt", @keywords)
106
97
  Subject::ExampleGroupMethods.register_subjects
107
98
  end
108
99
 
109
- with_sandboxed_options do
110
- it "passes when expectation should pass" do
111
- group = Class.new(ExampleGroupDouble).describe(Array)
112
- child = group.exemplos(:length) { should == 0 }
113
- child.run(options).should == true
114
- end
115
-
116
- it "fails when expectation should fail" do
117
- group = Class.new(ExampleGroupDouble).describe(Array)
118
- child = group.ejemplos(:length) { should == 1 }
119
- child.run(options).should == false
120
- end
100
+ with_sandboxed_options do
101
+ it "passes when expectation should pass" do
102
+ group = Class.new(ExampleGroupDouble).describe(Array)
103
+ child = group.exemplos(:length) { should == 0 }
104
+ child.run(options).should == true
105
+ end
121
106
  end
107
+
122
108
  end
123
109
 
124
110
  end
@@ -1,25 +1,39 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Object, "#should and #should_not" do
4
-
4
+
5
5
  before(:each) do
6
- @pt = SpecI18n::Parser::NaturalLanguage.get("pt")
7
- @es = SpecI18n::Parser::NaturalLanguage.get("es")
8
- @languages = {"pt" => @pt,"es" => @es}
9
- @pt_keywords = {"should" => "deve", "should_not" => "nao_deve"}
10
- @es_keywords = {"should" => "debe", "should_not" => "no_debe"}
11
- @pt.stub!(:keywords).and_return(@pt_keywords)
12
- @es.stub!(:keywords).and_return(@es_keywords)
6
+ @keywords = { 'should' => 'deve|deveria', 'should_not' => 'nao_deve|nao_deveria'}
7
+ stub_language!('pt', @keywords)
8
+ Kernel.register_expectations_keywords
13
9
  end
14
-
15
- it "should have the 'should' and 'should_not' methods translated" do
16
- @languages.each do |lang, language|
17
- SpecI18n.stub!(:natural_language).and_return(language)
18
- Kernel.register_expectations_keywords
19
- language.expectation_keywords.values.to_a.flatten.each do |keyword|
20
- Kernel.methods.should include(keyword)
10
+
11
+ context 'when #should' do
12
+
13
+ it "should translate the #should method" do
14
+ [:deve, :deveria].each do |expetation_method|
15
+ Kernel.methods.to_sym.should include(expetation_method)
16
+ end
17
+ end
18
+
19
+ it "should use the #should method" do
20
+ 1.deve == 1
21
+ end
22
+
23
+ end
24
+
25
+ context 'when #should_not' do
26
+
27
+ it "should translate the #should_not method" do
28
+ [:nao_deve, :nao_deveria].each do |expectation_method|
29
+ Kernel.methods.to_sym.should include(expectation_method)
21
30
  end
22
31
  end
32
+
33
+ it "should use the #should_not method" do
34
+ 2.should_not == 1
35
+ end
36
+
23
37
  end
24
38
 
25
39
  end
@@ -5,20 +5,20 @@ module Spec
5
5
  describe "[actual.should] be_close(expected, delta)" do
6
6
 
7
7
  before(:each) do
8
- @expected_matcher = {'matchers' => { 'be_close' => 'estar_perto'} }
9
- portuguese_language(@expected_matcher)
8
+ @keywords = {'matchers' => { 'be_close' => 'estar_perto|estar_proximo'} }
9
+ stub_language!("pt", @keywords)
10
10
  Spec::Matchers.register_all_matchers
11
11
  end
12
12
 
13
13
  it "should register the be_close matcher" do
14
- values = @expected_matcher['matchers']['be_close'].split('|')
15
- values.each do |value_method|
16
- Object.instance_methods.should be_include(value_method)
14
+ [:estar_perto, :estar_proximo].each do |translate_matcher|
15
+ methods.to_symbols.should include translate_matcher
17
16
  end
18
17
  end
19
18
 
20
19
  it "matches when actual == expected" do
21
20
  estar_perto(5.0, 0.5).matches?(5.0).should be_true
21
+ estar_proximo(5.0, 0.5).matches?(5.0).should be_true
22
22
  end
23
23
 
24
24
  it "matches when actual < (expected + delta)" do
@@ -28,9 +28,11 @@ module Spec
28
28
  it "does not match when actual == (expected - delta)" do
29
29
  estar_perto(5.0, 0.5).matches?(4.5).should be_false
30
30
  end
31
+
31
32
  it "does not match when actual < (expected - delta)" do
32
33
  estar_perto(5.0, 0.5).matches?(4.49).should be_false
33
34
  end
35
+
34
36
  it "does not match when actual == (expected + delta)" do
35
37
  estar_perto(5.0, 0.5).matches?(5.5).should be_false
36
38
  end
@@ -5,15 +5,14 @@ module Spec
5
5
  describe 'the be_instance_of method' do
6
6
 
7
7
  before(:each) do
8
- @expected_matcher = { 'matchers' => { 'be_an_instance_of' => 'ser_instancia_de'} }
9
- portuguese_language(@expected_matcher)
8
+ @keywords = { 'matchers' => { 'be_an_instance_of' => 'ser_instancia_de|ser_instancia'} }
9
+ stub_language!("pt", @keywords)
10
10
  Spec::Matchers.register_all_matchers
11
11
  end
12
12
 
13
13
  it "register the be_an_instance_of method" do
14
- values = @expected_matcher['matchers']['be_an_instance_of'].split('|')
15
- values.each do |value_method|
16
- Object.instance_methods.should be_include(value_method)
14
+ [:ser_instancia_de, :ser_instancia].each do |translated_matcher|
15
+ methods.to_symbols.should include(translated_matcher)
17
16
  end
18
17
  end
19
18
 
@@ -5,16 +5,13 @@ module Spec
5
5
  describe 'the be_kind_of method' do
6
6
 
7
7
  before(:each) do
8
- @expected_matcher = { 'matchers' => { 'be_a_kind_of' => 'ser_do_tipo'} }
9
- portuguese_language(@expected_matcher)
8
+ @keywords = { 'matchers' => { 'be_a_kind_of' => 'ser_do_tipo'} }
9
+ stub_language!("pt", @keywords)
10
10
  Spec::Matchers.register_all_matchers
11
11
  end
12
12
 
13
13
  it "register the be_an_instance_of method" do
14
- values = @expected_matcher['matchers']['be_a_kind_of'].split('|')
15
- values.each do |value_method|
16
- Object.instance_methods.should be_include(value_method)
17
- end
14
+ methods.to_symbols.should include(:ser_do_tipo)
18
15
  end
19
16
 
20
17
  it "passes if actual is instance of expected class" do
@@ -1,13 +1,132 @@
1
+ # coding: UTF-8
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "should be_predicate" do
4
5
 
5
- before(:each) do
6
- portuguese_language({"matchers" => {"be" => "ser"}, "true" => "verdadeiro"})
7
- Spec::Matchers.register_all_matchers
6
+ context 'when translate the be matcher' do
7
+
8
+ it "should have the translate method" do
9
+ stub_language!('pt', {'matchers' => {'be' => 'ser'}})
10
+ Spec::Matchers.translate_be_matcher
11
+ methods.to_sym.should include(:ser)
12
+ end
13
+
14
+ it "should have the be translate matchers" do
15
+ stub_language!('de', { 'matchers' => { 'be' => 'sein' }})
16
+ Spec::Matchers.translate_be_matcher
17
+ methods.to_sym.should include(:sein)
18
+ end
19
+
20
+ it "should not raise exception for the be empty keyword" do
21
+ stub_language!('pt', { 'name' => 'Portuguese', 'native' => 'Português'})
22
+ lambda { Spec::Matchers.translate_be_matcher }.should_not raise_exception
23
+ end
24
+
25
+ end
26
+
27
+ context 'when method missing' do
28
+
29
+ before(:each) do
30
+ include Spec::Matchers
31
+ @keywords = { 'matchers' => { 'be' => 'ser' } }
32
+ stub_language!('pt', @keywords)
33
+ end
34
+
35
+ it "should return a Be Predicate" do
36
+ Spec::Matchers::BePredicate.should_receive(:new).with(:be_something)
37
+ method_missing(:be_something)
38
+ end
39
+
40
+ it "should not return a Be Predicate" do
41
+ Spec::Matchers::BePredicate.should_not_receive(:new)
42
+ method_missing(:have_something)
43
+ end
44
+
45
+ it "should return a Has Predicate" do
46
+ Spec::Matchers::Has.should_receive(:new).with(:have_something)
47
+ method_missing(:have_something)
48
+ end
49
+
50
+ it "should not return a Has Predicate" do
51
+ Spec::Matchers::Has.should_not_receive(:new)
52
+ method_missing(:be_something)
53
+ end
54
+
55
+ it "when don't have the be word in the language should return a Be Predicate" do
56
+ stub_language!('es', {'name' => 'Spanish', 'native' => 'Español'})
57
+ Spec::Matchers::BePredicate.should_receive(:new).with(:be_something)
58
+ method_missing(:be_something)
59
+ end
60
+
61
+ end
62
+
63
+ context 'when have? in method missing' do
64
+
65
+ before(:each) do
66
+ include Spec::Matchers
67
+ end
68
+
69
+ it "should return true(0 or anything) for string match" do
70
+ have_predicate?(:have_exactly).should be_true
71
+ end
72
+
73
+ it "should return true for have at least method" do
74
+ have_predicate?(:have_at_least).should be_true
75
+ end
76
+
77
+ it "should return true for have at most method" do
78
+ have_predicate?(:have_at_most).should be_true
79
+ end
80
+
81
+ it "should return false(false or nil) for not string match" do
82
+ have_predicate?(:be_true).should be_false
83
+ end
84
+
85
+ it "should return nil for not string match" do
86
+ have_predicate?(:be_false).should be_false
87
+ end
88
+
8
89
  end
9
90
 
10
- context "be predicate" do
91
+ context 'when be_predicate? in method missing' do
92
+
93
+ before(:each) do
94
+ include Spec::Matchers
95
+ end
96
+
97
+ it "should return true for be true string match" do
98
+ be_predicate?(:be_true).should be_true
99
+ end
100
+
101
+ it "should return true for the be false string match" do
102
+ be_predicate?(:be_false).should be_true
103
+ end
104
+
105
+ it "should return true for the be_something string match" do
106
+ be_predicate?(:be_something).should be_true
107
+ end
108
+
109
+ it "should return false for the have string match" do
110
+ be_predicate?(:have).should be_false
111
+ end
112
+
113
+ it "should return true for the have something string match" do
114
+ be_predicate?(:have_something).should be_false
115
+ end
116
+
117
+ it "should return true for the have exactly string match" do
118
+ be_predicate?(:have_exactly).should be_false
119
+ end
120
+
121
+ end
122
+
123
+ context 'when be predicate' do
124
+
125
+ before(:each) do
126
+ @keywords = {"matchers" => {"be" => "ser", "true_word" => "verdadeiro"}}
127
+ stub_language!("pt", @keywords)
128
+ Spec::Matchers.translate_be_matcher
129
+ end
11
130
 
12
131
  it "should pass with be language translated" do
13
132
  atual = stub("atual", :feliz? => true)
@@ -15,136 +134,182 @@ describe "should be_predicate" do
15
134
  end
16
135
 
17
136
  it "should fail when actual returns false for :predicate?" do
18
-
19
- pending('verify rspec 1.3')
20
-
21
137
  atual = stub("atual", :feliz? => false)
22
138
  lambda {
23
- atual.should be_feliz
139
+ atual.should ser_feliz
24
140
  }.should fail_with("expected feliz? to return true, got false")
25
141
  end
26
142
 
27
143
  it "should fail when actual returns false for :predicate?" do
28
-
29
- pending('verify rspec 1.3')
30
-
31
144
  atual = stub("atual", :feliz? => nil)
32
145
  lambda {
33
- atual.should be_feliz
146
+ atual.should ser_feliz
34
147
  }.should fail_with("expected feliz? to return true, got nil")
35
148
  end
36
149
  end
37
150
 
38
- context "be words" do
151
+ context 'when be words' do
152
+
39
153
  before(:each) do
40
154
  @pt = Parser::NaturalLanguage.get("pt")
41
155
  @es = Parser::NaturalLanguage.get("es")
42
- include Spec::Matchers
43
- @pt_keywords = { "matchers" => {'be' => 'ser',
44
- "true_word" => "verdadeiro", "empty_word" => "vazio",
45
- "false_word" => "falso", 'nil_word' => 'nulo'}}
46
- @pt.stub!(:keywords).and_return(@pt_keywords)
47
- @es_keywords = { "matchers" => {'be' => 'ser',
48
- "true_word" => "verdadero", "false_word" => "falso",
49
- 'nil_word' => 'nulo', 'empty_word' => "vazio"}}
50
- @es.stub!(:keywords).and_return(@es_keywords)
51
- end
52
-
53
- ['true', 'false', 'nil', 'empty'].each do |ruby_type|
54
- context "be #{ruby_type}" do
55
-
56
- it "should translate #{ruby_type} keyword for pt" do
57
- SpecI18n.stub!(:natural_language).and_return(@pt)
58
- matcher_be = "#{@pt_keywords['matchers']['be']}"
59
- matcher = @pt_keywords['matchers']["#{ruby_type}_word"]
60
- expected = "#{matcher_be}_#{matcher}"
61
- eval <<-MATCHER
62
- Be.matcher_be_some(:#{ruby_type} => true).should == [expected.to_sym ]
63
- MATCHER
156
+ end
157
+
158
+ describe "when matcher be some word(true, false,nil or empty)" do
159
+
160
+ context 'when write specifications exactly as it is in languages.yml' do
161
+
162
+ before(:each) do
163
+ @pt_keywords = { "matchers" => {'be' => 'ser|estar',
164
+ "true_word" => "verdadeiro|verdade", "false_word" => "falso|muito_falso",
165
+ "empty_word" => "vazio|sem_elemento", "nil_word" => "nulo|null" }}
166
+ stub_language!('pt', @pt_keywords)
167
+ end
168
+
169
+ it "should translate true word for languages" do
170
+ expected = [:ser_verdadeiro, :ser_verdade, :estar_verdadeiro, :estar_verdade]
171
+ Spec::Matchers.matcher_be_some(:true).should == expected
172
+ end
173
+
174
+ it "should translate false word for languages" do
175
+ expected = [:ser_falso, :ser_muito_falso, :estar_falso, :estar_muito_falso]
176
+ Spec::Matchers.matcher_be_some(:false).should == expected
177
+ end
178
+
179
+ it "should translate false word for languages" do
180
+ expected = [:ser_vazio, :ser_sem_elemento, :estar_vazio, :estar_sem_elemento]
181
+ Spec::Matchers.matcher_be_some(:empty).should == expected
182
+ end
183
+
184
+ it "should translate nil word for languages" do
185
+ expected = [:ser_nulo, :ser_null, :estar_nulo, :estar_null]
186
+ Spec::Matchers.matcher_be_some(:nil).should == expected
187
+ end
188
+ end
189
+
190
+ context 'when write specifications of objects, verbs and predicates in different orders' do
191
+
192
+ before(:each) do
193
+ @keywords = { 'matchers' => { 'be' => 'sein', 'true_word' => 'wahr*',
194
+ 'false_word' => 'falsch*', 'nil_word' => 'null*', 'empty_word' => 'leer*' } }
195
+ stub_language!('de', @keywords)
196
+ end
197
+
198
+ it "should return be true in different order" do
199
+ Spec::Matchers.matcher_be_some(:true).should eql([:wahr_sein])
200
+ end
201
+
202
+ it "should return be_false in different order" do
203
+ Spec::Matchers.matcher_be_some(:false).should eql([:falsch_sein])
204
+ end
205
+
206
+ it "should return be_nil in different order" do
207
+ Spec::Matchers.matcher_be_some(:nil).should eql([:null_sein])
208
+ end
209
+
210
+ it "should return be_empty in different order" do
211
+ Spec::Matchers.matcher_be_some(:empty).should eql([:leer_sein])
64
212
  end
65
213
 
66
- it "should translate #{ruby_type} keyword for es" do
67
- SpecI18n.stub!(:natural_language).and_return(@es)
68
- matcher_be = "#{@es_keywords['matchers']['be']}"
69
- matcher = @es_keywords['matchers']["#{ruby_type}_word"]
70
- expected = "#{matcher_be}_#{matcher}"
71
- eval <<-MATCHER
72
- Be.matcher_be_some(:#{ruby_type} => true).should == [expected.to_sym ]
73
- MATCHER
74
- end
75
214
  end
215
+
76
216
  end
77
217
 
78
218
  context "be true predicate" do
79
-
80
- it "should pass when actual equal?(true)" do
81
- [@pt, @es].each do |language|
82
- SpecI18n.stub!(:natural_language).and_return(language)
83
- Be.translate_be_true
84
- matcher_be_some(:true => true).each do |word_be_true|
85
- eval <<-BE_TRUE
86
- true.should #{word_be_true}
87
- 1.should #{word_be_true}
88
- BE_TRUE
89
- end
90
- end
91
- end
219
+
220
+ before(:each) do
221
+ @pt_keywords = { "matchers" => {'be' => 'ser', "true_word" => "verdadeiro|verdade" }}
222
+ stub_keywords!(@pt, @pt_keywords)
223
+ mock_natural_language(@pt)
224
+ Spec::Matchers.translate_be_true
225
+ end
226
+
227
+ it "should pass when actual equal?(true) for language" do
228
+ true.should ser_verdadeiro
229
+ true.should ser_verdade
230
+ end
231
+
232
+ it "should pass when actual is 1" do
233
+ 1.should ser_verdadeiro
234
+ 1.should ser_verdade
235
+ end
92
236
 
93
237
  end
94
238
 
95
239
  context "be false predicate" do
96
240
 
97
- it "should pass when actual equal?(true)" do
98
- [@pt, @es].each do |language|
99
- SpecI18n.stub!(:natural_language).and_return(language)
100
- Be.translate_be_false
101
- matcher_be_some(:false => true).each do |word_be_false|
102
- eval <<-BE_FALSE
103
- false.should #{word_be_false}
104
- nil.should #{word_be_false}
105
- BE_FALSE
106
- end
107
- end
108
- end
241
+ before(:each) do
242
+ @pt_keywords = { "matchers" => {'be' => 'ser', "false_word" => "falso|muito_falso" }}
243
+ stub_keywords!(@pt, @pt_keywords)
244
+ mock_natural_language(@pt)
245
+ Spec::Matchers.translate_be_false
246
+ end
247
+
248
+ it "should pass when actual equal?(false) for language" do
249
+ false.should ser_falso
250
+ false.should ser_muito_falso
251
+ end
109
252
 
253
+ it "should pass when actual equal?(nil) for language" do
254
+ nil.should ser_falso
255
+ nil.should ser_muito_falso
256
+ end
110
257
 
111
258
  end
112
259
 
113
260
  context "be nil predicate" do
261
+
262
+ before(:each) do
263
+ @pt_keywords = { "matchers" => {'be' => 'ser', "nil_word" => "nulo|null" }}
264
+ stub_keywords!(@pt, @pt_keywords)
265
+ mock_natural_language(@pt)
266
+ Spec::Matchers.translate_be_nil
267
+ end
114
268
 
115
269
  it "should pass when actual is nil" do
116
- [@pt, @es].each do |language|
117
- SpecI18n.stub!(:natural_language).and_return(language)
118
- Be.translate_be_nil
119
- matcher_be_some(:nil => true).each do |word_be_nil|
120
- eval <<-BE_NIL
121
- nil.should #{word_be_nil}
122
- BE_NIL
123
- end
124
- end
270
+ nil.should ser_nulo
271
+ nil.should ser_null
125
272
  end
273
+
274
+ it "should pass when not be nil and actual is not nil" do
275
+ :not_nil.should_not ser_nulo
276
+ :not_nil.should_not ser_null
277
+ end
278
+
126
279
  end
127
280
 
128
281
  context "be empty predicate" do
129
- it "should pass when actual is nil" do
130
- [@pt, @es].each do |language|
131
- SpecI18n.stub!(:natural_language).and_return(language)
132
- Be.translate_be_empty
133
- matcher_be_some(:empty => true).each do |word_be_nil|
134
- eval <<-BE_EMPTY
135
- [].should #{word_be_nil}
136
- BE_EMPTY
137
- end
138
- end
282
+
283
+ before(:each) do
284
+ @pt_keywords = { "matchers" => {'be' => 'ser', "empty_word" => "vazio|sem_elemento" }}
285
+ stub_keywords!(@pt, @pt_keywords)
286
+ mock_natural_language(@pt)
287
+ Spec::Matchers.translate_be_empty
288
+ end
289
+
290
+ it "should pass when actual is empty" do
291
+ [].should ser_vazio
292
+ [].should ser_sem_elemento
139
293
  end
294
+
295
+ it "should pass when not is empty and actual is not empty" do
296
+ [:not_empty].should_not ser_vazio
297
+ [:not_empty].should_not ser_sem_elemento
298
+ end
299
+
140
300
  end
141
301
 
142
302
  end
143
303
 
144
- context "convert the be word" do
304
+ context 'when be to english' do
305
+
145
306
  it 'should convert be word to english with two parameters' do
146
307
  be_to_english(:ser_feliz, 'ser|estar').should == :be_feliz
147
308
  end
309
+
310
+ it "should convert be words to english" do
311
+ be_to_english(:estar_feliz, 'ser|estar').should == :be_feliz
312
+ end
148
313
 
149
314
  it "should convert be word to english" do
150
315
  be_to_english(:ser_feliz, :ser).should == :be_feliz
@@ -161,6 +326,7 @@ describe "should be_predicate" do
161
326
  it "should keep the same word for the nil be word" do
162
327
  be_to_english(:be_include, nil).should == :be_include
163
328
  end
329
+
164
330
  end
165
331
 
166
332
  end