transpec 2.3.8 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +11 -0
  3. data/CHANGELOG.md +8 -1
  4. data/Gemfile +0 -2
  5. data/Guardfile +2 -2
  6. data/README.md +16 -16
  7. data/README.md.erb +9 -9
  8. data/lib/transpec/cli.rb +12 -13
  9. data/lib/transpec/config.rb +1 -1
  10. data/lib/transpec/converter.rb +11 -7
  11. data/lib/transpec/dynamic_analyzer.rb +2 -2
  12. data/lib/transpec/git.rb +5 -4
  13. data/lib/transpec/option_parser.rb +8 -8
  14. data/lib/transpec/processed_source.rb +4 -7
  15. data/lib/transpec/project.rb +18 -5
  16. data/lib/transpec/spec_suite.rb +9 -6
  17. data/lib/transpec/syntax.rb +13 -5
  18. data/lib/transpec/syntax/method_stub.rb +1 -1
  19. data/lib/transpec/syntax/mixin/matcher_owner.rb +3 -1
  20. data/lib/transpec/syntax/mixin/owned_matcher.rb +4 -2
  21. data/lib/transpec/syntax/mixin/rspec_rails.rb +1 -1
  22. data/lib/transpec/syntax/oneliner_should.rb +1 -1
  23. data/lib/transpec/syntax/operator.rb +4 -2
  24. data/lib/transpec/syntax/rspec_configure.rb +1 -1
  25. data/lib/transpec/version.rb +3 -3
  26. data/spec/spec_helper.rb +1 -4
  27. data/spec/support/shared_context.rb +6 -1
  28. data/spec/transpec/config_spec.rb +1 -1
  29. data/spec/transpec/converter_spec.rb +10 -5
  30. data/spec/transpec/dynamic_analyzer_spec.rb +6 -6
  31. data/spec/transpec/git_spec.rb +22 -33
  32. data/spec/transpec/option_parser_spec.rb +4 -4
  33. data/spec/transpec/project_spec.rb +118 -7
  34. data/spec/transpec/spec_suite_spec.rb +4 -3
  35. data/spec/transpec/syntax/current_example_spec.rb +2 -2
  36. data/spec/transpec/syntax/double_spec.rb +1 -1
  37. data/spec/transpec/syntax/example_group_spec.rb +309 -164
  38. data/spec/transpec/syntax/example_spec.rb +1 -1
  39. data/spec/transpec/syntax/have_spec.rb +1 -1
  40. data/spec/transpec/syntax/its_spec.rb +1 -1
  41. data/spec/transpec/syntax/method_stub_spec.rb +7 -10
  42. data/spec/transpec/syntax/oneliner_should_spec.rb +1 -1
  43. data/spec/transpec/syntax/pending_spec.rb +1 -1
  44. data/spec/transpec/syntax/rspec_configure_spec.rb +66 -57
  45. data/tasks/readme.rake +12 -3
  46. metadata +3 -3
@@ -22,7 +22,7 @@ module Transpec
22
22
  end
23
23
 
24
24
  let(:example_object) do
25
- Example.new(target_node, source_rewriter, runtime_data)
25
+ Example.new(target_node, runtime_data)
26
26
  end
27
27
 
28
28
  subject { example_object.conversion_target? }
@@ -81,7 +81,7 @@ module Transpec
81
81
  end
82
82
 
83
83
  let(:should_object) do
84
- Should.new(should_node, source_rewriter, runtime_data)
84
+ Should.new(should_node, runtime_data)
85
85
  end
86
86
 
87
87
  subject { should_object.have_matcher.conversion_target? }
@@ -20,7 +20,7 @@ module Transpec
20
20
  end
21
21
 
22
22
  let(:its_object) do
23
- Its.new(its_node, source_rewriter, runtime_data)
23
+ Its.new(its_node, runtime_data)
24
24
  end
25
25
 
26
26
  subject { its_object.conversion_target? }
@@ -21,7 +21,7 @@ module Transpec
21
21
  end
22
22
 
23
23
  let(:method_stub_object) do
24
- MethodStub.new(target_node, source_rewriter, runtime_data)
24
+ MethodStub.new(target_node, runtime_data)
25
25
  end
26
26
 
27
27
  subject { method_stub_object.conversion_target? }
@@ -176,7 +176,8 @@ module Transpec
176
176
 
177
177
  describe '#allowize!' do
178
178
  before do
179
- method_stub_object.allowize!(rspec_version) unless example.metadata[:no_before_allowize!]
179
+ method_stub_object.stub(:rspec_version).and_return(rspec_version)
180
+ method_stub_object.allowize! unless example.metadata[:no_before_allowize!]
180
181
  end
181
182
 
182
183
  let(:rspec_version) { Transpec.required_rspec_version }
@@ -241,15 +242,13 @@ module Transpec
241
242
  include_context 'dynamic analysis objects'
242
243
 
243
244
  it 'raises ContextError' do
244
- -> { method_stub_object.allowize!(rspec_version) }
245
- .should raise_error(ContextError)
245
+ -> { method_stub_object.allowize! }.should raise_error(ContextError)
246
246
  end
247
247
  end
248
248
 
249
249
  context 'without runtime information' do
250
250
  it 'raises ContextError' do
251
- -> { method_stub_object.allowize!(rspec_version) }
252
- .should raise_error(ContextError)
251
+ -> { method_stub_object.allowize! }.should raise_error(ContextError)
253
252
  end
254
253
  end
255
254
  end
@@ -273,15 +272,13 @@ module Transpec
273
272
  include_context 'dynamic analysis objects'
274
273
 
275
274
  it 'raises ContextError' do
276
- -> { method_stub_object.allowize!(rspec_version) }
277
- .should raise_error(ContextError)
275
+ -> { method_stub_object.allowize! }.should raise_error(ContextError)
278
276
  end
279
277
  end
280
278
 
281
279
  context 'without runtime information' do
282
280
  it 'does not raise ContextError' do
283
- -> { method_stub_object.allowize!(rspec_version) }
284
- .should_not raise_error
281
+ -> { method_stub_object.allowize! }.should_not raise_error
285
282
  end
286
283
  end
287
284
  end
@@ -20,7 +20,7 @@ module Transpec
20
20
  end
21
21
 
22
22
  let(:should_object) do
23
- OnelinerShould.new(target_node, source_rewriter, runtime_data)
23
+ OnelinerShould.new(target_node, runtime_data)
24
24
  end
25
25
 
26
26
  subject { should_object.conversion_target? }
@@ -20,7 +20,7 @@ module Transpec
20
20
  end
21
21
 
22
22
  let(:pending_object) do
23
- Pending.new(target_node, source_rewriter, runtime_data)
23
+ Pending.new(target_node, runtime_data)
24
24
  end
25
25
 
26
26
  subject { pending_object.conversion_target? }
@@ -14,6 +14,7 @@ module Transpec
14
14
 
15
15
  context 'when multiple configurations are added' do
16
16
  before do
17
+ rspec_configure.stub(:rspec_rails?).and_return(true)
17
18
  rspec_configure.expose_dsl_globally = true
18
19
  rspec_configure.infer_spec_type_from_file_location!
19
20
  end
@@ -58,7 +59,8 @@ module Transpec
58
59
 
59
60
  describe '#convert_deprecated_options!' do
60
61
  before do
61
- rspec_configure.convert_deprecated_options!(RSpecVersion.new('3.0.0'))
62
+ rspec_configure.stub(:rspec_version).and_return(RSpecVersion.new('3.0.0'))
63
+ rspec_configure.convert_deprecated_options!
62
64
  end
63
65
 
64
66
  [
@@ -290,66 +292,73 @@ module Transpec
290
292
  end
291
293
 
292
294
  describe '#infer_spec_type_from_file_location!' do
293
- before do
294
- rspec_configure.infer_spec_type_from_file_location!
295
- end
296
-
297
- context 'when #infer_spec_type_from_file_location! does not exist' do
298
- let(:source) do
299
- <<-END
300
- RSpec.configure do |config|
301
- end
302
- END
295
+ context 'in rspec-rails project' do
296
+ before do
297
+ rspec_configure.stub(:rspec_rails?).and_return(true)
298
+ rspec_configure.infer_spec_type_from_file_location!
303
299
  end
304
300
 
305
- let(:expected_source) do
306
- <<-END
307
- RSpec.configure do |config|
308
- # rspec-rails 3 will no longer automatically infer an example group's spec type
309
- # from the file location. You can explicitly opt-in to the feature using this
310
- # config option.
311
- # To explicitly tag specs without using automatic inference, set the `:type`
312
- # metadata manually:
313
- #
314
- # describe ThingsController, :type => :controller do
315
- # # Equivalent to being in spec/controllers
316
- # end
317
- config.infer_spec_type_from_file_location!
318
- end
319
- END
320
- end
301
+ context 'when #infer_spec_type_from_file_location! does not exist' do
302
+ let(:source) do
303
+ <<-END
304
+ RSpec.configure do |config|
305
+ end
306
+ END
307
+ end
321
308
 
322
- it 'adds #infer_spec_type_from_file_location! statement along with comment' do
323
- rewritten_source.should == expected_source
324
- end
309
+ let(:expected_source) do
310
+ <<-END
311
+ RSpec.configure do |config|
312
+ # rspec-rails 3 will no longer automatically infer an example group's spec type
313
+ # from the file location. You can explicitly opt-in to the feature using this
314
+ # config option.
315
+ # To explicitly tag specs without using automatic inference, set the `:type`
316
+ # metadata manually:
317
+ #
318
+ # describe ThingsController, :type => :controller do
319
+ # # Equivalent to being in spec/controllers
320
+ # end
321
+ config.infer_spec_type_from_file_location!
322
+ end
323
+ END
324
+ end
325
325
 
326
- it 'adds record of addition `RSpec.configure { |c| c.expose_dsl_globally = value }`' do
327
- record.type.should == :addition
328
- record.new_syntax.should == 'RSpec.configure { |c| c.infer_spec_type_from_file_location! }'
329
- end
330
- end
326
+ it 'adds #infer_spec_type_from_file_location! statement along with comment' do
327
+ rewritten_source.should == expected_source
328
+ end
331
329
 
332
- context 'when #infer_spec_type_from_file_location! already exists' do
333
- let(:source) do
334
- <<-END
335
- RSpec.configure do |config|
336
- config.infer_spec_type_from_file_location!
337
- end
338
- END
330
+ it 'adds record of addition `RSpec.configure { |c| c.expose_dsl_globally = value }`' do
331
+ record.type.should == :addition
332
+ record.new_syntax.should == 'RSpec.configure { |c| c.infer_spec_type_from_file_location! }'
333
+ end
339
334
  end
340
335
 
341
- it 'does nothing' do
342
- rewritten_source.should == source
343
- end
336
+ context 'when #infer_spec_type_from_file_location! already exists' do
337
+ let(:source) do
338
+ <<-END
339
+ RSpec.configure do |config|
340
+ config.infer_spec_type_from_file_location!
341
+ end
342
+ END
343
+ end
344
+
345
+ it 'does nothing' do
346
+ rewritten_source.should == source
347
+ end
344
348
 
345
- it 'reports nothing' do
346
- record.should be_nil
349
+ it 'reports nothing' do
350
+ record.should be_nil
351
+ end
347
352
  end
348
353
  end
349
354
 
350
355
  context 'with runtime information' do
351
356
  include_context 'dynamic analysis objects'
352
357
 
358
+ before do
359
+ rspec_configure.infer_spec_type_from_file_location!
360
+ end
361
+
353
362
  context 'when rspec-rails is loaded in the spec' do
354
363
  let(:source) do
355
364
  <<-END
@@ -388,18 +397,18 @@ module Transpec
388
397
  it 'adds #infer_spec_type_from_file_location! statement' do
389
398
  rewritten_source.should == expected_source
390
399
  end
391
- end
392
400
 
393
- context 'when rspec-rails is not loaded in the spec' do
394
- let(:source) do
395
- <<-END
396
- RSpec.configure do |config|
397
- end
398
- END
399
- end
401
+ context 'when rspec-rails is not loaded in the spec' do
402
+ let(:source) do
403
+ <<-END
404
+ RSpec.configure do |config|
405
+ end
406
+ END
407
+ end
400
408
 
401
- it 'does nothing' do
402
- rewritten_source.should == source
409
+ it 'does nothing' do
410
+ rewritten_source.should == source
411
+ end
403
412
  end
404
413
  end
405
414
  end
data/tasks/readme.rake CHANGED
@@ -53,9 +53,6 @@ class READMEContext
53
53
  end
54
54
 
55
55
  def convert(source, options = {}) # rubocop:disable MethodLength
56
- cli = Transpec::CLI.new
57
- cli.project.stub(:rspec_version).and_return(options[:rspec_version]) if options[:rspec_version]
58
-
59
56
  cli_args = Array(options[:cli])
60
57
  cli_args << '--skip-dynamic-analysis' unless options[:dynamic] # For performance
61
58
 
@@ -72,7 +69,19 @@ class READMEContext
72
69
  in_isolated_env do
73
70
  path = options[:path] || 'spec/example_spec.rb'
74
71
  FileHelper.create_file(path, source)
72
+
73
+ cli = Transpec::CLI.new
74
+
75
+ if options[:rspec_version]
76
+ cli.project.stub(:rspec_version).and_return(options[:rspec_version])
77
+ end
78
+
79
+ if options[:rails]
80
+ cli.project.stub(:depend_on_rspec_rails?).and_return(true)
81
+ end
82
+
75
83
  cli.run(cli_args)
84
+
76
85
  converted_source = File.read(path)
77
86
  end
78
87
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transpec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.8
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuji Nakayama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-11 00:00:00.000000000 Z
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -420,7 +420,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
420
420
  version: '0'
421
421
  requirements: []
422
422
  rubyforge_project:
423
- rubygems_version: 2.4.2
423
+ rubygems_version: 2.4.3
424
424
  signing_key:
425
425
  specification_version: 4
426
426
  summary: The RSpec syntax converter