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,628 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
- require 'transpec/syntax/oneliner_should'
5
-
6
- module Transpec
7
- class Syntax
8
- describe OnelinerShould do
9
- include_context 'parsed objects'
10
- include_context 'syntax object', OnelinerShould, :should_object
11
-
12
- let(:record) { should_object.report.records.first }
13
-
14
- describe '#conversion_target?' do
15
- let(:target_node) do
16
- ast.each_node(:send).find do |send_node|
17
- method_name = send_node.children[1]
18
- method_name == :should
19
- end
20
- end
21
-
22
- let(:should_object) do
23
- OnelinerShould.new(target_node, runtime_data)
24
- end
25
-
26
- subject { should_object.conversion_target? }
27
-
28
- context 'when one-liner #should node is passed' do
29
- let(:source) do
30
- <<-END
31
- describe 'example' do
32
- subject { 1 }
33
- it { should == 1 }
34
- end
35
- END
36
- end
37
-
38
- it { should be_true }
39
-
40
- context 'with runtime information' do
41
- include_context 'dynamic analysis objects'
42
- it { should be_true }
43
- end
44
- end
45
-
46
- context 'when monkey-patched #should node is passed' do
47
- let(:source) do
48
- <<-END
49
- describe 'example' do
50
- subject { 1 }
51
- it 'is 1' do
52
- subject.should == 1
53
- end
54
- end
55
- END
56
- end
57
-
58
- it { should be_false }
59
- end
60
- end
61
-
62
- describe '#matcher_node' do
63
- context 'when it is taking operator matcher' do
64
- let(:source) do
65
- <<-END
66
- describe 'example' do
67
- it { should == 1 }
68
- end
69
- END
70
- end
71
-
72
- it 'returns its parent node' do
73
- should_object.parent_node.children[1].should == :==
74
- should_object.matcher_node.should == should_object.parent_node
75
- end
76
- end
77
-
78
- context 'when it is taking non-operator matcher without argument' do
79
- let(:source) do
80
- <<-END
81
- describe 'example' do
82
- it { should be_empty }
83
- end
84
- END
85
- end
86
-
87
- it 'returns its argument node' do
88
- should_object.arg_node.children[1].should == :be_empty
89
- should_object.matcher_node.should == should_object.arg_node
90
- end
91
- end
92
-
93
- context 'when it is taking non-operator matcher with argument' do
94
- let(:source) do
95
- <<-END
96
- describe 'example' do
97
- it { should eq(1) }
98
- end
99
- END
100
- end
101
-
102
- it 'returns its argument node' do
103
- should_object.arg_node.children[1].should == :eq
104
- should_object.matcher_node.should == should_object.arg_node
105
- end
106
- end
107
- end
108
-
109
- describe '#operator_matcher' do
110
- subject { should_object.operator_matcher }
111
-
112
- let(:source) do
113
- <<-END
114
- describe 'example' do
115
- it { should == 1 }
116
- end
117
- END
118
- end
119
-
120
- it 'returns an instance of Operator' do
121
- should be_an(Operator)
122
- end
123
- end
124
-
125
- describe '#have_matcher' do
126
- subject { should_object.have_matcher }
127
-
128
- let(:source) do
129
- <<-END
130
- describe 'example' do
131
- it { should have(2).items }
132
- end
133
- END
134
- end
135
-
136
- it 'returns an instance of Have' do
137
- should be_an(Have)
138
- end
139
- end
140
-
141
- describe '#expectize!' do
142
- context 'with expression `it { should be true }`' do
143
- let(:source) do
144
- <<-END
145
- describe 'example' do
146
- it { should be true }
147
- end
148
- END
149
- end
150
-
151
- let(:expected_source) do
152
- <<-END
153
- describe 'example' do
154
- it { is_expected.to be true }
155
- end
156
- END
157
- end
158
-
159
- it 'converts to `it { is_expected.to be true }` form' do
160
- should_object.expectize!
161
- rewritten_source.should == expected_source
162
- end
163
-
164
- it 'adds record `it { should ... }` -> `it { is_expected.to ... }`' do
165
- should_object.expectize!
166
- record.old_syntax.should == 'it { should ... }'
167
- record.new_syntax.should == 'it { is_expected.to ... }'
168
- end
169
- end
170
-
171
- context 'with expression `it { should() == 1 }`' do
172
- let(:source) do
173
- <<-END
174
- describe 'example' do
175
- it { should() == 1 }
176
- end
177
- END
178
- end
179
-
180
- let(:expected_source) do
181
- <<-END
182
- describe 'example' do
183
- it { is_expected.to == 1 }
184
- end
185
- END
186
- end
187
-
188
- it 'converts to `it { is_expected.to == 1 }` form' do
189
- should_object.expectize!
190
- rewritten_source.should == expected_source
191
- end
192
- end
193
- end
194
-
195
- describe '#convert_have_items_to_standard_should! and Have#convert_to_standard_expectation!' do
196
- before do
197
- should_object.convert_have_items_to_standard_should!
198
- should_object.have_matcher.convert_to_standard_expectation!
199
- end
200
-
201
- context 'with expression `it { should have(2).items }`' do
202
- let(:source) do
203
- <<-END
204
- describe 'example' do
205
- it { should have(2).items }
206
- end
207
- END
208
- end
209
-
210
- let(:expected_source) do
211
- <<-END
212
- describe 'example' do
213
- it 'has 2 items' do
214
- subject.size.should == 2
215
- end
216
- end
217
- END
218
- end
219
-
220
- it "converts to `it 'has 2 items' do subject.size.should == 2 end` form" do
221
- rewritten_source.should == expected_source
222
- end
223
-
224
- it 'adds record ' \
225
- '`it { should have(n).items }` -> `it \'has n items\' do subject.size.should == n end`' do
226
- record.old_syntax.should == 'it { should have(n).items }'
227
- record.new_syntax.should == "it 'has n items' do subject.size.should == n end"
228
- end
229
- end
230
-
231
- context 'with expression `it { should_not have(2).items }`' do
232
- let(:source) do
233
- <<-END
234
- describe 'example' do
235
- it { should_not have(2).items }
236
- end
237
- END
238
- end
239
-
240
- let(:expected_source) do
241
- <<-END
242
- describe 'example' do
243
- it 'does not have 2 items' do
244
- subject.size.should_not == 2
245
- end
246
- end
247
- END
248
- end
249
-
250
- it "converts to `it 'does not have 2 items' do subject.size.should_not == 2 end` form" do
251
- rewritten_source.should == expected_source
252
- end
253
-
254
- it 'adds record `it { should_not have(n).items }`' \
255
- ' -> `it \'does not have n items\' do subject.size.should_not == n end`' do
256
- record.old_syntax.should == 'it { should_not have(n).items }'
257
- record.new_syntax.should == "it 'does not have n items' do subject.size.should_not == n end"
258
- end
259
- end
260
-
261
- context 'with expression `it { should have(1).items }`' do
262
- let(:source) do
263
- <<-END
264
- describe 'example' do
265
- it { should have(1).items }
266
- end
267
- END
268
- end
269
-
270
- let(:expected_source) do
271
- <<-END
272
- describe 'example' do
273
- it 'has 1 item' do
274
- subject.size.should == 1
275
- end
276
- end
277
- END
278
- end
279
-
280
- it "converts to `it 'has 1 item' do subject.size.should == 1 end` form" do
281
- rewritten_source.should == expected_source
282
- end
283
-
284
- it 'adds record ' \
285
- '`it { should have(n).items }` -> `it \'has n items\' do subject.size.should == n end`' do
286
- record.old_syntax.should == 'it { should have(n).items }'
287
- record.new_syntax.should == "it 'has n items' do subject.size.should == n end"
288
- end
289
- end
290
-
291
- context 'with expression `it { should have(0).items }`' do
292
- let(:source) do
293
- <<-END
294
- describe 'example' do
295
- it { should have(0).items }
296
- end
297
- END
298
- end
299
-
300
- let(:expected_source) do
301
- <<-END
302
- describe 'example' do
303
- it 'has no items' do
304
- subject.size.should == 0
305
- end
306
- end
307
- END
308
- end
309
-
310
- it "converts to `it 'has no items' do subject.size.should == 0 end` form" do
311
- rewritten_source.should == expected_source
312
- end
313
-
314
- it 'adds record ' \
315
- '`it { should have(n).items }` -> `it \'has n items\' do subject.size.should == n end`' do
316
- record.old_syntax.should == 'it { should have(n).items }'
317
- record.new_syntax.should == "it 'has n items' do subject.size.should == n end"
318
- end
319
- end
320
-
321
- context 'with expression `it { should have(variable).items }`' do
322
- let(:source) do
323
- <<-END
324
- describe 'example' do
325
- it { should have(number_of).items }
326
- end
327
- END
328
- end
329
-
330
- let(:expected_source) do
331
- <<-END
332
- describe 'example' do
333
- it 'has number_of items' do
334
- subject.size.should == number_of
335
- end
336
- end
337
- END
338
- end
339
-
340
- it "converts to `it 'has variable items' do subject.size.should == variable end` form" do
341
- rewritten_source.should == expected_source
342
- end
343
-
344
- it 'adds record ' \
345
- '`it { should have(n).items }` -> `it \'has n items\' do subject.size.should == n end`' do
346
- record.old_syntax.should == 'it { should have(n).items }'
347
- record.new_syntax.should == "it 'has n items' do subject.size.should == n end"
348
- end
349
- end
350
-
351
- context 'with expression `it { should_not have(0).items }`' do
352
- let(:source) do
353
- <<-END
354
- describe 'example' do
355
- it { should_not have(0).items }
356
- end
357
- END
358
- end
359
-
360
- let(:expected_source) do
361
- <<-END
362
- describe 'example' do
363
- it 'does not have 0 items' do
364
- subject.size.should_not == 0
365
- end
366
- end
367
- END
368
- end
369
-
370
- it "converts to `it 'does not have 0 items' do subject.size.should_not == 0 end` form" do
371
- rewritten_source.should == expected_source
372
- end
373
-
374
- it 'adds record `it { should_not have(n).items }`' \
375
- ' -> `it \'does not have n items\' do subject.size.should_not == n end`' do
376
- record.old_syntax.should == 'it { should_not have(n).items }'
377
- record.new_syntax.should == "it 'does not have n items' do subject.size.should_not == n end"
378
- end
379
- end
380
-
381
- context 'with expression multiline `it { should have(2).items }`' do
382
- let(:source) do
383
- <<-END
384
- describe 'example' do
385
- it {
386
- should have(2).items
387
- }
388
- end
389
- END
390
- end
391
-
392
- let(:expected_source) do
393
- <<-END
394
- describe 'example' do
395
- it 'has 2 items' {
396
- subject.size.should == 2
397
- }
398
- end
399
- END
400
- end
401
-
402
- it "converts to `it 'has 2 items' { subject.size.should == 2 }` form" do
403
- rewritten_source.should == expected_source
404
- end
405
-
406
- it 'adds record ' \
407
- '`it { should have(n).items }` -> `it \'has n items\' do subject.size.should == n end`' do
408
- record.old_syntax.should == 'it { should have(n).items }'
409
- record.new_syntax.should == "it 'has n items' do subject.size.should == n end"
410
- end
411
- end
412
-
413
- context "with expression `it 'has 2 items' do should have(2).items end`" do
414
- let(:source) do
415
- <<-END
416
- describe 'example' do
417
- it 'has 2 items' do
418
- should have(2).items
419
- end
420
- end
421
- END
422
- end
423
-
424
- let(:expected_source) do
425
- <<-END
426
- describe 'example' do
427
- it 'has 2 items' do
428
- subject.size.should == 2
429
- end
430
- end
431
- END
432
- end
433
-
434
- it "converts to `it 'has 2 items' do subject.size.should == 2 end` form" do
435
- rewritten_source.should == expected_source
436
- end
437
-
438
- it 'adds record ' \
439
- '`it \'...\' { should have(n).items }` -> `it \'...\' do subject.size.should == n end`' do
440
- record.old_syntax.should == "it '...' do should have(n).items end"
441
- record.new_syntax.should == "it '...' do subject.size.should == n end"
442
- end
443
- end
444
-
445
- context 'with expression `it { should have_at_least(2).items }`' do
446
- let(:source) do
447
- <<-END
448
- describe 'example' do
449
- it { should have_at_least(2).items }
450
- end
451
- END
452
- end
453
-
454
- let(:expected_source) do
455
- <<-END
456
- describe 'example' do
457
- it 'has at least 2 items' do
458
- subject.size.should >= 2
459
- end
460
- end
461
- END
462
- end
463
-
464
- it "converts to `it 'has at least 2 items' do subject.size.should >= 2 end` form" do
465
- rewritten_source.should == expected_source
466
- end
467
-
468
- it 'adds record `it { should have_at_least(n).items }` ' \
469
- '-> `it \'has at least n items\' do subject.size.should >= n end`' do
470
- record.old_syntax.should == 'it { should have_at_least(n).items }'
471
- record.new_syntax.should == "it 'has at least n items' do subject.size.should >= n end"
472
- end
473
- end
474
-
475
- context 'with expression `it { should have(2).words }`' do
476
- context 'with runtime information' do
477
- include_context 'dynamic analysis objects'
478
-
479
- context 'when the subject responds to #words and #words responds to #size' do
480
- let(:source) do
481
- <<-END
482
- class String
483
- def words
484
- split(' ')
485
- end
486
- end
487
-
488
- describe 'a string' do
489
- it { should have(2).words }
490
- end
491
- END
492
- end
493
-
494
- let(:expected_source) do
495
- <<-END
496
- class String
497
- def words
498
- split(' ')
499
- end
500
- end
501
-
502
- describe 'a string' do
503
- it 'has 2 words' do
504
- subject.words.size.should == 2
505
- end
506
- end
507
- END
508
- end
509
-
510
- it "converts to `it 'has 2 words' do subject.words.size.should == 2 end` form" do
511
- rewritten_source.should == expected_source
512
- end
513
-
514
- it 'adds record `it { should have(n).words }` ' \
515
- '-> `it \'has n words\' do subject.words.size.should == n end`' do
516
- record.old_syntax.should == 'it { should have(n).words }'
517
- record.new_syntax.should == "it 'has n words' do subject.words.size.should == n end"
518
- end
519
- end
520
- end
521
- end
522
- end
523
-
524
- describe '#convert_have_items_to_standard_expect! and Have#convert_to_standard_expectation!' do
525
- before do
526
- should_object.convert_have_items_to_standard_expect!
527
- should_object.have_matcher.convert_to_standard_expectation!
528
- end
529
-
530
- context 'with expression `it { should have(2).items }`' do
531
- let(:source) do
532
- <<-END
533
- describe 'example' do
534
- it { should have(2).items }
535
- end
536
- END
537
- end
538
-
539
- let(:expected_source) do
540
- <<-END
541
- describe 'example' do
542
- it 'has 2 items' do
543
- expect(subject.size).to eq(2)
544
- end
545
- end
546
- END
547
- end
548
-
549
- it "converts to `it 'has 2 items' do expect(subject.size).to eq(2) end` form" do
550
- rewritten_source.should == expected_source
551
- end
552
-
553
- it 'adds record ' \
554
- '`it { should have(n).items }` -> `it \'has n items\' do expect(subject.size).to eq(n) end`' do
555
- record.old_syntax.should == 'it { should have(n).items }'
556
- record.new_syntax.should == "it 'has n items' do expect(subject.size).to eq(n) end"
557
- end
558
- end
559
-
560
- context 'with expression `it { should_not have(2).items }`' do
561
- let(:source) do
562
- <<-END
563
- describe 'example' do
564
- it { should_not have(2).items }
565
- end
566
- END
567
- end
568
-
569
- let(:expected_source) do
570
- <<-END
571
- describe 'example' do
572
- it 'does not have 2 items' do
573
- expect(subject.size).not_to eq(2)
574
- end
575
- end
576
- END
577
- end
578
-
579
- it "converts to `it 'does not have 2 items' do expect(subject.size).not_to eq(2) end` form" do
580
- rewritten_source.should == expected_source
581
- end
582
-
583
- it 'adds record `it { should_not have(n).items }`' \
584
- ' -> `it \'does not have n items\' do expect(subject.size).not_to eq(n) end`' do
585
- record.old_syntax.should == 'it { should_not have(n).items }'
586
- record.new_syntax.should == "it 'does not have n items' do expect(subject.size).not_to eq(n) end"
587
- end
588
- end
589
-
590
- context 'when the oneliner #should is not directly enclosed in an example block' do
591
- let(:source) do
592
- <<-END
593
- describe 'example' do
594
- def some_method
595
- should have(2).items
596
- end
597
-
598
- it { some_method }
599
- end
600
- END
601
- end
602
-
603
- let(:expected_source) do
604
- <<-END
605
- describe 'example' do
606
- def some_method
607
- expect(subject.size).to eq(2)
608
- end
609
-
610
- it { some_method }
611
- end
612
- END
613
- end
614
-
615
- it 'does not insert example description' do
616
- rewritten_source.should == expected_source
617
- end
618
-
619
- it 'adds record ' \
620
- '`it { should have(n).items }` -> `it { expect(subject.size).to eq(n) }`' do
621
- record.old_syntax.should == 'it { should have(n).items }'
622
- record.new_syntax.should == 'it { expect(subject.size).to eq(n) }'
623
- end
624
- end
625
- end
626
- end
627
- end
628
- end