transpec 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,11 +11,13 @@ module Transpec
11
11
  subject(:its_object) do
12
12
  ast.each_node do |node|
13
13
  next unless Its.target_node?(node)
14
- return Its.new(node, source_rewriter)
14
+ return Its.new(node, source_rewriter, runtime_data)
15
15
  end
16
16
  fail 'No #its node is found!'
17
17
  end
18
18
 
19
+ let(:runtime_data) { nil }
20
+
19
21
  let(:record) { its_object.report.records.last }
20
22
 
21
23
  describe '#convert_to_describe_subject_it!' do
@@ -23,6 +25,29 @@ module Transpec
23
25
  its_object.convert_to_describe_subject_it!
24
26
  end
25
27
 
28
+ context 'when rspec-its is loaded in the spec' do
29
+ include_context 'dynamic analysis objects'
30
+
31
+ let(:source) do
32
+ <<-END
33
+ module RSpec
34
+ module Its
35
+ end
36
+ end
37
+
38
+ describe 'example' do
39
+ subject { ['foo'] }
40
+
41
+ its(:size) { should == 1 }
42
+ end
43
+ END
44
+ end
45
+
46
+ it 'does nothing' do
47
+ rewritten_source.should == source
48
+ end
49
+ end
50
+
26
51
  context 'when it is `its(:size) { ... }` form' do
27
52
  let(:source) do
28
53
  <<-END
@@ -47,13 +72,13 @@ module Transpec
47
72
  END
48
73
  end
49
74
 
50
- it "converts into `describe '#size' do subject { super().size } it { ... } end` form" do
75
+ it "converts into `describe '#size' do subject { super().size }; it { ... } end` form" do
51
76
  rewritten_source.should == expected_source
52
77
  end
53
78
 
54
- it "adds record \"`its(:attr) { }` -> `describe 'attr' do subject { super().attr } it { } end`\"" do
79
+ it "adds record \"`its(:attr) { }` -> `describe 'attr' do subject { super().attr }; it { } end`\"" do
55
80
  record.original_syntax.should == 'its(:attr) { }'
56
- record.converted_syntax.should == "describe 'attr' do subject { super().attr } it { } end"
81
+ record.converted_syntax.should == "describe 'attr' do subject { super().attr }; it { } end"
57
82
  end
58
83
 
59
84
  context 'and there is no blank line before #its' do
@@ -144,13 +169,13 @@ module Transpec
144
169
  END
145
170
  end
146
171
 
147
- it "converts into `describe '#size' do subject { super().size } it { ... } end` form" do
172
+ it "converts into `describe '#size' do subject { super().size }; it { ... } end` form" do
148
173
  rewritten_source.should == expected_source
149
174
  end
150
175
 
151
- it "adds record \"`its(:attr) { }` -> `describe 'attr' do subject { super().attr } it { } end`\"" do
176
+ it "adds record \"`its(:attr) { }` -> `describe 'attr' do subject { super().attr }; it { } end`\"" do
152
177
  record.original_syntax.should == 'its(:attr) { }'
153
- record.converted_syntax.should == "describe 'attr' do subject { super().attr } it { } end"
178
+ record.converted_syntax.should == "describe 'attr' do subject { super().attr }; it { } end"
154
179
  end
155
180
  end
156
181
 
@@ -185,9 +210,9 @@ module Transpec
185
210
  rewritten_source.should == expected_source
186
211
  end
187
212
 
188
- it "adds record \"`its(:attr) { }` -> `describe 'attr' do subject { super().attr } it { } end`\"" do
213
+ it "adds record \"`its(:attr) { }` -> `describe 'attr' do subject { super().attr }; it { } end`\"" do
189
214
  record.original_syntax.should == 'its(:attr) { }'
190
- record.converted_syntax.should == "describe 'attr' do subject { super().attr } it { } end"
215
+ record.converted_syntax.should == "describe 'attr' do subject { super().attr }; it { } end"
191
216
  end
192
217
  end
193
218
 
@@ -215,13 +240,13 @@ module Transpec
215
240
  END
216
241
  end
217
242
 
218
- it "converts into `describe '[:foo]' do subject { super()[:foo] } it { ... } end` form" do
243
+ it "converts into `describe '[:foo]' do subject { super()[:foo] }; it { ... } end` form" do
219
244
  rewritten_source.should == expected_source
220
245
  end
221
246
 
222
- it "adds record \"`its([:key]) { }` -> `describe '[:key]' do subject { super()[:key] } it { } end`\"" do
247
+ it "adds record \"`its([:key]) { }` -> `describe '[:key]' do subject { super()[:key] }; it { } end`\"" do
223
248
  record.original_syntax.should == 'its([:key]) { }'
224
- record.converted_syntax.should == "describe '[:key]' do subject { super()[:key] } it { } end"
249
+ record.converted_syntax.should == "describe '[:key]' do subject { super()[:key] }; it { } end"
225
250
  end
226
251
  end
227
252
 
@@ -249,13 +274,13 @@ module Transpec
249
274
  END
250
275
  end
251
276
 
252
- it "converts into `describe \"['foo']\" do subject { super()['foo'] } it { ... } end` form" do
277
+ it "converts into `describe \"['foo']\" do subject { super()['foo'] }; it { ... } end` form" do
253
278
  rewritten_source.should == expected_source
254
279
  end
255
280
 
256
- it "adds record \"`its([:key]) { }` -> `describe '[:key]' do subject { super()[:key] } it { } end`\"" do
281
+ it "adds record \"`its([:key]) { }` -> `describe '[:key]' do subject { super()[:key] }; it { } end`\"" do
257
282
  record.original_syntax.should == 'its([:key]) { }'
258
- record.converted_syntax.should == "describe '[:key]' do subject { super()[:key] } it { } end"
283
+ record.converted_syntax.should == "describe '[:key]' do subject { super()[:key] }; it { } end"
259
284
  end
260
285
  end
261
286
 
@@ -283,13 +308,13 @@ module Transpec
283
308
  END
284
309
  end
285
310
 
286
- it "converts into `describe '[3, 2]' do subject { super()[3, 2] } it { ... } end` form" do
311
+ it "converts into `describe '[3, 2]' do subject { super()[3, 2] }; it { ... } end` form" do
287
312
  rewritten_source.should == expected_source
288
313
  end
289
314
 
290
- it "adds record \"`its([:key]) { }` -> `describe '[:key]' do subject { super()[:key] } it { } end`\"" do
315
+ it "adds record \"`its([:key]) { }` -> `describe '[:key]' do subject { super()[:key] }; it { } end`\"" do
291
316
  record.original_syntax.should == 'its([:key]) { }'
292
- record.converted_syntax.should == "describe '[:key]' do subject { super()[:key] } it { } end"
317
+ record.converted_syntax.should == "describe '[:key]' do subject { super()[:key] }; it { } end"
293
318
  end
294
319
  end
295
320
 
@@ -327,13 +352,13 @@ module Transpec
327
352
  END
328
353
  end
329
354
 
330
- it 'converts into `describe attribute do subject { super().send(attribute) } it { ... } end` form' do
355
+ it 'converts into `describe attribute do subject { super().send(attribute) }; it { ... } end` form' do
331
356
  rewritten_source.should == expected_source
332
357
  end
333
358
 
334
- it "adds record \"`its(:attr) { }` -> `describe 'attr' do subject { super().attr } it { } end`\"" do
359
+ it "adds record \"`its(:attr) { }` -> `describe 'attr' do subject { super().attr }; it { } end`\"" do
335
360
  record.original_syntax.should == 'its(:attr) { }'
336
- record.converted_syntax.should == "describe 'attr' do subject { super().attr } it { } end"
361
+ record.converted_syntax.should == "describe 'attr' do subject { super().attr }; it { } end"
337
362
  end
338
363
  end
339
364
 
@@ -371,13 +396,13 @@ module Transpec
371
396
  END
372
397
  end
373
398
 
374
- it 'converts into `describe [1, length] do subject { super()[1, length] } it { ... } end` form' do
399
+ it 'converts into `describe [1, length] do subject { super()[1, length] }; it { ... } end` form' do
375
400
  rewritten_source.should == expected_source
376
401
  end
377
402
 
378
- it "adds record \"`its([:key]) { }` -> `describe '[:key]' do subject { super()[:key] } it { } end`\"" do
403
+ it "adds record \"`its([:key]) { }` -> `describe '[:key]' do subject { super()[:key] }; it { } end`\"" do
379
404
  record.original_syntax.should == 'its([:key]) { }'
380
- record.converted_syntax.should == "describe '[:key]' do subject { super()[:key] } it { } end"
405
+ record.converted_syntax.should == "describe '[:key]' do subject { super()[:key] }; it { } end"
381
406
  end
382
407
  end
383
408
  end