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,497 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'transpec/syntax/should'
|
5
|
-
|
6
|
-
module Transpec
|
7
|
-
class Syntax
|
8
|
-
describe Should do
|
9
|
-
include_context 'parsed objects'
|
10
|
-
include_context 'syntax object', Should, :should_object
|
11
|
-
|
12
|
-
let(:record) { should_object.report.records.first }
|
13
|
-
|
14
|
-
describe '#matcher_node' do
|
15
|
-
let(:matcher_name) { should_object.matcher_node.children[1] }
|
16
|
-
|
17
|
-
context 'when the matcher is operator' do
|
18
|
-
let(:source) do
|
19
|
-
<<-END
|
20
|
-
describe 'example' do
|
21
|
-
it 'is 1' do
|
22
|
-
subject.should == 1
|
23
|
-
end
|
24
|
-
end
|
25
|
-
END
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'returns the matcher node' do
|
29
|
-
matcher_name.should == :==
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'when the matcher is not operator' do
|
34
|
-
let(:source) do
|
35
|
-
<<-END
|
36
|
-
describe 'example' do
|
37
|
-
it 'is empty' do
|
38
|
-
subject.should be_empty
|
39
|
-
end
|
40
|
-
end
|
41
|
-
END
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'returns the matcher node' do
|
45
|
-
matcher_name.should == :be_empty
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context 'when the matcher is chained by another method' do
|
50
|
-
let(:source) do
|
51
|
-
<<-END
|
52
|
-
describe 'example' do
|
53
|
-
it 'has 2 items' do
|
54
|
-
subject.should have(2).items
|
55
|
-
end
|
56
|
-
end
|
57
|
-
END
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'returns the matcher node' do
|
61
|
-
matcher_name.should == :have
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
context 'when the matcher is chained by another method that is taking a block' do
|
66
|
-
let(:source) do
|
67
|
-
<<-END
|
68
|
-
describe 'example' do
|
69
|
-
it 'has 2 items' do
|
70
|
-
subject.should have(2).items { }
|
71
|
-
end
|
72
|
-
end
|
73
|
-
END
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'returns the first node of the chain' do
|
77
|
-
matcher_name.should == :have
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe '#operator_matcher' do
|
83
|
-
subject { should_object.operator_matcher }
|
84
|
-
|
85
|
-
let(:source) do
|
86
|
-
<<-END
|
87
|
-
describe 'example' do
|
88
|
-
it 'is 1' do
|
89
|
-
subject.should == 1
|
90
|
-
end
|
91
|
-
end
|
92
|
-
END
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'returns an instance of Operator' do
|
96
|
-
should be_an(Operator)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe '#have_matcher' do
|
101
|
-
subject { should_object.have_matcher }
|
102
|
-
|
103
|
-
let(:source) do
|
104
|
-
<<-END
|
105
|
-
describe 'example' do
|
106
|
-
it 'has 2 items' do
|
107
|
-
subject.should have(2).items
|
108
|
-
end
|
109
|
-
end
|
110
|
-
END
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'returns an instance of Have' do
|
114
|
-
should be_an(Have)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
describe '#raise_error_matcher' do
|
119
|
-
subject { should_object.raise_error_matcher }
|
120
|
-
|
121
|
-
let(:source) do
|
122
|
-
<<-END
|
123
|
-
describe 'example' do
|
124
|
-
it 'raises error' do
|
125
|
-
lambda { do_something }.should raise_error
|
126
|
-
end
|
127
|
-
end
|
128
|
-
END
|
129
|
-
end
|
130
|
-
|
131
|
-
it 'returns an instance of RaiseError' do
|
132
|
-
should be_an(RaiseError)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
describe '#dependent_syntaxes' do
|
137
|
-
let(:source) do
|
138
|
-
<<-END
|
139
|
-
describe 'example' do
|
140
|
-
it 'has 2 items' do
|
141
|
-
subject.should have(2).items
|
142
|
-
end
|
143
|
-
end
|
144
|
-
END
|
145
|
-
end
|
146
|
-
|
147
|
-
it 'returns an array containing #have_matcher, #operator_matcher, #raise_error_matcher' do
|
148
|
-
should_object.dependent_syntaxes.should =~ [
|
149
|
-
should_object.have_matcher,
|
150
|
-
should_object.operator_matcher,
|
151
|
-
should_object.raise_error_matcher
|
152
|
-
]
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
describe '#expectize!' do
|
157
|
-
context 'with expression `obj.should`' do
|
158
|
-
let(:source) do
|
159
|
-
<<-END
|
160
|
-
describe 'example' do
|
161
|
-
it 'is 1' do
|
162
|
-
subject.should eq(1)
|
163
|
-
end
|
164
|
-
end
|
165
|
-
END
|
166
|
-
end
|
167
|
-
|
168
|
-
let(:expected_source) do
|
169
|
-
<<-END
|
170
|
-
describe 'example' do
|
171
|
-
it 'is 1' do
|
172
|
-
expect(subject).to eq(1)
|
173
|
-
end
|
174
|
-
end
|
175
|
-
END
|
176
|
-
end
|
177
|
-
|
178
|
-
it 'converts to `expect(obj).to` form' do
|
179
|
-
should_object.expectize!
|
180
|
-
rewritten_source.should == expected_source
|
181
|
-
end
|
182
|
-
|
183
|
-
it 'adds record `obj.should` -> `expect(obj).to`' do
|
184
|
-
should_object.expectize!
|
185
|
-
record.old_syntax.should == 'obj.should'
|
186
|
-
record.new_syntax.should == 'expect(obj).to'
|
187
|
-
end
|
188
|
-
|
189
|
-
context 'and #expect is available in the context by including RSpec::Matchers' do
|
190
|
-
let(:source) do
|
191
|
-
<<-END
|
192
|
-
describe 'example' do
|
193
|
-
class TestRunner
|
194
|
-
include RSpec::Matchers
|
195
|
-
|
196
|
-
def run
|
197
|
-
1.should == 1
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
it 'is 1' do
|
202
|
-
TestRunner.new.run
|
203
|
-
end
|
204
|
-
end
|
205
|
-
END
|
206
|
-
end
|
207
|
-
|
208
|
-
context 'with runtime information' do
|
209
|
-
include_context 'dynamic analysis objects'
|
210
|
-
|
211
|
-
it 'does not raise ContextError' do
|
212
|
-
-> { should_object.expectize! }.should_not raise_error
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
context 'without runtime information' do
|
217
|
-
it 'raises ContextError' do
|
218
|
-
-> { should_object.expectize! }.should raise_error(ContextError)
|
219
|
-
end
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
context 'and #expect is not available in the context' do
|
224
|
-
context 'and the context is determinable statically' do
|
225
|
-
let(:source) do
|
226
|
-
<<-END
|
227
|
-
describe 'example' do
|
228
|
-
class TestRunner
|
229
|
-
def run
|
230
|
-
1.should == 1
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
it 'is 1' do
|
235
|
-
TestRunner.new.run
|
236
|
-
end
|
237
|
-
end
|
238
|
-
END
|
239
|
-
end
|
240
|
-
|
241
|
-
context 'with runtime information' do
|
242
|
-
include_context 'dynamic analysis objects'
|
243
|
-
|
244
|
-
it 'raises ContextError' do
|
245
|
-
-> { should_object.expectize! }.should raise_error(ContextError)
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
context 'without runtime information' do
|
250
|
-
it 'raises ContextError' do
|
251
|
-
-> { should_object.expectize! }.should raise_error(ContextError)
|
252
|
-
end
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
context 'and the context is not determinable statically' do
|
257
|
-
let(:source) do
|
258
|
-
<<-END
|
259
|
-
def my_eval(&block)
|
260
|
-
Object.new.instance_eval(&block)
|
261
|
-
end
|
262
|
-
|
263
|
-
describe 'example' do
|
264
|
-
it 'responds to #foo' do
|
265
|
-
my_eval { 1.should == 1 }
|
266
|
-
end
|
267
|
-
end
|
268
|
-
END
|
269
|
-
end
|
270
|
-
|
271
|
-
context 'with runtime information' do
|
272
|
-
include_context 'dynamic analysis objects'
|
273
|
-
|
274
|
-
it 'raises ContextError' do
|
275
|
-
-> { should_object.expectize! }.should raise_error(ContextError)
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
context 'without runtime information' do
|
280
|
-
it 'does not raise ContextError' do
|
281
|
-
-> { should_object.expectize! }.should_not raise_error
|
282
|
-
end
|
283
|
-
end
|
284
|
-
end
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
context 'with expression `obj.should_not`' do
|
289
|
-
let(:source) do
|
290
|
-
<<-END
|
291
|
-
describe 'example' do
|
292
|
-
it 'is not 1' do
|
293
|
-
subject.should_not eq(1)
|
294
|
-
end
|
295
|
-
end
|
296
|
-
END
|
297
|
-
end
|
298
|
-
|
299
|
-
let(:expected_source) do
|
300
|
-
<<-END
|
301
|
-
describe 'example' do
|
302
|
-
it 'is not 1' do
|
303
|
-
expect(subject).not_to eq(1)
|
304
|
-
end
|
305
|
-
end
|
306
|
-
END
|
307
|
-
end
|
308
|
-
|
309
|
-
it 'converts to `expect(obj).not_to` form' do
|
310
|
-
should_object.expectize!
|
311
|
-
rewritten_source.should == expected_source
|
312
|
-
end
|
313
|
-
|
314
|
-
it 'adds record `obj.should_not` -> `expect(obj).not_to`' do
|
315
|
-
should_object.expectize!
|
316
|
-
record.old_syntax.should == 'obj.should_not'
|
317
|
-
record.new_syntax.should == 'expect(obj).not_to'
|
318
|
-
end
|
319
|
-
|
320
|
-
context 'and "to_not" is passed as negative form' do
|
321
|
-
let(:expected_source) do
|
322
|
-
<<-END
|
323
|
-
describe 'example' do
|
324
|
-
it 'is not 1' do
|
325
|
-
expect(subject).to_not eq(1)
|
326
|
-
end
|
327
|
-
end
|
328
|
-
END
|
329
|
-
end
|
330
|
-
|
331
|
-
it 'converts to `expect(obj).to_not` form' do
|
332
|
-
should_object.expectize!('to_not')
|
333
|
-
rewritten_source.should == expected_source
|
334
|
-
end
|
335
|
-
|
336
|
-
it 'adds record `obj.should_not` -> `expect(obj).to_not`' do
|
337
|
-
should_object.expectize!('to_not')
|
338
|
-
record.old_syntax.should == 'obj.should_not'
|
339
|
-
record.new_syntax.should == 'expect(obj).to_not'
|
340
|
-
end
|
341
|
-
end
|
342
|
-
end
|
343
|
-
|
344
|
-
context 'with expression `(obj).should`' do
|
345
|
-
let(:source) do
|
346
|
-
<<-END
|
347
|
-
describe 'example' do
|
348
|
-
it 'is true' do
|
349
|
-
(1 == 1).should be_true
|
350
|
-
end
|
351
|
-
end
|
352
|
-
END
|
353
|
-
end
|
354
|
-
|
355
|
-
let(:expected_source) do
|
356
|
-
<<-END
|
357
|
-
describe 'example' do
|
358
|
-
it 'is true' do
|
359
|
-
expect(1 == 1).to be_true
|
360
|
-
end
|
361
|
-
end
|
362
|
-
END
|
363
|
-
end
|
364
|
-
|
365
|
-
it 'converts to `expect(obj).to` form without superfluous parentheses' do
|
366
|
-
should_object.expectize!
|
367
|
-
rewritten_source.should == expected_source
|
368
|
-
end
|
369
|
-
end
|
370
|
-
|
371
|
-
context 'with expression `obj.should() == 1`' do
|
372
|
-
let(:source) do
|
373
|
-
<<-END
|
374
|
-
describe 'example' do
|
375
|
-
it 'is 1' do
|
376
|
-
subject.should() == 1
|
377
|
-
end
|
378
|
-
end
|
379
|
-
END
|
380
|
-
end
|
381
|
-
|
382
|
-
let(:expected_source) do
|
383
|
-
<<-END
|
384
|
-
describe 'example' do
|
385
|
-
it 'is 1' do
|
386
|
-
expect(subject).to == 1
|
387
|
-
end
|
388
|
-
end
|
389
|
-
END
|
390
|
-
end
|
391
|
-
|
392
|
-
it 'converts to `expect(obj).to == 1` form' do
|
393
|
-
should_object.expectize!
|
394
|
-
rewritten_source.should == expected_source
|
395
|
-
end
|
396
|
-
end
|
397
|
-
|
398
|
-
[
|
399
|
-
'lambda', 'Kernel.lambda', '::Kernel.lambda',
|
400
|
-
'proc', 'Kernel.proc', '::Kernel.proc',
|
401
|
-
'Proc.new', '::Proc.new',
|
402
|
-
'->',
|
403
|
-
'expect'
|
404
|
-
].each do |method|
|
405
|
-
context "with expression `#{method} { ... }.should`" do
|
406
|
-
let(:source) do
|
407
|
-
<<-END
|
408
|
-
describe 'example' do
|
409
|
-
it 'raises error' do
|
410
|
-
#{method} { fail }.should raise_error
|
411
|
-
end
|
412
|
-
end
|
413
|
-
END
|
414
|
-
end
|
415
|
-
|
416
|
-
let(:expected_source) do
|
417
|
-
<<-END
|
418
|
-
describe 'example' do
|
419
|
-
it 'raises error' do
|
420
|
-
expect { fail }.to raise_error
|
421
|
-
end
|
422
|
-
end
|
423
|
-
END
|
424
|
-
end
|
425
|
-
|
426
|
-
it 'converts to `expect {...}.to` form' do
|
427
|
-
should_object.expectize!
|
428
|
-
rewritten_source.should == expected_source
|
429
|
-
end
|
430
|
-
|
431
|
-
it "adds record `#{method} { }.should` -> `expect { }.to`" do
|
432
|
-
should_object.expectize!
|
433
|
-
record.old_syntax.should == "#{method} { }.should"
|
434
|
-
record.new_syntax.should == 'expect { }.to'
|
435
|
-
end
|
436
|
-
end
|
437
|
-
end
|
438
|
-
|
439
|
-
['MyObject.lambda', 'MyObject.proc', 'MyObject.new'].each do |method|
|
440
|
-
context "with expression `#{method} { ... }.should`" do
|
441
|
-
let(:source) do
|
442
|
-
<<-END
|
443
|
-
describe 'example' do
|
444
|
-
it 'is 1' do
|
445
|
-
#{method} { fail }.should eq(1)
|
446
|
-
end
|
447
|
-
end
|
448
|
-
END
|
449
|
-
end
|
450
|
-
|
451
|
-
let(:expected_source) do
|
452
|
-
<<-END
|
453
|
-
describe 'example' do
|
454
|
-
it 'is 1' do
|
455
|
-
expect(#{method} { fail }).to eq(1)
|
456
|
-
end
|
457
|
-
end
|
458
|
-
END
|
459
|
-
end
|
460
|
-
|
461
|
-
it "converts to `expect(#{method} { ... }).to` form" do
|
462
|
-
should_object.expectize!
|
463
|
-
rewritten_source.should == expected_source
|
464
|
-
end
|
465
|
-
end
|
466
|
-
end
|
467
|
-
|
468
|
-
context 'with expression `method { ... }.should` but the subject object is not proc' do
|
469
|
-
let(:source) do
|
470
|
-
<<-END
|
471
|
-
describe 'example' do
|
472
|
-
it 'increments all elements' do
|
473
|
-
[1, 2].map { |i| i + 1 }.should eq([2, 3])
|
474
|
-
end
|
475
|
-
end
|
476
|
-
END
|
477
|
-
end
|
478
|
-
|
479
|
-
let(:expected_source) do
|
480
|
-
<<-END
|
481
|
-
describe 'example' do
|
482
|
-
it 'increments all elements' do
|
483
|
-
expect([1, 2].map { |i| i + 1 }).to eq([2, 3])
|
484
|
-
end
|
485
|
-
end
|
486
|
-
END
|
487
|
-
end
|
488
|
-
|
489
|
-
it 'converts to `expect(method { ... }).to` form' do
|
490
|
-
should_object.expectize!
|
491
|
-
rewritten_source.should == expected_source
|
492
|
-
end
|
493
|
-
end
|
494
|
-
end
|
495
|
-
end
|
496
|
-
end
|
497
|
-
end
|