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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe2492f7a3b324bdfb3f2facd8a1ffb9369b6228
|
4
|
+
data.tar.gz: f710841766c727037a9adb01c857f4a365c39a73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35e7f4ef63186b8203c900cffe147e7dc0edf2686c7c2621055f72690c8f1ac8363128c869900942ef8901dcc1410db8b74d51068a1dfed6ae59f04e6ec2030b
|
7
|
+
data.tar.gz: c8077f07f56bee2f1828c8b7cc44b0c3c3239ae5a84a271c8e9244a8c8a5877a593d0bf211c07dd559c7f2062273735743b89c954f08174e13f8e9980ecb228d
|
data/.rubocop.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
|
2
2
|
AllCops:
|
3
3
|
Include:
|
4
|
+
- 'Guardfile'
|
4
5
|
- '**/*.rake'
|
5
6
|
Exclude:
|
6
7
|
- 'tmp/**/*'
|
@@ -12,6 +13,9 @@ LineLength:
|
|
12
13
|
MethodLength:
|
13
14
|
Max: 17
|
14
15
|
|
16
|
+
ParameterLists:
|
17
|
+
Max: 6
|
18
|
+
|
15
19
|
CyclomaticComplexity:
|
16
20
|
Max: 8
|
17
21
|
|
@@ -24,6 +28,13 @@ AbcSize:
|
|
24
28
|
WordArray:
|
25
29
|
Enabled: false
|
26
30
|
|
31
|
+
RegexpLiteral:
|
32
|
+
Exclude:
|
33
|
+
- 'Guardfile'
|
34
|
+
|
35
|
+
EmptyElse:
|
36
|
+
Enabled: false
|
37
|
+
|
27
38
|
AlignHash:
|
28
39
|
# Alignment of entries using hash rocket as separator. Valid values are:
|
29
40
|
#
|
data/CHANGELOG.md
CHANGED
@@ -2,9 +2,16 @@
|
|
2
2
|
|
3
3
|
## Development
|
4
4
|
|
5
|
+
## v3.0.0
|
6
|
+
|
7
|
+
* Check whether rspec-rails is used in the target project via `Gemfile.lock` when `-s/--skip-dynamic-analysis` option is specified. ([#88](https://github.com/yujinakayama/transpec/issues/88))
|
8
|
+
* Now by default the addition of `config.infer_spec_type_from_file_location!` is enabled and the addition of explicit `:type` metadata to each example group is disabled in a project using `rspec-rails` (the former behavior with `-t/--no-explicit-spec-type`).
|
9
|
+
* Remove `-t/--no-explicit-spec-type` and add `-e/--explicit-spec-type` option.
|
10
|
+
* Handle separated git-dir repository on generation of the commit message. ([#94](https://github.com/yujinakayama/transpec/issues/94))
|
11
|
+
|
5
12
|
## v2.3.8
|
6
13
|
|
7
|
-
* Fix an error on processing one-liner `should` that is not directly
|
14
|
+
* Fix an error on processing one-liner `should` that is not directly enclosed in an example block. ([#93](https://github.com/yujinakayama/transpec/issues/93))
|
8
15
|
|
9
16
|
## v2.3.7
|
10
17
|
|
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -7,8 +7,8 @@ group :red_green_refactor, halt_on_fail: true do
|
|
7
7
|
guard :rspec, cmd: 'bundle exec rspec --format Fuubar' do
|
8
8
|
watch(%r{^spec/.+_spec\.rb$})
|
9
9
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
10
|
-
watch('spec/spec_helper.rb') {
|
11
|
-
watch(%r{^spec/support/.+\.rb$}) {
|
10
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
11
|
+
watch(%r{^spec/support/.+\.rb$}) { 'spec' }
|
12
12
|
end
|
13
13
|
|
14
14
|
guard :rubocop, all_on_start: false, cli: '--format fuubar' do
|
data/README.md
CHANGED
@@ -306,6 +306,12 @@ $ transpec --boolean-matcher true,false
|
|
306
306
|
|
307
307
|
See [Supported Conversions - Boolean matchers](#boolean-matchers) for more details.
|
308
308
|
|
309
|
+
### `-e/--explicit-spec-type`
|
310
|
+
|
311
|
+
Add explicit spec `:type` metadata to example groups in a project using rspec-rails.
|
312
|
+
|
313
|
+
See [Supported Conversions - Implicit spec types in rspec-rails](#implicit-spec-types-in-rspec-rails) for more details.
|
314
|
+
|
309
315
|
### `-a/--no-yield-any-instance`
|
310
316
|
|
311
317
|
Suppress yielding receiver instances to `any_instance` implementation blocks as the first block argument.
|
@@ -317,12 +323,6 @@ Note that this is not same as `--keep deprecated` since this configures `yield_r
|
|
317
323
|
|
318
324
|
See [Supported Conversions - `any_instance` implementation blocks](#any_instance-implementation-blocks) for more details.
|
319
325
|
|
320
|
-
### `-t/--no-explicit-spec-type`
|
321
|
-
|
322
|
-
Suppress adding explicit spec `:type` metadata to example groups in a project using rspec-rails.
|
323
|
-
|
324
|
-
See [Supported Conversions - Implicit spec types in rspec-rails](#implicit-spec-types-in-rspec-rails) for more details.
|
325
|
-
|
326
326
|
### `-p/--no-parens-matcher-arg`
|
327
327
|
|
328
328
|
Suppress parenthesizing arguments of matchers when converting
|
@@ -1270,16 +1270,6 @@ end
|
|
1270
1270
|
|
1271
1271
|
Will be converted to:
|
1272
1272
|
|
1273
|
-
```ruby
|
1274
|
-
RSpec.configure do |rspec|
|
1275
|
-
end
|
1276
|
-
|
1277
|
-
describe SomeModel, :type => :model do
|
1278
|
-
end
|
1279
|
-
```
|
1280
|
-
|
1281
|
-
Or with `--no-explicit-spec-type` option they will be converted to:
|
1282
|
-
|
1283
1273
|
```ruby
|
1284
1274
|
RSpec.configure do |rspec|
|
1285
1275
|
# rspec-rails 3 will no longer automatically infer an example group's spec type
|
@@ -1298,6 +1288,16 @@ describe SomeModel do
|
|
1298
1288
|
end
|
1299
1289
|
```
|
1300
1290
|
|
1291
|
+
Or with `--explicit-spec-type` option they will be converted to:
|
1292
|
+
|
1293
|
+
```ruby
|
1294
|
+
RSpec.configure do |rspec|
|
1295
|
+
end
|
1296
|
+
|
1297
|
+
describe SomeModel, :type => :model do
|
1298
|
+
end
|
1299
|
+
```
|
1300
|
+
|
1301
1301
|
* This conversion can be disabled by: `--keep deprecated`
|
1302
1302
|
* Deprecation: deprecated since RSpec 2.99, removed in RSpec 3.0
|
1303
1303
|
* See also: [Consider making example group mixins more explicit · rspec/rspec-rails](https://github.com/rspec/rspec-rails/issues/662)
|
data/README.md.erb
CHANGED
@@ -294,6 +294,12 @@ $ transpec --boolean-matcher true,false
|
|
294
294
|
|
295
295
|
See [Supported Conversions - Boolean matchers](#boolean-matchers) for more details.
|
296
296
|
|
297
|
+
### `-e/--explicit-spec-type`
|
298
|
+
|
299
|
+
Add explicit spec `:type` metadata to example groups in a project using rspec-rails.
|
300
|
+
|
301
|
+
See [Supported Conversions - Implicit spec types in rspec-rails](#implicit-spec-types-in-rspec-rails) for more details.
|
302
|
+
|
297
303
|
### `-a/--no-yield-any-instance`
|
298
304
|
|
299
305
|
Suppress yielding receiver instances to `any_instance` implementation blocks as the first block argument.
|
@@ -305,12 +311,6 @@ Note that this is not same as `--keep deprecated` since this configures `yield_r
|
|
305
311
|
|
306
312
|
See [Supported Conversions - `any_instance` implementation blocks](#any_instance-implementation-blocks) for more details.
|
307
313
|
|
308
|
-
### `-t/--no-explicit-spec-type`
|
309
|
-
|
310
|
-
Suppress adding explicit spec `:type` metadata to example groups in a project using rspec-rails.
|
311
|
-
|
312
|
-
See [Supported Conversions - Implicit spec types in rspec-rails](#implicit-spec-types-in-rspec-rails) for more details.
|
313
|
-
|
314
314
|
### `-p/--no-parens-matcher-arg`
|
315
315
|
|
316
316
|
Suppress parenthesizing arguments of matchers when converting
|
@@ -1328,13 +1328,13 @@ END
|
|
1328
1328
|
Will be converted to:
|
1329
1329
|
|
1330
1330
|
```ruby
|
1331
|
-
<%= convert(example, rspec_version: rspec_version, path: 'spec/models/some_model_spec.rb') -%>
|
1331
|
+
<%= convert(example, rspec_version: rspec_version, rails: true, path: 'spec/models/some_model_spec.rb') -%>
|
1332
1332
|
```
|
1333
1333
|
|
1334
|
-
Or with `--
|
1334
|
+
Or with `--explicit-spec-type` option they will be converted to:
|
1335
1335
|
|
1336
1336
|
```ruby
|
1337
|
-
<%= convert(example, rspec_version: rspec_version, path: 'spec/models/some_model_spec.rb', cli: ['--
|
1337
|
+
<%= convert(example, rspec_version: rspec_version, rails: true, path: 'spec/models/some_model_spec.rb', cli: ['--explicit-spec-type']) -%>
|
1338
1338
|
```
|
1339
1339
|
|
1340
1340
|
* This conversion can be disabled by: `--keep deprecated`
|
data/lib/transpec/cli.rb
CHANGED
@@ -34,8 +34,12 @@ module Transpec
|
|
34
34
|
return false
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
begin
|
38
|
+
process(paths)
|
39
|
+
rescue DynamicAnalyzer::AnalysisError => error
|
40
|
+
warn "\n" + error.message.color(:red)
|
41
|
+
return false
|
42
|
+
end
|
39
43
|
|
40
44
|
display_summary
|
41
45
|
generate_commit_message
|
@@ -47,10 +51,9 @@ module Transpec
|
|
47
51
|
def process(paths)
|
48
52
|
unless config.skip_dynamic_analysis?
|
49
53
|
runtime_data = run_dynamic_analysis(paths)
|
50
|
-
return false unless runtime_data
|
51
54
|
end
|
52
55
|
|
53
|
-
spec_suite = SpecSuite.new(paths, runtime_data)
|
56
|
+
spec_suite = SpecSuite.new(project, paths, runtime_data)
|
54
57
|
# Actually #analyze does not need to be invoked here, but doing this will avoid long freeze
|
55
58
|
# while conversion of files.
|
56
59
|
puts 'Gathering the spec suite data...'
|
@@ -60,8 +63,6 @@ module Transpec
|
|
60
63
|
spec_suite.specs.each do |spec|
|
61
64
|
convert_spec(spec, spec_suite)
|
62
65
|
end
|
63
|
-
|
64
|
-
true
|
65
66
|
end
|
66
67
|
|
67
68
|
def run_dynamic_analysis(paths)
|
@@ -69,7 +70,7 @@ module Transpec
|
|
69
70
|
|
70
71
|
puts 'Copying the project for dynamic analysis...'
|
71
72
|
|
72
|
-
DynamicAnalyzer.new(rspec_command: config.rspec_command) do |analyzer|
|
73
|
+
DynamicAnalyzer.new(project: project, rspec_command: config.rspec_command) do |analyzer|
|
73
74
|
puts "Running dynamic analysis with command #{analyzer.rspec_command.inspect}..."
|
74
75
|
runtime_data = analyzer.analyze(paths)
|
75
76
|
end
|
@@ -77,15 +78,12 @@ module Transpec
|
|
77
78
|
puts
|
78
79
|
|
79
80
|
runtime_data
|
80
|
-
rescue DynamicAnalyzer::AnalysisError => error
|
81
|
-
warn "\n" + error.message.color(:red)
|
82
|
-
return nil
|
83
81
|
end
|
84
82
|
|
85
83
|
def convert_spec(spec, spec_suite)
|
86
84
|
puts "Converting #{spec.path}"
|
87
85
|
|
88
|
-
converter = Converter.new(spec_suite,
|
86
|
+
converter = Converter.new(spec_suite, project, config)
|
89
87
|
converter.convert_file!(spec)
|
90
88
|
|
91
89
|
warn_annotations(converter.report)
|
@@ -129,11 +127,12 @@ module Transpec
|
|
129
127
|
return unless Git.command_available? && Git.inside_of_repository?
|
130
128
|
|
131
129
|
commit_message = CommitMessage.new(report, project.rspec_version, ARGV)
|
132
|
-
Git.write_commit_message(commit_message.to_s)
|
130
|
+
commit_message_path = Git.write_commit_message(commit_message.to_s)
|
131
|
+
commit_message_path = Pathname.new(commit_message_path).relative_path_from(Pathname.pwd)
|
133
132
|
|
134
133
|
puts
|
135
134
|
puts 'A commit message that describes the conversion summary was generated to'.color(:cyan)
|
136
|
-
puts
|
135
|
+
puts "#{commit_message_path}. To use the message, type the following command for".color(:cyan)
|
137
136
|
puts 'the next commit:'.color(:cyan)
|
138
137
|
puts ' git commit -aeF .git/COMMIT_EDITMSG'
|
139
138
|
end
|
data/lib/transpec/config.rb
CHANGED
@@ -20,8 +20,8 @@ module Transpec
|
|
20
20
|
[:convert_hook_scope, false],
|
21
21
|
[:convert_stub_with_hash_to_allow_to_receive_and_return, false],
|
22
22
|
[:skip_dynamic_analysis, false],
|
23
|
+
[:add_explicit_type_metadata_to_example_group, false],
|
23
24
|
[:add_receiver_arg_to_any_instance_implementation_block, true],
|
24
|
-
[:add_explicit_type_metadata_to_example_group, true],
|
25
25
|
[:parenthesize_matcher_arg, true]
|
26
26
|
].freeze
|
27
27
|
|
data/lib/transpec/converter.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'transpec/base_rewriter'
|
4
4
|
require 'transpec/config'
|
5
|
+
require 'transpec/project'
|
5
6
|
require 'transpec/report'
|
6
|
-
require 'transpec/rspec_version'
|
7
7
|
require 'transpec/spec_suite'
|
8
8
|
require 'transpec/syntax'
|
9
9
|
|
@@ -13,16 +13,16 @@ module Transpec
|
|
13
13
|
class Converter < BaseRewriter # rubocop:disable ClassLength
|
14
14
|
include Syntax::Dispatcher
|
15
15
|
|
16
|
-
attr_reader :spec_suite, :
|
16
|
+
attr_reader :spec_suite, :project, :config, :report
|
17
17
|
|
18
18
|
alias_method :convert_file!, :rewrite_file!
|
19
19
|
alias_method :convert_source, :rewrite_source
|
20
20
|
alias_method :convert, :rewrite
|
21
21
|
|
22
|
-
def initialize(spec_suite = nil,
|
22
|
+
def initialize(spec_suite = nil, project = nil, config = nil)
|
23
23
|
@spec_suite = spec_suite || SpecSuite.new
|
24
|
+
@project = project || Project.new
|
24
25
|
@config = config || Config.new
|
25
|
-
@rspec_version = rspec_version || Transpec.required_rspec_version
|
26
26
|
@report = Report.new
|
27
27
|
end
|
28
28
|
|
@@ -30,12 +30,16 @@ module Transpec
|
|
30
30
|
spec_suite.runtime_data
|
31
31
|
end
|
32
32
|
|
33
|
+
def rspec_version
|
34
|
+
project.rspec_version
|
35
|
+
end
|
36
|
+
|
33
37
|
def process(ast, source_rewriter)
|
34
38
|
return unless ast
|
35
39
|
|
36
40
|
ast.each_node do |node|
|
37
41
|
begin
|
38
|
-
dispatch_node(node,
|
42
|
+
dispatch_node(node, runtime_data, project, source_rewriter, report)
|
39
43
|
rescue ConversionError => error
|
40
44
|
report.conversion_errors << error
|
41
45
|
end
|
@@ -88,7 +92,7 @@ module Transpec
|
|
88
92
|
if !method_stub.hash_arg? ||
|
89
93
|
rspec_version.receive_messages_available? ||
|
90
94
|
config.convert_stub_with_hash_to_allow_to_receive_and_return?
|
91
|
-
method_stub.allowize!
|
95
|
+
method_stub.allowize!
|
92
96
|
elsif config.convert_deprecated_method?
|
93
97
|
method_stub.convert_deprecated_method!
|
94
98
|
end
|
@@ -166,7 +170,7 @@ module Transpec
|
|
166
170
|
|
167
171
|
def process_rspec_configure(rspec_configure)
|
168
172
|
if config.convert_deprecated_method?
|
169
|
-
rspec_configure.convert_deprecated_options!
|
173
|
+
rspec_configure.convert_deprecated_options!
|
170
174
|
end
|
171
175
|
|
172
176
|
if spec_suite.main_rspec_configure_node?(rspec_configure.node)
|
@@ -29,7 +29,7 @@ module Transpec
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def default_rspec_command
|
32
|
-
if project.
|
32
|
+
if project.using_bundler?
|
33
33
|
'bundle exec rspec'
|
34
34
|
else
|
35
35
|
'rspec'
|
@@ -76,7 +76,7 @@ module Transpec
|
|
76
76
|
def rewrite_specs(paths)
|
77
77
|
rewriter = Rewriter.new
|
78
78
|
|
79
|
-
spec_suite = SpecSuite.new(paths)
|
79
|
+
spec_suite = SpecSuite.new(project, paths)
|
80
80
|
|
81
81
|
spec_suite.specs.each do |spec|
|
82
82
|
next if spec.error
|
data/lib/transpec/git.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Transpec
|
4
4
|
module Git
|
5
5
|
GIT = 'git'
|
6
|
-
|
6
|
+
COMMIT_MESSAGE_FILENAME = 'COMMIT_EDITMSG'
|
7
7
|
|
8
8
|
module_function
|
9
9
|
|
@@ -24,15 +24,16 @@ module Transpec
|
|
24
24
|
`#{GIT} status --porcelain`.empty?
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def git_dir_path
|
28
28
|
fail_unless_inside_of_repository
|
29
|
-
`#{GIT} rev-parse --
|
29
|
+
`#{GIT} rev-parse --git-dir`.chomp
|
30
30
|
end
|
31
31
|
|
32
32
|
def write_commit_message(message)
|
33
33
|
fail_unless_inside_of_repository
|
34
|
-
file_path = File.join(
|
34
|
+
file_path = File.expand_path(File.join(git_dir_path, COMMIT_MESSAGE_FILENAME))
|
35
35
|
File.write(file_path, message)
|
36
|
+
file_path
|
36
37
|
end
|
37
38
|
|
38
39
|
def fail_unless_inside_of_repository
|
@@ -87,12 +87,12 @@ module Transpec
|
|
87
87
|
config.form_of_be_falsey = type.include?('falsy') ? 'be_falsy' : 'be_falsey'
|
88
88
|
end
|
89
89
|
|
90
|
-
define_option('-
|
91
|
-
config.
|
90
|
+
define_option('-e', '--explicit-spec-type') do
|
91
|
+
config.add_explicit_type_metadata_to_example_group = true
|
92
92
|
end
|
93
93
|
|
94
|
-
define_option('-
|
95
|
-
config.
|
94
|
+
define_option('-a', '--no-yield-any-instance') do
|
95
|
+
config.add_receiver_arg_to_any_instance_implementation_block = false
|
96
96
|
end
|
97
97
|
|
98
98
|
define_option('-p', '--no-parens-matcher-arg') do
|
@@ -173,14 +173,14 @@ module Transpec
|
|
173
173
|
' *true,false* (exact equality)',
|
174
174
|
'Default: *truthy,falsey*'
|
175
175
|
],
|
176
|
+
'-e' => [
|
177
|
+
'Add explicit `:type` metadata to example groups in a project using',
|
178
|
+
'rspec-rails.'
|
179
|
+
],
|
176
180
|
'-a' => [
|
177
181
|
'Suppress yielding receiver instances to `any_instance`',
|
178
182
|
'implementation blocks as the first block argument.'
|
179
183
|
],
|
180
|
-
'-t' => [
|
181
|
-
'Suppress adding explicit `:type` metadata to example groups in a',
|
182
|
-
'project using rspec-rails.'
|
183
|
-
],
|
184
184
|
'-p' => [
|
185
185
|
'Suppress parenthesizing arguments of matchers when converting',
|
186
186
|
'`should` with operator matcher to `expect` with non-operator matcher.',
|
@@ -1,12 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
require 'parser/ruby21'
|
8
|
-
Parser::CurrentRuby = Parser::Ruby21 # rubocop:disable ConstantName
|
9
|
-
end
|
3
|
+
original_verbose = $VERBOSE
|
4
|
+
$VERBOSE = nil
|
5
|
+
require 'parser/current'
|
6
|
+
$VERBOSE = original_verbose
|
10
7
|
|
11
8
|
require 'transpec/ast/builder'
|
12
9
|
|
data/lib/transpec/project.rb
CHANGED
@@ -15,9 +15,18 @@ module Transpec
|
|
15
15
|
File.basename(path)
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
18
|
+
def using_bundler?
|
19
|
+
File.exist?(gemfile_lock_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
def depend_on_rspec_rails?
|
23
|
+
return @depend_on_rspec_rails if instance_variable_defined?(:@depend_on_rspec_rails)
|
24
|
+
return @depend_on_rspec_rails = false unless using_bundler?
|
25
|
+
|
26
|
+
require 'bundler'
|
27
|
+
gemfile_lock_content = File.read(gemfile_lock_path)
|
28
|
+
lockfile = Bundler::LockfileParser.new(gemfile_lock_content)
|
29
|
+
@depend_on_rspec_rails = lockfile.specs.any? { |gem| gem.name == 'rspec-rails' }
|
21
30
|
end
|
22
31
|
|
23
32
|
def rspec_version
|
@@ -25,7 +34,7 @@ module Transpec
|
|
25
34
|
end
|
26
35
|
|
27
36
|
def with_bundler_clean_env
|
28
|
-
if defined?(Bundler) &&
|
37
|
+
if defined?(Bundler) && using_bundler?
|
29
38
|
Bundler.with_clean_env do
|
30
39
|
# Bundler.with_clean_env cleans environment variables
|
31
40
|
# which are set after bundler is loaded.
|
@@ -38,9 +47,13 @@ module Transpec
|
|
38
47
|
|
39
48
|
private
|
40
49
|
|
50
|
+
def gemfile_lock_path
|
51
|
+
@gemfile_lock_path ||= File.join(path, 'Gemfile.lock')
|
52
|
+
end
|
53
|
+
|
41
54
|
def fetch_rspec_version
|
42
55
|
command = 'rspec --version'
|
43
|
-
command = 'bundle exec ' + command if
|
56
|
+
command = 'bundle exec ' + command if using_bundler?
|
44
57
|
|
45
58
|
output = nil
|
46
59
|
|