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.
- data/.gitignore +2 -0
- data/Gemfile +6 -0
- data/History.rdoc +40 -2
- data/License.txt +0 -1
- data/README.rdoc +19 -19
- data/Rakefile +54 -4
- data/TODO.txt +5 -24
- data/Tasks +3 -0
- data/VERSION.yml +3 -3
- data/bin/rspec-i18n +4 -13
- data/cucumber.yml +1 -0
- data/examples/i18n/de/german_spec.rb +39 -0
- data/examples/i18n/pt/{person_spec.rb → portuguese_spec.rb} +39 -7
- data/features/command_line/list_languages.feature +113 -0
- data/features/support/env.rb +13 -0
- data/lib/spec-i18n/command_line/language_help_formatter.rb +64 -58
- data/lib/spec-i18n/command_line/main.rb +1 -6
- data/lib/spec-i18n/command_line/options.rb +31 -17
- data/lib/spec-i18n/dsl/main.rb +23 -4
- data/lib/spec-i18n/example.rb +1 -0
- data/lib/spec-i18n/example/before_and_after_hooks.rb +26 -8
- data/lib/spec-i18n/example/example_group_methods.rb +9 -6
- data/lib/spec-i18n/example/pending.rb +19 -0
- data/lib/spec-i18n/example/subject.rb +2 -4
- data/lib/spec-i18n/expectations/extensions/kernel.rb +6 -4
- data/lib/spec-i18n/languages.yml +88 -50
- data/lib/spec-i18n/matchers.rb +0 -2
- data/lib/spec-i18n/matchers/be.rb +36 -49
- data/lib/spec-i18n/matchers/method_missing.rb +33 -17
- data/lib/spec-i18n/matchers/register_all_matchers.rb +1 -2
- data/lib/spec-i18n/matchers/translate_basic_matchers.rb +40 -14
- data/lib/spec-i18n/parser/natural_language.rb +228 -27
- data/lib/spec-i18n/platform.rb +0 -2
- data/lib/spec-i18n/runner/configuration.rb +64 -6
- data/lib/spec-i18n/spec_language.rb +29 -2
- data/rspec-i18n.gemspec +30 -20
- data/spec/spec-i18n/command_line/language_help_formatter_spec.rb +74 -49
- data/spec/spec-i18n/command_line/options_spec.rb +11 -2
- data/spec/spec-i18n/dsl/main_spec.rb +54 -12
- data/spec/spec-i18n/example/before_and_after_hooks_spec.rb +210 -88
- data/spec/spec-i18n/example/example_group_methods_spec.rb +26 -8
- data/spec/spec-i18n/example/pending_spec.rb +41 -0
- data/spec/spec-i18n/example/subject_spec.rb +27 -41
- data/spec/spec-i18n/expectations/kernel_spec.rb +29 -15
- data/spec/spec-i18n/matchers/be_close_spec.rb +7 -5
- data/spec/spec-i18n/matchers/be_instance_of_spec.rb +4 -5
- data/spec/spec-i18n/matchers/be_kind_of_spec.rb +3 -6
- data/spec/spec-i18n/matchers/be_spec.rb +255 -89
- data/spec/spec-i18n/matchers/eql_spec.rb +4 -6
- data/spec/spec-i18n/matchers/equal_spec.rb +28 -7
- data/spec/spec-i18n/matchers/exist_spec.rb +4 -5
- data/spec/spec-i18n/matchers/have_spec.rb +1 -1
- data/spec/spec-i18n/matchers/include_spec.rb +6 -8
- data/spec/spec-i18n/matchers/match_spec.rb +4 -5
- data/spec/spec-i18n/matchers/raise_error_spec.rb +5 -4
- data/spec/spec-i18n/matchers/satisfy_spec.rb +4 -5
- data/spec/spec-i18n/parser/natural_language_spec.rb +420 -58
- data/spec/spec-i18n/runner/{runner_spec.rb → rspec_i18n_language_spec.rb} +0 -0
- data/spec/spec-i18n/runner/{configuration_spec.rb → rspec_i18n_spec.rb} +28 -7
- data/spec/spec-i18n/spec_examples/pt/pessoa_spec.rb +63 -5
- data/spec/spec-i18n/spec_language_spec.rb +24 -10
- data/spec/spec.opts +1 -2
- data/spec/spec_helper.rb +26 -18
- metadata +102 -44
@@ -7,23 +7,65 @@ describe Main do
|
|
7
7
|
@pt = SpecI18n::Parser::NaturalLanguage.get("pt")
|
8
8
|
@es = SpecI18n::Parser::NaturalLanguage.get("es")
|
9
9
|
@languages = {"pt" => @pt,"es" => @es}
|
10
|
-
@pt_keywords = {"describe" => "descreva"}
|
11
|
-
@es_keywords = {"describe" => "descreva"}
|
12
|
-
@pt.stub!(:keywords).and_return(@pt_keywords)
|
13
|
-
@es.stub!(:keywords).and_return(@es_keywords)
|
14
10
|
end
|
15
11
|
|
16
12
|
describe 'the manipulation of methods of the domain specific language' do
|
13
|
+
before(:each) do
|
14
|
+
@pt_keywords = {"describe" => "descreva|contexto"}
|
15
|
+
@es_keywords = {"describe" => "descreba|describir"}
|
16
|
+
@pt.stub!(:keywords).and_return(@pt_keywords)
|
17
|
+
@es.stub!(:keywords).and_return(@es_keywords)
|
18
|
+
end
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
Main.methods.should include(keyword)
|
24
|
-
end
|
25
|
-
end
|
20
|
+
it "should have the methods of the dsl keywords of the language specified" do
|
21
|
+
mock_natural_language(@pt)
|
22
|
+
Main.register_adverbs
|
23
|
+
[:descreva, :contexto].each do |keyword|
|
24
|
+
Main.methods.all_to_symbols.should include(keyword)
|
26
25
|
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should have the method for other language" do
|
29
|
+
mock_natural_language(@es)
|
30
|
+
Main.register_adverbs
|
31
|
+
[:descreba, :describir].each do |keyword|
|
32
|
+
Main.methods.all_to_symbols.should include(keyword)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "the manipulation of shared examples for" do
|
39
|
+
|
40
|
+
before(:each) do
|
41
|
+
@keywords = { "shared_examples_for" => "exemplos_distribuidos|exemplos_distribuidos_para" }
|
42
|
+
stub_language!("pt", @keywords)
|
43
|
+
Main.translate_shared_examples_for
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should register all the keywords for the shared examples for" do
|
47
|
+
[:exemplos_distribuidos, :exemplos_distribuidos_para].each do |keyword|
|
48
|
+
Main.methods.to_symbols.should include(keyword)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "when translate share_as" do
|
55
|
+
|
56
|
+
before(:each) do
|
57
|
+
@keywords = { "share_as" => 'distribua|distribua_como' }
|
58
|
+
stub_language!('pt', @keywords)
|
59
|
+
Main.translate_share_as_keywords
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should include the translate methods" do
|
63
|
+
main_methods = Main.methods.to_symbols
|
64
|
+
[:distribua, :distribua_como].each do |method_name|
|
65
|
+
main_methods.should include(method_name)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
27
69
|
end
|
28
70
|
|
29
71
|
end
|
@@ -3,82 +3,205 @@ require 'spec_helper'
|
|
3
3
|
module Spec
|
4
4
|
module Example
|
5
5
|
describe BeforeAndAfterHooks do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
6
|
+
|
7
|
+
describe 'when translate the hooks' do
|
8
|
+
|
9
|
+
context 'when portuguese' do
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
@keywords = { 'before' => 'antes|anterior', 'after' => 'depois|posterior' }
|
13
|
+
stub_language!('pt', @keywords)
|
14
|
+
Spec::Example::BeforeAndAfterHooks.register_hooks
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should include all i18n methods to Before Hooks" do
|
18
|
+
name_methods = BeforeAndAfterHooks.methods.to_symbols
|
19
|
+
[:antes, :anterior].each do |translated_method|
|
20
|
+
name_methods.should include(translated_method)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should include all i18n methods to After Hooks" do
|
25
|
+
name_methods = BeforeAndAfterHooks.methods.to_symbols
|
26
|
+
[:depois, :posterior].each do |translated_method|
|
27
|
+
name_methods.should include(translated_method)
|
28
|
+
end
|
27
29
|
end
|
30
|
+
|
28
31
|
end
|
32
|
+
|
29
33
|
end
|
30
34
|
|
31
|
-
|
35
|
+
describe 'when hooks' do
|
32
36
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
scope = language.hooks_params_keywords["each"].first
|
38
|
-
self.should_receive(:before_each_parts)
|
39
|
-
before_parts(scope)
|
40
|
-
end
|
37
|
+
before(:each) do
|
38
|
+
SpecI18n.stub!(:spec_language).and_return('pt')
|
39
|
+
@keywords = { 'hooks' => { 'each' => 'cada|de_cada', 'all' => 'todos|de_todos', 'suite' => 'suite|da_suite'}}
|
40
|
+
stub_language!('pt', @keywords)
|
41
41
|
end
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
42
|
+
|
43
|
+
describe "the before hook" do
|
44
|
+
|
45
|
+
context 'when :each' do
|
46
|
+
|
47
|
+
it "should translate the :each parameters and parse options" do
|
48
|
+
[:cada, :de_cada].each do |scope|
|
49
|
+
BeforeAndAfterHooks.should_receive(:before_each_parts)
|
50
|
+
BeforeAndAfterHooks.before_parts(scope)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should not call the :all parameters for :each hook" do
|
55
|
+
BeforeAndAfterHooks.should_not_receive(:before_all_parts)
|
56
|
+
[:cada, :de_cada].each do |scope|
|
57
|
+
BeforeAndAfterHooks.before_parts(scope)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should not call the :suite parameters for :suite hook" do
|
62
|
+
BeforeAndAfterHooks.should_not_receive(:before_suite_parts)
|
63
|
+
[:cada, :de_cada].each do |scope|
|
64
|
+
BeforeAndAfterHooks.before_parts(scope)
|
65
|
+
end
|
66
|
+
end
|
50
67
|
end
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
68
|
+
|
69
|
+
context 'when :all' do
|
70
|
+
|
71
|
+
it "should translate the :all parameter" do
|
72
|
+
[:todos, :de_todos].each do |scope|
|
73
|
+
BeforeAndAfterHooks.should_receive(:before_all_parts)
|
74
|
+
BeforeAndAfterHooks.before_parts(scope)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should not call the :each parameter" do
|
79
|
+
BeforeAndAfterHooks.should_not_receive(:before_each_parts)
|
80
|
+
[:todos, :de_todos].each do |scope|
|
81
|
+
BeforeAndAfterHooks.before_parts(scope)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should not call the :suite parameter" do
|
86
|
+
BeforeAndAfterHooks.should_not_receive(:before_suite_parts)
|
87
|
+
[:todos, :de_todos].each do |scope|
|
88
|
+
BeforeAndAfterHooks.before_parts(scope)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'when :suite' do
|
95
|
+
|
96
|
+
it "should translate the :suite parameter" do
|
97
|
+
[:suite, :da_suite].each do |scope|
|
98
|
+
BeforeAndAfterHooks.should_receive(:before_suite_parts)
|
99
|
+
BeforeAndAfterHooks.before_parts(scope)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should not call the :each parameter" do
|
104
|
+
BeforeAndAfterHooks.should_not_receive(:before_each_parts)
|
105
|
+
[:suite, :da_suite].each do |scope|
|
106
|
+
BeforeAndAfterHooks.before_parts(scope)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should not call the :all parameter" do
|
111
|
+
BeforeAndAfterHooks.should_not_receive(:before_all_parts)
|
112
|
+
[:suite, :da_suite].each do |scope|
|
113
|
+
BeforeAndAfterHooks.before_parts(scope)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
60
117
|
end
|
118
|
+
|
61
119
|
end
|
62
|
-
end
|
63
120
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
121
|
+
context "the after hook" do
|
122
|
+
|
123
|
+
context 'when :each' do
|
124
|
+
|
125
|
+
it "should translate the :each parameters and parse options" do
|
126
|
+
[:cada, :de_cada].each do |scope|
|
127
|
+
BeforeAndAfterHooks.should_receive(:after_each_parts)
|
128
|
+
BeforeAndAfterHooks.after_parts(scope)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should not call the :all parameters for :each hook" do
|
133
|
+
BeforeAndAfterHooks.should_not_receive(:after_all_parts)
|
134
|
+
[:cada, :de_cada].each do |scope|
|
135
|
+
BeforeAndAfterHooks.after_parts(scope)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should not call the :suite parameters for :suite hook" do
|
140
|
+
BeforeAndAfterHooks.should_not_receive(:after_suite_parts)
|
141
|
+
[:cada, :de_cada].each do |scope|
|
142
|
+
BeforeAndAfterHooks.after_parts(scope)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'when :all' do
|
148
|
+
|
149
|
+
it "should translate the :all parameter" do
|
150
|
+
[:todos, :de_todos].each do |scope|
|
151
|
+
BeforeAndAfterHooks.should_receive(:after_all_parts)
|
152
|
+
BeforeAndAfterHooks.after_parts(scope)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should not call the :each parameter" do
|
157
|
+
BeforeAndAfterHooks.should_not_receive(:after_each_parts)
|
158
|
+
[:todos, :de_todos].each do |scope|
|
159
|
+
BeforeAndAfterHooks.after_parts(scope)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should not call the :suite parameter" do
|
164
|
+
BeforeAndAfterHooks.should_not_receive(:after_suite_parts)
|
165
|
+
[:todos, :de_todos].each do |scope|
|
166
|
+
BeforeAndAfterHooks.after_parts(scope)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
72
170
|
end
|
171
|
+
|
172
|
+
context 'when :suite' do
|
173
|
+
|
174
|
+
it "should translate the :suite parameter" do
|
175
|
+
[:suite, :da_suite].each do |scope|
|
176
|
+
BeforeAndAfterHooks.should_receive(:after_suite_parts)
|
177
|
+
BeforeAndAfterHooks.after_parts(scope)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should not call the :each parameter" do
|
182
|
+
BeforeAndAfterHooks.should_not_receive(:after_each_parts)
|
183
|
+
[:suite, :da_suite].each do |scope|
|
184
|
+
BeforeAndAfterHooks.after_parts(scope)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should not call the :all parameter" do
|
189
|
+
BeforeAndAfterHooks.should_not_receive(:after_all_parts)
|
190
|
+
[:suite, :da_suite].each do |scope|
|
191
|
+
BeforeAndAfterHooks.after_parts(scope)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
|
73
197
|
end
|
198
|
+
|
74
199
|
end
|
75
200
|
|
76
201
|
context "grep the scope and call the hook" do
|
77
202
|
|
78
203
|
before(:each) do
|
79
|
-
@
|
80
|
-
@language = SpecI18n::Parser::NaturalLanguage.get(@pt)
|
81
|
-
@hooks = @language.hooks_params_keywords
|
204
|
+
@hooks = { 'each' => 'cada|de_cada', 'all' => 'todos|de_todos', 'suite' => 'suite|da_suite' }
|
82
205
|
end
|
83
206
|
|
84
207
|
it "should return the same scope if scope is in English" do
|
@@ -87,51 +210,50 @@ module Spec
|
|
87
210
|
end
|
88
211
|
end
|
89
212
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
213
|
+
context 'with String scope parameters' do
|
214
|
+
|
215
|
+
it "should grep the scope each in translated values" do
|
216
|
+
['cada', 'de_cada'].each do |scope|
|
217
|
+
grep_the_scope(scope, @hooks).should == :each
|
218
|
+
end
|
94
219
|
end
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
grep_the_scope(scope, @hooks).should == :all
|
220
|
+
|
221
|
+
it "should grep the scope all in translated values" do
|
222
|
+
['todos', 'de_todos'].each do |scope|
|
223
|
+
grep_the_scope(scope, @hooks).should == :all
|
224
|
+
end
|
101
225
|
end
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
grep_the_scope(scope, @hooks).should == :suite
|
226
|
+
|
227
|
+
it "should grep the scope suite in translated values" do
|
228
|
+
['suite', 'da_suite'].each do |scope|
|
229
|
+
grep_the_scope(scope, @hooks).should == :suite
|
230
|
+
end
|
108
231
|
end
|
232
|
+
|
109
233
|
end
|
110
234
|
|
111
|
-
context "with Symbol
|
235
|
+
context "with Symbol scope parameters" do
|
112
236
|
|
113
|
-
it "should grep the scope
|
114
|
-
|
115
|
-
|
116
|
-
grep_the_scope(scope, @hooks).should == :each
|
237
|
+
it "should grep the scope each in translated values" do
|
238
|
+
[:cada, :de_cada].each do |scope|
|
239
|
+
grep_the_scope(scope, @hooks).should == :each
|
117
240
|
end
|
118
241
|
end
|
119
242
|
|
120
|
-
it "should grep the scope
|
121
|
-
|
122
|
-
scopes.each do |scope|
|
243
|
+
it "should grep the scope all in translated values" do
|
244
|
+
[:todos, :de_todos].each do |scope|
|
123
245
|
grep_the_scope(scope, @hooks).should == :all
|
124
246
|
end
|
125
247
|
end
|
126
|
-
|
127
|
-
it "should grep the scope
|
128
|
-
|
129
|
-
|
130
|
-
grep_the_scope(scope, @hooks).should == :suite
|
248
|
+
|
249
|
+
it "should grep the scope suite in translated values" do
|
250
|
+
[:suite, :da_suite].each do |scope|
|
251
|
+
grep_the_scope(scope, @hooks).should == :suite
|
131
252
|
end
|
132
253
|
end
|
133
254
|
|
134
255
|
end
|
256
|
+
|
135
257
|
end
|
136
258
|
|
137
259
|
end
|
@@ -4,19 +4,37 @@ module Spec
|
|
4
4
|
module Example
|
5
5
|
describe ExampleGroupMethods do
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
context 'when it keywords' do
|
8
|
+
before(:each) do
|
9
|
+
@keywords = {"it" => "isto|especificar"}
|
10
|
+
stub_language!("pt", @keywords)
|
11
|
+
Spec::Example::ExampleGroupMethods.register_example_adverbs
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should include the example translated methods" do
|
15
|
+
example_group_methods = Spec::Example::ExampleGroup.methods.to_symbols
|
16
|
+
[:isto, :especificar].each do |example_method|
|
17
|
+
example_group_methods.should include(example_method)
|
18
|
+
end
|
19
|
+
end
|
9
20
|
end
|
10
21
|
|
11
|
-
it
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
22
|
+
context 'when it should behave like keywords' do
|
23
|
+
before(:each) do
|
24
|
+
@keywords = { 'it_should_behave_like' => 'deve_se_comportar_como|deve_se_comportar'}
|
25
|
+
stub_language!('pt', @keywords)
|
26
|
+
Spec::Example::ExampleGroupMethods.translate_it_should_behave_like
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should include the it should behave like method translated' do
|
30
|
+
example_group_methods = Spec::ExampleGroup.methods.to_symbols
|
31
|
+
[:deve_se_comportar_como, :deve_se_comportar].each do |translated_method|
|
32
|
+
example_group_methods.should include(translated_method)
|
17
33
|
end
|
18
34
|
end
|
35
|
+
|
19
36
|
end
|
37
|
+
|
20
38
|
end
|
21
39
|
end
|
22
40
|
end
|