transpec 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/CHANGELOG.md +4 -0
  4. data/lib/transpec/version.rb +1 -1
  5. data/transpec.gemspec +4 -3
  6. metadata +3 -97
  7. data/spec/.rubocop.yml +0 -23
  8. data/spec/integration/configuration_modification_spec.rb +0 -186
  9. data/spec/integration/conversion_spec.rb +0 -145
  10. data/spec/spec_helper.rb +0 -52
  11. data/spec/support/cache_helper.rb +0 -62
  12. data/spec/support/file_helper.rb +0 -25
  13. data/spec/support/shared_context.rb +0 -84
  14. data/spec/transpec/cli_spec.rb +0 -341
  15. data/spec/transpec/commit_message_spec.rb +0 -81
  16. data/spec/transpec/config_spec.rb +0 -99
  17. data/spec/transpec/converter_spec.rb +0 -1374
  18. data/spec/transpec/directory_cloner_spec.rb +0 -74
  19. data/spec/transpec/dynamic_analyzer/rewriter_spec.rb +0 -143
  20. data/spec/transpec/dynamic_analyzer_spec.rb +0 -329
  21. data/spec/transpec/git_spec.rb +0 -151
  22. data/spec/transpec/option_parser_spec.rb +0 -275
  23. data/spec/transpec/processed_source_spec.rb +0 -93
  24. data/spec/transpec/project_spec.rb +0 -194
  25. data/spec/transpec/record_spec.rb +0 -128
  26. data/spec/transpec/report_spec.rb +0 -126
  27. data/spec/transpec/rspec_version_spec.rb +0 -129
  28. data/spec/transpec/spec_file_finder_spec.rb +0 -118
  29. data/spec/transpec/spec_suite_spec.rb +0 -108
  30. data/spec/transpec/static_context_inspector_spec.rb +0 -713
  31. data/spec/transpec/syntax/allow_spec.rb +0 -122
  32. data/spec/transpec/syntax/be_boolean_spec.rb +0 -176
  33. data/spec/transpec/syntax/be_close_spec.rb +0 -51
  34. data/spec/transpec/syntax/current_example_spec.rb +0 -319
  35. data/spec/transpec/syntax/double_spec.rb +0 -175
  36. data/spec/transpec/syntax/example_group_spec.rb +0 -716
  37. data/spec/transpec/syntax/example_spec.rb +0 -301
  38. data/spec/transpec/syntax/expect_spec.rb +0 -313
  39. data/spec/transpec/syntax/have_spec.rb +0 -1276
  40. data/spec/transpec/syntax/hook_spec.rb +0 -215
  41. data/spec/transpec/syntax/its_spec.rb +0 -448
  42. data/spec/transpec/syntax/matcher_definition_spec.rb +0 -59
  43. data/spec/transpec/syntax/method_stub_spec.rb +0 -1301
  44. data/spec/transpec/syntax/oneliner_should_spec.rb +0 -628
  45. data/spec/transpec/syntax/operator_spec.rb +0 -871
  46. data/spec/transpec/syntax/pending_spec.rb +0 -415
  47. data/spec/transpec/syntax/raise_error_spec.rb +0 -354
  48. data/spec/transpec/syntax/receive_spec.rb +0 -499
  49. data/spec/transpec/syntax/rspec_configure_spec.rb +0 -870
  50. data/spec/transpec/syntax/should_receive_spec.rb +0 -1108
  51. data/spec/transpec/syntax/should_spec.rb +0 -497
  52. data/spec/transpec/util_spec.rb +0 -115
  53. data/spec/transpec_spec.rb +0 -22
@@ -1,499 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
- require 'transpec/syntax/receive'
5
- require 'transpec/syntax/expect'
6
- require 'transpec/syntax/allow'
7
-
8
- module Transpec
9
- class Syntax
10
- describe Receive do
11
- include_context 'parsed objects'
12
- include_context 'syntax object', Expect, :expect_object
13
- include_context 'syntax object', Allow, :allow_object
14
-
15
- let(:record) { receive_object.report.records.last }
16
-
17
- describe '#remove_useless_and_return!' do
18
- before do
19
- receive_object.remove_useless_and_return!
20
- end
21
-
22
- context 'with #expect' do
23
- let(:receive_object) { expect_object.receive_matcher }
24
-
25
- context 'with expression `expect(obj).to receive(:message).and_return { value }`' do
26
- let(:source) do
27
- <<-END
28
- describe 'example' do
29
- it 'receives #foo and returns 1' do
30
- expect(subject).to receive(:foo).and_return { 1 }
31
- end
32
- end
33
- END
34
- end
35
-
36
- let(:expected_source) do
37
- <<-END
38
- describe 'example' do
39
- it 'receives #foo and returns 1' do
40
- expect(subject).to receive(:foo) { 1 }
41
- end
42
- end
43
- END
44
- end
45
-
46
- it 'converts to `expect(obj).to receive(:message) { value }` form' do
47
- rewritten_source.should == expected_source
48
- end
49
-
50
- it 'adds record `expect(obj).to receive(:message).and_return { value }` ' \
51
- '-> `expect(obj).to receive(:message) { value }`' do
52
- record.old_syntax.should == 'expect(obj).to receive(:message).and_return { value }'
53
- record.new_syntax.should == 'expect(obj).to receive(:message) { value }'
54
- end
55
- end
56
-
57
- context 'with expression `expect(obj).to receive(:message).and_return do value end`' do
58
- let(:source) do
59
- <<-END
60
- describe 'example' do
61
- it 'receives #foo and returns 1' do
62
- expect(subject).to receive(:foo).and_return do
63
- 1
64
- end
65
- end
66
- end
67
- END
68
- end
69
-
70
- let(:expected_source) do
71
- <<-END
72
- describe 'example' do
73
- it 'receives #foo and returns 1' do
74
- expect(subject).to receive(:foo) do
75
- 1
76
- end
77
- end
78
- end
79
- END
80
- end
81
-
82
- it 'converts to `expect(obj).to receive(:message) do value end` form' do
83
- rewritten_source.should == expected_source
84
- end
85
-
86
- it 'adds record `expect(obj).to receive(:message).and_return` ' \
87
- '-> `expect(obj).to receive(:message)`' do
88
- record.old_syntax.should == 'expect(obj).to receive(:message).and_return'
89
- record.new_syntax.should == 'expect(obj).to receive(:message)'
90
- end
91
- end
92
-
93
- context 'with expression `expect_any_instance_of(Klass).to receive(:message).and_return { value }`' do
94
- let(:source) do
95
- <<-END
96
- describe 'example' do
97
- it 'receives #foo and returns 1' do
98
- expect_any_instance_of(Klass).to receive(:foo).and_return { 1 }
99
- end
100
- end
101
- END
102
- end
103
-
104
- let(:expected_source) do
105
- <<-END
106
- describe 'example' do
107
- it 'receives #foo and returns 1' do
108
- expect_any_instance_of(Klass).to receive(:foo) { 1 }
109
- end
110
- end
111
- END
112
- end
113
-
114
- it 'converts to `expect_any_instance_of(Klass).to receive(:message) { value }` form' do
115
- rewritten_source.should == expected_source
116
- end
117
-
118
- it 'adds record `expect(obj).to receive(:message).and_return` ' \
119
- '-> `expect(obj).to receive(:message)`' do
120
- record.old_syntax.should == 'expect(obj).to receive(:message).and_return { value }'
121
- record.new_syntax.should == 'expect(obj).to receive(:message) { value }'
122
- end
123
- end
124
-
125
- context 'with expression `expect(obj).to receive(:message).and_return`' do
126
- let(:source) do
127
- <<-END
128
- describe 'example' do
129
- it 'responds to #foo' do
130
- expect(subject).to receive(:foo).and_return
131
- end
132
- end
133
- END
134
- end
135
-
136
- let(:expected_source) do
137
- <<-END
138
- describe 'example' do
139
- it 'responds to #foo' do
140
- expect(subject).to receive(:foo)
141
- end
142
- end
143
- END
144
- end
145
-
146
- it 'converts to `expect(obj).to receive(:message)` form' do
147
- rewritten_source.should == expected_source
148
- end
149
-
150
- it 'adds record `expect(obj).to receive(:message).and_return` -> `expect(obj).to receive(:message)`' do
151
- record.old_syntax.should == 'expect(obj).to receive(:message).and_return'
152
- record.new_syntax.should == 'expect(obj).to receive(:message)'
153
- end
154
- end
155
-
156
- context 'with expression `expect(obj).to receive(:message).and_return(value)`' do
157
- let(:source) do
158
- <<-END
159
- describe 'example' do
160
- it 'responds to #foo and returns 1' do
161
- expect(obj).to receive(:message).and_return(1)
162
- end
163
- end
164
- END
165
- end
166
-
167
- it 'does nothing' do
168
- rewritten_source.should == source
169
- record.should be_nil
170
- end
171
- end
172
- end
173
-
174
- context 'with #allow' do
175
- let(:receive_object) { allow_object.receive_matcher }
176
-
177
- context 'with expression `allow(obj).to receive(:message).and_return { value }`' do
178
- let(:source) do
179
- <<-END
180
- describe 'example' do
181
- it 'responds to #foo and returns 1' do
182
- allow(subject).to receive(:foo).and_return { 1 }
183
- end
184
- end
185
- END
186
- end
187
-
188
- let(:expected_source) do
189
- <<-END
190
- describe 'example' do
191
- it 'responds to #foo and returns 1' do
192
- allow(subject).to receive(:foo) { 1 }
193
- end
194
- end
195
- END
196
- end
197
-
198
- it 'converts to `allow(obj).to receive(:message) { value }` form' do
199
- rewritten_source.should == expected_source
200
- end
201
-
202
- it 'adds record `allow(obj).to receive(:message).and_return { value }` ' \
203
- '-> `allow(obj).to receive(:message) { value }`' do
204
- record.old_syntax.should == 'allow(obj).to receive(:message).and_return { value }'
205
- record.new_syntax.should == 'allow(obj).to receive(:message) { value }'
206
- end
207
- end
208
- end
209
- end
210
-
211
- describe '#add_receiver_arg_to_any_instance_implementation_block!' do
212
- before do
213
- receive_object.add_receiver_arg_to_any_instance_implementation_block!
214
- end
215
-
216
- context 'with #expect' do
217
- let(:receive_object) { expect_object.receive_matcher }
218
-
219
- context 'with expression `expect_any_instance_of(Klass).to receive(:message) do |arg| .. end`' do
220
- let(:source) do
221
- <<-END
222
- describe 'example' do
223
- it 'receives #foo' do
224
- expect_any_instance_of(Klass).to receive(:foo) do |arg|
225
- end
226
- end
227
- end
228
- END
229
- end
230
-
231
- let(:expected_source) do
232
- <<-END
233
- describe 'example' do
234
- it 'receives #foo' do
235
- expect_any_instance_of(Klass).to receive(:foo) do |instance, arg|
236
- end
237
- end
238
- end
239
- END
240
- end
241
-
242
- it 'converts to `expect_any_instance_of(Klass).to receive(:message) do |instance, arg| .. end` form' do
243
- rewritten_source.should == expected_source
244
- end
245
-
246
- it 'adds record `expect_any_instance_of(Klass).to receive(:message) { |arg| }` ' \
247
- '-> `Klass.any_instance.should_receive(:message) { |instance, arg| }`' do
248
- record.old_syntax.should == 'expect_any_instance_of(Klass).to receive(:message) { |arg| }'
249
- record.new_syntax.should == 'expect_any_instance_of(Klass).to receive(:message) { |instance, arg| }'
250
- end
251
- end
252
-
253
- context 'with expression `expect_any_instance_of(Klass).to receive(:message).once do |arg| .. end`' do
254
- let(:source) do
255
- <<-END
256
- describe 'example' do
257
- it 'receives #foo' do
258
- expect_any_instance_of(Klass).to receive(:foo).once do |arg|
259
- end
260
- end
261
- end
262
- END
263
- end
264
-
265
- let(:expected_source) do
266
- <<-END
267
- describe 'example' do
268
- it 'receives #foo' do
269
- expect_any_instance_of(Klass).to receive(:foo).once do |instance, arg|
270
- end
271
- end
272
- end
273
- END
274
- end
275
-
276
- it 'converts to ' \
277
- '`expect_any_instance_of(Klass).to receive(:message).once do |instance, arg| .. end` form' do
278
- rewritten_source.should == expected_source
279
- end
280
-
281
- it 'adds record `expect_any_instance_of(Klass).to receive(:message) { |arg| }` ' \
282
- '-> `Klass.any_instance.should_receive(:message) { |instance, arg| }`' do
283
- record.old_syntax.should == 'expect_any_instance_of(Klass).to receive(:message) { |arg| }'
284
- record.new_syntax.should == 'expect_any_instance_of(Klass).to receive(:message) { |instance, arg| }'
285
- end
286
- end
287
-
288
- context 'with expression `expect_any_instance_of(Klass).to receive(:message) { |arg| .. }`' do
289
- let(:source) do
290
- <<-END
291
- describe 'example' do
292
- it 'receives #foo' do
293
- expect_any_instance_of(Klass).to receive(:foo) { |arg|
294
- }
295
- end
296
- end
297
- END
298
- end
299
-
300
- let(:expected_source) do
301
- <<-END
302
- describe 'example' do
303
- it 'receives #foo' do
304
- expect_any_instance_of(Klass).to receive(:foo) { |instance, arg|
305
- }
306
- end
307
- end
308
- END
309
- end
310
-
311
- it 'converts to `expect_any_instance_of(Klass).to receive(:message) { |instance, arg| .. }` form' do
312
- rewritten_source.should == expected_source
313
- end
314
-
315
- it 'adds record `expect_any_instance_of(Klass).to receive(:message) { |arg| }` ' \
316
- '-> `Klass.any_instance.should_receive(:message) { |instance, arg| }`' do
317
- record.old_syntax.should == 'expect_any_instance_of(Klass).to receive(:message) { |arg| }'
318
- record.new_syntax.should == 'expect_any_instance_of(Klass).to receive(:message) { |instance, arg| }'
319
- end
320
- end
321
-
322
- context 'with expression `expect_any_instance_of(Klass).to receive(:message) do .. end`' do
323
- let(:source) do
324
- <<-END
325
- describe 'example' do
326
- it 'receives #foo' do
327
- expect_any_instance_of(Klass).to receive(:foo) do
328
- end
329
- end
330
- end
331
- END
332
- end
333
-
334
- it 'does nothing' do
335
- rewritten_source.should == source
336
- end
337
- end
338
-
339
- context 'with expression `expect_any_instance_of(Klass).to receive(:message) do |instance| .. end`' do
340
- let(:source) do
341
- <<-END
342
- describe 'example' do
343
- it 'receives #foo' do
344
- expect_any_instance_of(Klass).to receive(:foo) do |instance|
345
- end
346
- end
347
- end
348
- END
349
- end
350
-
351
- it 'does nothing' do
352
- rewritten_source.should == source
353
- end
354
- end
355
-
356
- context 'with expression `expect(obj).to receive(:message) do |arg| .. end`' do
357
- let(:source) do
358
- <<-END
359
- describe 'example' do
360
- it 'receives #foo' do
361
- expect(subject).to receive(:foo) do |arg|
362
- end
363
- end
364
- end
365
- END
366
- end
367
-
368
- it 'does nothing' do
369
- rewritten_source.should == source
370
- end
371
- end
372
- end
373
-
374
- context 'with #allow' do
375
- let(:receive_object) { allow_object.receive_matcher }
376
-
377
- context 'with expression `allow_any_instance_of(Klass).to receive(:message) do |arg| .. end`' do
378
- let(:source) do
379
- <<-END
380
- describe 'example' do
381
- it 'responds to #foo' do
382
- allow_any_instance_of(Klass).to receive(:foo) do |arg|
383
- end
384
- end
385
- end
386
- END
387
- end
388
-
389
- let(:expected_source) do
390
- <<-END
391
- describe 'example' do
392
- it 'responds to #foo' do
393
- allow_any_instance_of(Klass).to receive(:foo) do |instance, arg|
394
- end
395
- end
396
- end
397
- END
398
- end
399
-
400
- it 'converts to `allow_any_instance_of(Klass).to receive(:message) do |instance, arg| .. end` form' do
401
- rewritten_source.should == expected_source
402
- end
403
-
404
- it 'adds record `allow_any_instance_of(Klass).to receive(:message) { |arg| }` ' \
405
- '-> `Klass.any_instance.should_receive(:message) { |instance, arg| }`' do
406
- record.old_syntax.should == 'allow_any_instance_of(Klass).to receive(:message) { |arg| }'
407
- record.new_syntax.should == 'allow_any_instance_of(Klass).to receive(:message) { |instance, arg| }'
408
- end
409
- end
410
-
411
- context 'with expression `allow_any_instance_of(Klass).to receive(:message) { |arg| .. }`' do
412
- let(:source) do
413
- <<-END
414
- describe 'example' do
415
- it 'responds to #foo' do
416
- allow_any_instance_of(Klass).to receive(:foo) { |arg|
417
- }
418
- end
419
- end
420
- END
421
- end
422
-
423
- let(:expected_source) do
424
- <<-END
425
- describe 'example' do
426
- it 'responds to #foo' do
427
- allow_any_instance_of(Klass).to receive(:foo) { |instance, arg|
428
- }
429
- end
430
- end
431
- END
432
- end
433
-
434
- it 'converts to `allow_any_instance_of(Klass).to receive(:message) { |instance, arg| .. }` form' do
435
- rewritten_source.should == expected_source
436
- end
437
-
438
- it 'adds record `allow_any_instance_of(Klass).to receive(:message) { |arg| }` ' \
439
- '-> `Klass.any_instance.should_receive(:message) { |instance, arg| }`' do
440
- record.old_syntax.should == 'allow_any_instance_of(Klass).to receive(:message) { |arg| }'
441
- record.new_syntax.should == 'allow_any_instance_of(Klass).to receive(:message) { |instance, arg| }'
442
- end
443
- end
444
-
445
- context 'with expression `allow_any_instance_of(Klass).to receive(:message) do .. end`' do
446
- let(:source) do
447
- <<-END
448
- describe 'example' do
449
- it 'responds to #foo' do
450
- allow_any_instance_of(Klass).to receive(:foo) do
451
- end
452
- end
453
- end
454
- END
455
- end
456
-
457
- it 'does nothing' do
458
- rewritten_source.should == source
459
- end
460
- end
461
-
462
- context 'with expression `allow_any_instance_of(Klass).to receive(:message) do |instance| .. end`' do
463
- let(:source) do
464
- <<-END
465
- describe 'example' do
466
- it 'responds to #foo' do
467
- allow_any_instance_of(Klass).to receive(:foo) do |instance|
468
- end
469
- end
470
- end
471
- END
472
- end
473
-
474
- it 'does nothing' do
475
- rewritten_source.should == source
476
- end
477
- end
478
-
479
- context 'with expression `allow(obj).to receive(:message) do |arg| .. end`' do
480
- let(:source) do
481
- <<-END
482
- describe 'example' do
483
- it 'responds to #foo' do
484
- allow(subject).to receive(:foo) do |arg|
485
- end
486
- end
487
- end
488
- END
489
- end
490
-
491
- it 'does nothing' do
492
- rewritten_source.should == source
493
- end
494
- end
495
- end
496
- end
497
- end
498
- end
499
- end