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.
- checksums.yaml +4 -4
- data/.rubocop.yml +11 -0
- data/CHANGELOG.md +8 -1
- data/Gemfile +0 -2
- data/Guardfile +2 -2
- data/README.md +16 -16
- data/README.md.erb +9 -9
- data/lib/transpec/cli.rb +12 -13
- data/lib/transpec/config.rb +1 -1
- data/lib/transpec/converter.rb +11 -7
- data/lib/transpec/dynamic_analyzer.rb +2 -2
- data/lib/transpec/git.rb +5 -4
- data/lib/transpec/option_parser.rb +8 -8
- data/lib/transpec/processed_source.rb +4 -7
- data/lib/transpec/project.rb +18 -5
- data/lib/transpec/spec_suite.rb +9 -6
- data/lib/transpec/syntax.rb +13 -5
- data/lib/transpec/syntax/method_stub.rb +1 -1
- data/lib/transpec/syntax/mixin/matcher_owner.rb +3 -1
- data/lib/transpec/syntax/mixin/owned_matcher.rb +4 -2
- data/lib/transpec/syntax/mixin/rspec_rails.rb +1 -1
- data/lib/transpec/syntax/oneliner_should.rb +1 -1
- data/lib/transpec/syntax/operator.rb +4 -2
- data/lib/transpec/syntax/rspec_configure.rb +1 -1
- data/lib/transpec/version.rb +3 -3
- data/spec/spec_helper.rb +1 -4
- data/spec/support/shared_context.rb +6 -1
- data/spec/transpec/config_spec.rb +1 -1
- data/spec/transpec/converter_spec.rb +10 -5
- data/spec/transpec/dynamic_analyzer_spec.rb +6 -6
- data/spec/transpec/git_spec.rb +22 -33
- data/spec/transpec/option_parser_spec.rb +4 -4
- data/spec/transpec/project_spec.rb +118 -7
- data/spec/transpec/spec_suite_spec.rb +4 -3
- data/spec/transpec/syntax/current_example_spec.rb +2 -2
- data/spec/transpec/syntax/double_spec.rb +1 -1
- data/spec/transpec/syntax/example_group_spec.rb +309 -164
- data/spec/transpec/syntax/example_spec.rb +1 -1
- data/spec/transpec/syntax/have_spec.rb +1 -1
- data/spec/transpec/syntax/its_spec.rb +1 -1
- data/spec/transpec/syntax/method_stub_spec.rb +7 -10
- data/spec/transpec/syntax/oneliner_should_spec.rb +1 -1
- data/spec/transpec/syntax/pending_spec.rb +1 -1
- data/spec/transpec/syntax/rspec_configure_spec.rb +66 -57
- data/tasks/readme.rake +12 -3
- metadata +3 -3
@@ -21,7 +21,7 @@ module Transpec
|
|
21
21
|
end
|
22
22
|
|
23
23
|
let(:method_stub_object) do
|
24
|
-
MethodStub.new(target_node,
|
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.
|
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!(
|
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!(
|
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!(
|
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!
|
284
|
-
.should_not raise_error
|
281
|
+
-> { method_stub_object.allowize! }.should_not raise_error
|
285
282
|
end
|
286
283
|
end
|
287
284
|
end
|
@@ -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.
|
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
|
-
|
294
|
-
|
295
|
-
|
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
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
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
|
-
|
323
|
-
|
324
|
-
|
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
|
-
|
327
|
-
|
328
|
-
|
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
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
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
|
-
|
342
|
-
|
343
|
-
|
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
|
-
|
346
|
-
|
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
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
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
|
-
|
402
|
-
|
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:
|
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
|
+
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.
|
423
|
+
rubygems_version: 2.4.3
|
424
424
|
signing_key:
|
425
425
|
specification_version: 4
|
426
426
|
summary: The RSpec syntax converter
|