transpec 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +4 -0
- data/lib/transpec/version.rb +1 -1
- data/transpec.gemspec +4 -3
- metadata +3 -97
- data/spec/.rubocop.yml +0 -23
- data/spec/integration/configuration_modification_spec.rb +0 -186
- data/spec/integration/conversion_spec.rb +0 -145
- data/spec/spec_helper.rb +0 -52
- data/spec/support/cache_helper.rb +0 -62
- data/spec/support/file_helper.rb +0 -25
- data/spec/support/shared_context.rb +0 -84
- data/spec/transpec/cli_spec.rb +0 -341
- data/spec/transpec/commit_message_spec.rb +0 -81
- data/spec/transpec/config_spec.rb +0 -99
- data/spec/transpec/converter_spec.rb +0 -1374
- data/spec/transpec/directory_cloner_spec.rb +0 -74
- data/spec/transpec/dynamic_analyzer/rewriter_spec.rb +0 -143
- data/spec/transpec/dynamic_analyzer_spec.rb +0 -329
- data/spec/transpec/git_spec.rb +0 -151
- data/spec/transpec/option_parser_spec.rb +0 -275
- data/spec/transpec/processed_source_spec.rb +0 -93
- data/spec/transpec/project_spec.rb +0 -194
- data/spec/transpec/record_spec.rb +0 -128
- data/spec/transpec/report_spec.rb +0 -126
- data/spec/transpec/rspec_version_spec.rb +0 -129
- data/spec/transpec/spec_file_finder_spec.rb +0 -118
- data/spec/transpec/spec_suite_spec.rb +0 -108
- data/spec/transpec/static_context_inspector_spec.rb +0 -713
- data/spec/transpec/syntax/allow_spec.rb +0 -122
- data/spec/transpec/syntax/be_boolean_spec.rb +0 -176
- data/spec/transpec/syntax/be_close_spec.rb +0 -51
- data/spec/transpec/syntax/current_example_spec.rb +0 -319
- data/spec/transpec/syntax/double_spec.rb +0 -175
- data/spec/transpec/syntax/example_group_spec.rb +0 -716
- data/spec/transpec/syntax/example_spec.rb +0 -301
- data/spec/transpec/syntax/expect_spec.rb +0 -313
- data/spec/transpec/syntax/have_spec.rb +0 -1276
- data/spec/transpec/syntax/hook_spec.rb +0 -215
- data/spec/transpec/syntax/its_spec.rb +0 -448
- data/spec/transpec/syntax/matcher_definition_spec.rb +0 -59
- data/spec/transpec/syntax/method_stub_spec.rb +0 -1301
- data/spec/transpec/syntax/oneliner_should_spec.rb +0 -628
- data/spec/transpec/syntax/operator_spec.rb +0 -871
- data/spec/transpec/syntax/pending_spec.rb +0 -415
- data/spec/transpec/syntax/raise_error_spec.rb +0 -354
- data/spec/transpec/syntax/receive_spec.rb +0 -499
- data/spec/transpec/syntax/rspec_configure_spec.rb +0 -870
- data/spec/transpec/syntax/should_receive_spec.rb +0 -1108
- data/spec/transpec/syntax/should_spec.rb +0 -497
- data/spec/transpec/util_spec.rb +0 -115
- data/spec/transpec_spec.rb +0 -22
@@ -1,215 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'transpec/syntax/hook'
|
5
|
-
|
6
|
-
module Transpec
|
7
|
-
class Syntax
|
8
|
-
describe Hook do
|
9
|
-
include_context 'parsed objects'
|
10
|
-
include_context 'syntax object', Hook, :hook_object
|
11
|
-
|
12
|
-
let(:record) { hook_object.report.records.last }
|
13
|
-
|
14
|
-
describe '#convert_scope_name!' do
|
15
|
-
before do
|
16
|
-
hook_object.convert_scope_name!
|
17
|
-
end
|
18
|
-
|
19
|
-
RSpecDSL::HOOK_METHODS.each do |hook_method|
|
20
|
-
context "with expression `#{hook_method}(:each) { }`" do
|
21
|
-
let(:source) do
|
22
|
-
<<-END
|
23
|
-
describe 'example' do
|
24
|
-
#{hook_method}(:each) do
|
25
|
-
do_something
|
26
|
-
end
|
27
|
-
end
|
28
|
-
END
|
29
|
-
end
|
30
|
-
|
31
|
-
let(:expected_source) do
|
32
|
-
<<-END
|
33
|
-
describe 'example' do
|
34
|
-
#{hook_method}(:example) do
|
35
|
-
do_something
|
36
|
-
end
|
37
|
-
end
|
38
|
-
END
|
39
|
-
end
|
40
|
-
|
41
|
-
it "converts to `#{hook_method}(:example) { }` form" do
|
42
|
-
rewritten_source.should == expected_source
|
43
|
-
end
|
44
|
-
|
45
|
-
it "adds record `#{hook_method}(:each) { }` -> `#{hook_method}(:example) { }`" do
|
46
|
-
record.old_syntax.should == "#{hook_method}(:each) { }"
|
47
|
-
record.new_syntax.should == "#{hook_method}(:example) { }"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
[:before, :after].each do |hook_method|
|
53
|
-
context "with expression `#{hook_method}(:all) { }`" do
|
54
|
-
let(:source) do
|
55
|
-
<<-END
|
56
|
-
describe 'example' do
|
57
|
-
#{hook_method}(:all) do
|
58
|
-
do_something
|
59
|
-
end
|
60
|
-
end
|
61
|
-
END
|
62
|
-
end
|
63
|
-
|
64
|
-
let(:expected_source) do
|
65
|
-
<<-END
|
66
|
-
describe 'example' do
|
67
|
-
#{hook_method}(:context) do
|
68
|
-
do_something
|
69
|
-
end
|
70
|
-
end
|
71
|
-
END
|
72
|
-
end
|
73
|
-
|
74
|
-
it "converts to `#{hook_method}(:context) { }` form" do
|
75
|
-
rewritten_source.should == expected_source
|
76
|
-
end
|
77
|
-
|
78
|
-
it "adds record `#{hook_method}(:all) { }` -> `#{hook_method}(:context) { }`" do
|
79
|
-
record.old_syntax.should == "#{hook_method}(:all) { }"
|
80
|
-
record.new_syntax.should == "#{hook_method}(:context) { }"
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
context "with expression `RSpec.configure { |c| c.#{hook_method}(:each) { } }`" do
|
85
|
-
let(:source) do
|
86
|
-
<<-END
|
87
|
-
RSpec.configure do |config|
|
88
|
-
config.#{hook_method}(:each) do
|
89
|
-
do_something
|
90
|
-
end
|
91
|
-
end
|
92
|
-
END
|
93
|
-
end
|
94
|
-
|
95
|
-
let(:expected_source) do
|
96
|
-
<<-END
|
97
|
-
RSpec.configure do |config|
|
98
|
-
config.#{hook_method}(:example) do
|
99
|
-
do_something
|
100
|
-
end
|
101
|
-
end
|
102
|
-
END
|
103
|
-
end
|
104
|
-
|
105
|
-
it "converts to `RSpec.configure { |c| c.#{hook_method}(:example) { } }` form" do
|
106
|
-
rewritten_source.should == expected_source
|
107
|
-
end
|
108
|
-
|
109
|
-
it "adds record `#{hook_method}(:each) { }` -> `#{hook_method}(:example) { }`" do
|
110
|
-
record.old_syntax.should == "#{hook_method}(:each) { }"
|
111
|
-
record.new_syntax.should == "#{hook_method}(:example) { }"
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
context "with expression `RSpec.configure { |c| c.#{hook_method}(:suite) { } }`" do
|
116
|
-
let(:source) do
|
117
|
-
<<-END
|
118
|
-
RSpec.configure do |config|
|
119
|
-
config.#{hook_method}(:suite) do
|
120
|
-
do_something
|
121
|
-
end
|
122
|
-
end
|
123
|
-
END
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'does nothing' do
|
127
|
-
rewritten_source.should == source
|
128
|
-
end
|
129
|
-
|
130
|
-
it 'does not add record' do
|
131
|
-
record.should be_nil
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
context 'with expression `before { }`' do
|
137
|
-
let(:source) do
|
138
|
-
<<-END
|
139
|
-
describe 'example' do
|
140
|
-
before do
|
141
|
-
do_something
|
142
|
-
end
|
143
|
-
end
|
144
|
-
END
|
145
|
-
end
|
146
|
-
|
147
|
-
it 'does nothing' do
|
148
|
-
rewritten_source.should == source
|
149
|
-
end
|
150
|
-
|
151
|
-
it 'does not add record' do
|
152
|
-
record.should be_nil
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
context 'with expression `before(variable) { }`' do
|
157
|
-
let(:source) do
|
158
|
-
<<-END
|
159
|
-
scope = :each
|
160
|
-
|
161
|
-
describe 'example' do
|
162
|
-
before(scope) do
|
163
|
-
do_something
|
164
|
-
end
|
165
|
-
end
|
166
|
-
END
|
167
|
-
end
|
168
|
-
|
169
|
-
it 'does nothing' do
|
170
|
-
rewritten_source.should == source
|
171
|
-
end
|
172
|
-
|
173
|
-
it 'does not add record' do
|
174
|
-
record.should be_nil
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
context 'with expression `before(:each, :type => :model) { }`' do
|
179
|
-
let(:source) do
|
180
|
-
<<-END
|
181
|
-
scope = :each
|
182
|
-
|
183
|
-
describe 'example' do
|
184
|
-
before(:each, :type => :model) do
|
185
|
-
do_something
|
186
|
-
end
|
187
|
-
end
|
188
|
-
END
|
189
|
-
end
|
190
|
-
|
191
|
-
let(:expected_source) do
|
192
|
-
<<-END
|
193
|
-
scope = :each
|
194
|
-
|
195
|
-
describe 'example' do
|
196
|
-
before(:example, :type => :model) do
|
197
|
-
do_something
|
198
|
-
end
|
199
|
-
end
|
200
|
-
END
|
201
|
-
end
|
202
|
-
|
203
|
-
it 'converts to `before(:example, :type => :model) { }` form' do
|
204
|
-
rewritten_source.should == expected_source
|
205
|
-
end
|
206
|
-
|
207
|
-
it 'adds record `before(:each) { }` -> `before(:example) { }`' do
|
208
|
-
record.old_syntax.should == 'before(:each) { }'
|
209
|
-
record.new_syntax.should == 'before(:example) { }'
|
210
|
-
end
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end
|
@@ -1,448 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'transpec/syntax/its'
|
5
|
-
|
6
|
-
module Transpec
|
7
|
-
class Syntax
|
8
|
-
describe Its do
|
9
|
-
include_context 'parsed objects'
|
10
|
-
include_context 'syntax object', Its, :its_object
|
11
|
-
|
12
|
-
let(:record) { its_object.report.records.last }
|
13
|
-
|
14
|
-
describe '#conversion_target?' do
|
15
|
-
let(:its_node) do
|
16
|
-
ast.each_node(:send).find do |send_node|
|
17
|
-
method_name = send_node.children[1]
|
18
|
-
method_name == :its
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
let(:its_object) do
|
23
|
-
Its.new(its_node, runtime_data)
|
24
|
-
end
|
25
|
-
|
26
|
-
subject { its_object.conversion_target? }
|
27
|
-
|
28
|
-
context 'when rspec-its is loaded in the spec' do
|
29
|
-
let(:source) do
|
30
|
-
<<-END
|
31
|
-
module RSpec
|
32
|
-
module Its
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe 'example' do
|
37
|
-
subject { ['foo'] }
|
38
|
-
|
39
|
-
its(:size) { should == 1 }
|
40
|
-
end
|
41
|
-
END
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'without runtime information' do
|
45
|
-
it { should be_true }
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'with runtime information' do
|
49
|
-
include_context 'dynamic analysis objects'
|
50
|
-
it { should be_false }
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe '#convert_to_describe_subject_it!' do
|
56
|
-
before do
|
57
|
-
its_object.convert_to_describe_subject_it!
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'with expression `its(:size) { ... }`' do
|
61
|
-
let(:source) do
|
62
|
-
<<-END
|
63
|
-
describe 'example' do
|
64
|
-
subject { ['foo'] }
|
65
|
-
|
66
|
-
its(:size) { should == 1 }
|
67
|
-
end
|
68
|
-
END
|
69
|
-
end
|
70
|
-
|
71
|
-
let(:expected_source) do
|
72
|
-
<<-END
|
73
|
-
describe 'example' do
|
74
|
-
subject { ['foo'] }
|
75
|
-
|
76
|
-
describe '#size' do
|
77
|
-
subject { super().size }
|
78
|
-
it { should == 1 }
|
79
|
-
end
|
80
|
-
end
|
81
|
-
END
|
82
|
-
end
|
83
|
-
|
84
|
-
it "converts to `describe '#size' do subject { super().size }; it { ... } end` form" do
|
85
|
-
rewritten_source.should == expected_source
|
86
|
-
end
|
87
|
-
|
88
|
-
it "adds record `its(:attr) { }` -> `describe '#attr' do subject { super().attr }; it { } end`" do
|
89
|
-
record.old_syntax.should == 'its(:attr) { }'
|
90
|
-
record.new_syntax.should == "describe '#attr' do subject { super().attr }; it { } end"
|
91
|
-
end
|
92
|
-
|
93
|
-
context 'and there are consecutive blanks between the #its and the block' do
|
94
|
-
let(:source) do
|
95
|
-
<<-END
|
96
|
-
describe 'example' do
|
97
|
-
subject { ['foo'] }
|
98
|
-
its(:size) { should == 1 }
|
99
|
-
end
|
100
|
-
END
|
101
|
-
end
|
102
|
-
|
103
|
-
let(:expected_source) do
|
104
|
-
<<-END
|
105
|
-
describe 'example' do
|
106
|
-
subject { ['foo'] }
|
107
|
-
|
108
|
-
describe '#size' do
|
109
|
-
subject { super().size }
|
110
|
-
it { should == 1 }
|
111
|
-
end
|
112
|
-
end
|
113
|
-
END
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'removes the redundant blanks' do
|
117
|
-
rewritten_source.should == expected_source
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
context 'and there is no blank line before #its' do
|
122
|
-
context 'and the indentation level of the previous line is same as the target line' do
|
123
|
-
let(:source) do
|
124
|
-
<<-END
|
125
|
-
describe 'example' do
|
126
|
-
subject { ['foo'] }
|
127
|
-
its(:size) { should == 1 }
|
128
|
-
end
|
129
|
-
END
|
130
|
-
end
|
131
|
-
|
132
|
-
let(:expected_source) do
|
133
|
-
<<-END
|
134
|
-
describe 'example' do
|
135
|
-
subject { ['foo'] }
|
136
|
-
|
137
|
-
describe '#size' do
|
138
|
-
subject { super().size }
|
139
|
-
it { should == 1 }
|
140
|
-
end
|
141
|
-
end
|
142
|
-
END
|
143
|
-
end
|
144
|
-
|
145
|
-
it 'inserts a blank line before #its' do
|
146
|
-
rewritten_source.should == expected_source
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
context 'and the indentation level of the previous line is lower than the target line' do
|
151
|
-
let(:source) do
|
152
|
-
<<-END
|
153
|
-
describe 'example' do
|
154
|
-
subject { ['foo'] }
|
155
|
-
|
156
|
-
context 'in some case' do
|
157
|
-
its(:size) { should == 1 }
|
158
|
-
end
|
159
|
-
end
|
160
|
-
END
|
161
|
-
end
|
162
|
-
|
163
|
-
let(:expected_source) do
|
164
|
-
<<-END
|
165
|
-
describe 'example' do
|
166
|
-
subject { ['foo'] }
|
167
|
-
|
168
|
-
context 'in some case' do
|
169
|
-
describe '#size' do
|
170
|
-
subject { super().size }
|
171
|
-
it { should == 1 }
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
END
|
176
|
-
end
|
177
|
-
|
178
|
-
it 'does not insert blank line before #its' do
|
179
|
-
rewritten_source.should == expected_source
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
context "with expression `its('size') { ... }`" do
|
186
|
-
let(:source) do
|
187
|
-
<<-END
|
188
|
-
describe 'example' do
|
189
|
-
subject { ['foo'] }
|
190
|
-
|
191
|
-
its('size') { should == 1 }
|
192
|
-
end
|
193
|
-
END
|
194
|
-
end
|
195
|
-
|
196
|
-
let(:expected_source) do
|
197
|
-
<<-END
|
198
|
-
describe 'example' do
|
199
|
-
subject { ['foo'] }
|
200
|
-
|
201
|
-
describe '#size' do
|
202
|
-
subject { super().size }
|
203
|
-
it { should == 1 }
|
204
|
-
end
|
205
|
-
end
|
206
|
-
END
|
207
|
-
end
|
208
|
-
|
209
|
-
it "converts to `describe '#size' do subject { super().size }; it { ... } end` form" do
|
210
|
-
rewritten_source.should == expected_source
|
211
|
-
end
|
212
|
-
|
213
|
-
it "adds record `its(:attr) { }` -> `describe '#attr' do subject { super().attr }; it { } end`" do
|
214
|
-
record.old_syntax.should == 'its(:attr) { }'
|
215
|
-
record.new_syntax.should == "describe '#attr' do subject { super().attr }; it { } end"
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
context "with expression `its('size.odd?') { ... }`" do
|
220
|
-
let(:source) do
|
221
|
-
<<-END
|
222
|
-
describe 'example' do
|
223
|
-
subject { ['foo'] }
|
224
|
-
|
225
|
-
its('size.odd?') { should be_true }
|
226
|
-
end
|
227
|
-
END
|
228
|
-
end
|
229
|
-
|
230
|
-
let(:expected_source) do
|
231
|
-
<<-END
|
232
|
-
describe 'example' do
|
233
|
-
subject { ['foo'] }
|
234
|
-
|
235
|
-
describe '#size' do
|
236
|
-
subject { super().size }
|
237
|
-
describe '#odd?' do
|
238
|
-
subject { super().odd? }
|
239
|
-
it { should be_true }
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|
243
|
-
END
|
244
|
-
end
|
245
|
-
|
246
|
-
it 'converts to nested #describe' do
|
247
|
-
rewritten_source.should == expected_source
|
248
|
-
end
|
249
|
-
|
250
|
-
it "adds record `its(:attr) { }` -> `describe '#attr' do subject { super().attr }; it { } end`" do
|
251
|
-
record.old_syntax.should == 'its(:attr) { }'
|
252
|
-
record.new_syntax.should == "describe '#attr' do subject { super().attr }; it { } end"
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
context 'with expression `its([:foo]) { ... }`' do
|
257
|
-
let(:source) do
|
258
|
-
<<-END
|
259
|
-
describe 'example' do
|
260
|
-
subject { { foo: 'bar' } }
|
261
|
-
|
262
|
-
its([:foo]) { should == 'bar' }
|
263
|
-
end
|
264
|
-
END
|
265
|
-
end
|
266
|
-
|
267
|
-
let(:expected_source) do
|
268
|
-
<<-END
|
269
|
-
describe 'example' do
|
270
|
-
subject { { foo: 'bar' } }
|
271
|
-
|
272
|
-
describe '[:foo]' do
|
273
|
-
subject { super()[:foo] }
|
274
|
-
it { should == 'bar' }
|
275
|
-
end
|
276
|
-
end
|
277
|
-
END
|
278
|
-
end
|
279
|
-
|
280
|
-
it "converts to `describe '[:foo]' do subject { super()[:foo] }; it { ... } end` form" do
|
281
|
-
rewritten_source.should == expected_source
|
282
|
-
end
|
283
|
-
|
284
|
-
it "adds record `its([:key]) { }` -> `describe '[:key]' do subject { super()[:key] }; it { } end`" do
|
285
|
-
record.old_syntax.should == 'its([:key]) { }'
|
286
|
-
record.new_syntax.should == "describe '[:key]' do subject { super()[:key] }; it { } end"
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
context "with expression `its(['foo']) { ... }`" do
|
291
|
-
let(:source) do
|
292
|
-
<<-END
|
293
|
-
describe 'example' do
|
294
|
-
subject { { 'foo' => 'bar' } }
|
295
|
-
|
296
|
-
its(['foo']) { should == 'bar' }
|
297
|
-
end
|
298
|
-
END
|
299
|
-
end
|
300
|
-
|
301
|
-
let(:expected_source) do
|
302
|
-
<<-END
|
303
|
-
describe 'example' do
|
304
|
-
subject { { 'foo' => 'bar' } }
|
305
|
-
|
306
|
-
describe "['foo']" do
|
307
|
-
subject { super()['foo'] }
|
308
|
-
it { should == 'bar' }
|
309
|
-
end
|
310
|
-
end
|
311
|
-
END
|
312
|
-
end
|
313
|
-
|
314
|
-
it "converts to `describe \"['foo']\" do subject { super()['foo'] }; it { ... } end` form" do
|
315
|
-
rewritten_source.should == expected_source
|
316
|
-
end
|
317
|
-
|
318
|
-
it "adds record `its([:key]) { }` -> `describe '[:key]' do subject { super()[:key] }; it { } end`" do
|
319
|
-
record.old_syntax.should == 'its([:key]) { }'
|
320
|
-
record.new_syntax.should == "describe '[:key]' do subject { super()[:key] }; it { } end"
|
321
|
-
end
|
322
|
-
end
|
323
|
-
|
324
|
-
context 'with expression `its([3, 2]) { ... }`' do
|
325
|
-
let(:source) do
|
326
|
-
<<-END
|
327
|
-
describe 'example' do
|
328
|
-
subject { %w(a b c d r f g) }
|
329
|
-
|
330
|
-
its([3, 2]) { should == %w(d r) }
|
331
|
-
end
|
332
|
-
END
|
333
|
-
end
|
334
|
-
|
335
|
-
let(:expected_source) do
|
336
|
-
<<-END
|
337
|
-
describe 'example' do
|
338
|
-
subject { %w(a b c d r f g) }
|
339
|
-
|
340
|
-
describe '[3, 2]' do
|
341
|
-
subject { super()[3, 2] }
|
342
|
-
it { should == %w(d r) }
|
343
|
-
end
|
344
|
-
end
|
345
|
-
END
|
346
|
-
end
|
347
|
-
|
348
|
-
it "converts to `describe '[3, 2]' do subject { super()[3, 2] }; it { ... } end` form" do
|
349
|
-
rewritten_source.should == expected_source
|
350
|
-
end
|
351
|
-
|
352
|
-
it "adds record `its([:key]) { }` -> `describe '[:key]' do subject { super()[:key] }; it { } end`" do
|
353
|
-
record.old_syntax.should == 'its([:key]) { }'
|
354
|
-
record.new_syntax.should == "describe '[:key]' do subject { super()[:key] }; it { } end"
|
355
|
-
end
|
356
|
-
end
|
357
|
-
|
358
|
-
context 'with expression `its(attribute) { ... }`' do
|
359
|
-
let(:source) do
|
360
|
-
<<-END
|
361
|
-
describe 'example' do
|
362
|
-
subject { 'foo' }
|
363
|
-
|
364
|
-
[
|
365
|
-
[:size, 3],
|
366
|
-
[:upcase, 'FOO']
|
367
|
-
].each do |attribute, expected_value|
|
368
|
-
its(attribute) { should == expected_value }
|
369
|
-
end
|
370
|
-
end
|
371
|
-
END
|
372
|
-
end
|
373
|
-
|
374
|
-
let(:expected_source) do
|
375
|
-
<<-END
|
376
|
-
describe 'example' do
|
377
|
-
subject { 'foo' }
|
378
|
-
|
379
|
-
[
|
380
|
-
[:size, 3],
|
381
|
-
[:upcase, 'FOO']
|
382
|
-
].each do |attribute, expected_value|
|
383
|
-
describe attribute do
|
384
|
-
subject { super().send(attribute) }
|
385
|
-
it { should == expected_value }
|
386
|
-
end
|
387
|
-
end
|
388
|
-
end
|
389
|
-
END
|
390
|
-
end
|
391
|
-
|
392
|
-
it 'converts to `describe attribute do subject { super().send(attribute) }; it { ... } end` form' do
|
393
|
-
rewritten_source.should == expected_source
|
394
|
-
end
|
395
|
-
|
396
|
-
it "adds record `its(:attr) { }` -> `describe '#attr' do subject { super().attr }; it { } end`" do
|
397
|
-
record.old_syntax.should == 'its(:attr) { }'
|
398
|
-
record.new_syntax.should == "describe '#attr' do subject { super().attr }; it { } end"
|
399
|
-
end
|
400
|
-
end
|
401
|
-
|
402
|
-
context 'with expression `its([1, length]) { ... }`' do
|
403
|
-
let(:source) do
|
404
|
-
<<-END
|
405
|
-
describe 'example' do
|
406
|
-
subject { 'foobar' }
|
407
|
-
|
408
|
-
[
|
409
|
-
[2, 'oo'],
|
410
|
-
[3, 'oob']
|
411
|
-
].each do |length, expected_value|
|
412
|
-
its([1, length]) { should == expected_value }
|
413
|
-
end
|
414
|
-
end
|
415
|
-
END
|
416
|
-
end
|
417
|
-
|
418
|
-
let(:expected_source) do
|
419
|
-
<<-END
|
420
|
-
describe 'example' do
|
421
|
-
subject { 'foobar' }
|
422
|
-
|
423
|
-
[
|
424
|
-
[2, 'oo'],
|
425
|
-
[3, 'oob']
|
426
|
-
].each do |length, expected_value|
|
427
|
-
describe [1, length] do
|
428
|
-
subject { super()[1, length] }
|
429
|
-
it { should == expected_value }
|
430
|
-
end
|
431
|
-
end
|
432
|
-
end
|
433
|
-
END
|
434
|
-
end
|
435
|
-
|
436
|
-
it 'converts to `describe [1, length] do subject { super()[1, length] }; it { ... } end` form' do
|
437
|
-
rewritten_source.should == expected_source
|
438
|
-
end
|
439
|
-
|
440
|
-
it "adds record `its([:key]) { }` -> `describe '[:key]' do subject { super()[:key] }; it { } end`" do
|
441
|
-
record.old_syntax.should == 'its([:key]) { }'
|
442
|
-
record.new_syntax.should == "describe '[:key]' do subject { super()[:key] }; it { } end"
|
443
|
-
end
|
444
|
-
end
|
445
|
-
end
|
446
|
-
end
|
447
|
-
end
|
448
|
-
end
|