transpec 2.3.6 → 2.3.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef34fe1049f37464615658931a9e8749da6b3a71
4
- data.tar.gz: 1aac984a22901c935e382ee51091fb018107e318
3
+ metadata.gz: 6ce681149f6777fb46a239bcee88f92b42523600
4
+ data.tar.gz: 1536c4975b64ec6168e53ec1dffd4b315abe329e
5
5
  SHA512:
6
- metadata.gz: b9dca048b790a0a7c28dffb238450cc79c952104e887ce046ef3b7ecec621a4c79582a13a70f45f1200257795a5c1ab8c8f3ca09f2d8da77457bd71dfc14af57
7
- data.tar.gz: a86b56beed1896c16b6b197510e9ccf53802daf4b5c295cac426a51ae49b407c238f438dae76e0d51fe2caa4ddc6f1d0347f28a62d9f919df5140f35f5c3ebf9
6
+ metadata.gz: b5d797314a4304bf65be434947f3408cdeccb68379ce7696539854788b4f92cede514bed025c5d8f1876302b5535a2987186d136ca3c357f923f064c2bdd24a6
7
+ data.tar.gz: cd41e8284cb963cfd971fb64b05d5ca6988b406da92836ab6719ee675c3b955a47843edcb7a45b83a0399896218b90cbdb3d21ddb5a20169795f3c2de30d4b7d
data/.rubocop.yml CHANGED
@@ -15,6 +15,9 @@ MethodLength:
15
15
  CyclomaticComplexity:
16
16
  Max: 8
17
17
 
18
+ PerceivedComplexity:
19
+ Max: 10
20
+
18
21
  WordArray:
19
22
  Enabled: false
20
23
 
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Development
4
4
 
5
+ ## v2.3.7
6
+
7
+ * Fix a bug where nested example groups in `RSpec.describe` are wrongly converted to non-monkey-patch form when dynamic analysis is skipped. ([#89](https://github.com/yujinakayama/transpec/issues/89))
8
+
5
9
  ## v2.3.6
6
10
 
7
11
  * Fix error `Unresolved dependency found during sorting - parser` on `gem install transpec`.
data/README.md CHANGED
@@ -292,7 +292,12 @@ See [Supported Conversions - Method stubs with a hash argument](#method-stubs-wi
292
292
 
293
293
  ### `-s/--skip-dynamic-analysis`
294
294
 
295
- Skip dynamic analysis and convert with only static analysis. Note that specifying this option decreases the conversion accuracy especially in the conversion of [`have(n).items` matcher](#havenitems-matcher).
295
+ Skip dynamic analysis and convert with only static analysis.
296
+ The use of this option is basically **discouraged**
297
+ since it significantly decreases the overall conversion accuracy.
298
+
299
+ This would be useful only if your spec suite takes really long (like an hour) to run
300
+ and you prefer a combination of the rough but fast conversion by Transpec and manual fixes after that.
296
301
 
297
302
  ### `-n/--negative-form`
298
303
 
data/README.md.erb CHANGED
@@ -280,7 +280,12 @@ See [Supported Conversions - Method stubs with a hash argument](#method-stubs-wi
280
280
 
281
281
  ### `-s/--skip-dynamic-analysis`
282
282
 
283
- Skip dynamic analysis and convert with only static analysis. Note that specifying this option decreases the conversion accuracy especially in the conversion of [`have(n).items` matcher](#havenitems-matcher).
283
+ Skip dynamic analysis and convert with only static analysis.
284
+ The use of this option is basically **discouraged**
285
+ since it significantly decreases the overall conversion accuracy.
286
+
287
+ This would be useful only if your spec suite takes really long (like an hour) to run
288
+ and you prefer a combination of the rough but fast conversion by Transpec and manual fixes after that.
284
289
 
285
290
  ### `-n/--negative-form`
286
291
 
@@ -1,5 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
+ require 'transpec/dynamic_analyzer/constants'
3
4
  require 'transpec/dynamic_analyzer/rewriter'
4
5
  require 'transpec/dynamic_analyzer/runtime_data'
5
6
  require 'transpec/directory_cloner'
@@ -12,12 +13,6 @@ require 'English'
12
13
 
13
14
  module Transpec
14
15
  class DynamicAnalyzer
15
- ANALYSIS_MODULE = 'Transpec'
16
- ANALYSIS_METHOD = 'analyze'
17
- RUNTIME_DATA_ERROR_MESSAGE_KEY = :error_message
18
- HELPER_TEMPLATE_FILE = 'transpec_analysis_helper.rb.erb'
19
- RESULT_FILE = 'transpec_analysis_result.json'
20
-
21
16
  attr_reader :project, :rspec_command, :silent
22
17
  alias_method :silent?, :silent
23
18
 
@@ -0,0 +1,11 @@
1
+ # coding: utf-8
2
+
3
+ module Transpec
4
+ class DynamicAnalyzer
5
+ ANALYSIS_MODULE = 'Transpec'
6
+ ANALYSIS_METHOD = 'analyze'
7
+ RUNTIME_DATA_ERROR_MESSAGE_KEY = :error_message
8
+ HELPER_TEMPLATE_FILE = 'transpec_analysis_helper.rb.erb'
9
+ RESULT_FILE = 'transpec_analysis_result.json'
10
+ end
11
+ end
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
 
3
3
  require 'transpec/base_rewriter'
4
- require 'transpec/dynamic_analyzer'
4
+ require 'transpec/dynamic_analyzer/constants'
5
5
  require 'transpec/dynamic_analyzer/node_util'
6
6
  require 'transpec/util'
7
7
  require 'transpec/syntax'
@@ -1,5 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
+ require 'transpec/dynamic_analyzer/constants'
3
4
  require 'transpec/dynamic_analyzer/node_util'
4
5
  require 'json'
5
6
  require 'ostruct'
@@ -129,8 +129,9 @@ module Transpec
129
129
  'Force processing even if the current Git repository is not clean.'
130
130
  ],
131
131
  '-s' => [
132
- 'Skip dynamic analysis and convert with only static analysis. Note',
133
- 'that specifying this option decreases the conversion accuracy.'
132
+ 'Skip dynamic analysis and convert with only static analysis. The',
133
+ 'use of this option is basically *discouraged* since it',
134
+ 'significantly decreases the overall conversion accuracy.'
134
135
  ],
135
136
  '-c' => [
136
137
  'Specify a command to run your specs that is used for dynamic',
@@ -3,7 +3,7 @@
3
3
  require 'find'
4
4
 
5
5
  module Transpec
6
- module FileFinder
6
+ module SpecFileFinder
7
7
  module_function
8
8
 
9
9
  def find(paths)
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'transpec/file_finder'
4
3
  require 'transpec/processed_source'
4
+ require 'transpec/spec_file_finder'
5
5
  require 'transpec/syntax'
6
6
 
7
7
  Transpec::Syntax.require_all
@@ -19,7 +19,7 @@ module Transpec
19
19
  end
20
20
 
21
21
  def specs
22
- @specs ||= FileFinder.find(@base_paths).map do |path|
22
+ @specs ||= SpecFileFinder.find(@base_paths).map do |path|
23
23
  ProcessedSource.from_file(path)
24
24
  end
25
25
  end
@@ -68,7 +68,7 @@ module Transpec
68
68
  def valid_ancestor_nodes
69
69
  valid_nodes = []
70
70
 
71
- self_and_ancestor_nodes = [node] + node.each_ancestor.to_a
71
+ self_and_ancestor_nodes = [node] + node.ancestors
72
72
 
73
73
  self_and_ancestor_nodes.each_cons(2) do |child, parent|
74
74
  valid_nodes << parent unless belong_to_direct_outer_scope?(child)
@@ -101,12 +101,19 @@ module Transpec
101
101
  end
102
102
  end
103
103
 
104
- def special_block_type(block_node)
104
+ def special_block_type(block_node) # rubocop:disable MethodLength, CyclomaticComplexity
105
105
  send_node = block_node.children.first
106
106
  receiver_node, method_name, *_ = *send_node
107
107
 
108
- if const_name(receiver_node) == 'RSpec' && method_name == :configure
109
- :rspec_configure
108
+ if const_name(receiver_node) == 'RSpec'
109
+ case method_name
110
+ when :configure
111
+ :rspec_configure
112
+ when *EXAMPLE_GROUP_METHODS
113
+ :example_group
114
+ else
115
+ nil
116
+ end
110
117
  elsif HOOK_METHODS.include?(method_name)
111
118
  hook_type(send_node)
112
119
  elsif receiver_node
@@ -5,7 +5,7 @@ module Transpec
5
5
  module Version
6
6
  MAJOR = 2
7
7
  MINOR = 3
8
- PATCH = 6
8
+ PATCH = 7
9
9
 
10
10
  def self.to_s
11
11
  [MAJOR, MINOR, PATCH].join('.')
@@ -1,10 +1,10 @@
1
1
  # coding: utf-8
2
2
 
3
3
  require 'spec_helper'
4
- require 'transpec/file_finder'
4
+ require 'transpec/spec_file_finder'
5
5
 
6
6
  module Transpec
7
- describe FileFinder do
7
+ describe SpecFileFinder do
8
8
  include FileHelper
9
9
 
10
10
  describe '.find' do
@@ -16,7 +16,7 @@ module Transpec
16
16
  end
17
17
  end
18
18
 
19
- subject { FileFinder.find(paths) }
19
+ subject { SpecFileFinder.find(paths) }
20
20
 
21
21
  context 'when no path is passed' do
22
22
  let(:paths) { [] }
@@ -33,7 +33,7 @@ module Transpec
33
33
 
34
34
  context 'and there is not "spec" directory' do
35
35
  it 'raises error' do
36
- -> { FileFinder.find(paths) }.should raise_error(ArgumentError)
36
+ -> { SpecFileFinder.find(paths) }.should raise_error(ArgumentError)
37
37
  end
38
38
  end
39
39
  end
@@ -58,7 +58,7 @@ module Transpec
58
58
  let(:paths) { ['non-existent-file'] }
59
59
 
60
60
  it 'raises error' do
61
- -> { FileFinder.find(paths) }.should raise_error(ArgumentError) { |error|
61
+ -> { SpecFileFinder.find(paths) }.should raise_error(ArgumentError) { |error|
62
62
  error.message.should == 'No such file or directory "non-existent-file"'
63
63
  }
64
64
  end
@@ -76,7 +76,7 @@ module Transpec
76
76
  describe '.base_paths' do
77
77
  include_context 'isolated environment'
78
78
 
79
- subject { FileFinder.base_paths(paths) }
79
+ subject { SpecFileFinder.base_paths(paths) }
80
80
 
81
81
  context 'when target paths are specified' do
82
82
  let(:paths) { ['foo_spec.rb', 'spec/bar_spec.rb'] }
@@ -90,7 +90,7 @@ module Transpec
90
90
  let(:paths) { ['../foo_spec.rb', 'spec/bar_spec.rb'] }
91
91
 
92
92
  it 'raises error' do
93
- -> { FileFinder.base_paths(paths) }.should raise_error(ArgumentError)
93
+ -> { SpecFileFinder.base_paths(paths) }.should raise_error(ArgumentError)
94
94
  end
95
95
  end
96
96
 
@@ -109,7 +109,7 @@ module Transpec
109
109
 
110
110
  context 'and there is not "spec" directory' do
111
111
  it 'raises error' do
112
- -> { FileFinder.base_paths(paths) }.should raise_error(ArgumentError)
112
+ -> { SpecFileFinder.base_paths(paths) }.should raise_error(ArgumentError)
113
113
  end
114
114
  end
115
115
  end
@@ -49,6 +49,10 @@ module Transpec
49
49
  end
50
50
  end
51
51
 
52
+ RSpec.describe 'something' do
53
+ in_rspec_describe
54
+ end
55
+
52
56
  feature 'Capybara DSL' do
53
57
  background do
54
58
  in_background
@@ -118,6 +122,10 @@ module Transpec
118
122
  'send nil :in_block',
119
123
  'in normal block in #describe in module',
120
124
  [:module]
125
+ ], [
126
+ 'send nil :in_rspec_describe',
127
+ 'in RSpec.describe',
128
+ [:example_group]
121
129
  ], [
122
130
  'send nil :in_background',
123
131
  'in #background block in #feature',
@@ -126,6 +126,33 @@ module Transpec
126
126
  end
127
127
  end
128
128
 
129
+ context 'when the #describe is in another RSpec.describe' do
130
+ include_context 'multiple #describes'
131
+
132
+ let(:source) do
133
+ <<-END
134
+ RSpec.describe 'something' do
135
+ describe '#some_method' do
136
+ end
137
+ end
138
+ END
139
+ end
140
+
141
+ context 'without runtime information' do
142
+ it 'does nothing' do
143
+ rewritten_source.should == source
144
+ end
145
+ end
146
+
147
+ context 'with runtime information' do
148
+ include_context 'dynamic analysis objects'
149
+
150
+ it 'does nothing' do
151
+ rewritten_source.should == source
152
+ end
153
+ end
154
+ end
155
+
129
156
  context 'when logical-inner #describe is placed outside of the outer #describe in source' do
130
157
  include_context 'multiple #describes'
131
158
 
data/transpec.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.required_ruby_version = '>= 1.9.3'
24
24
 
25
25
  spec.add_runtime_dependency 'parser', '>= 2.2.0.pre.3', '< 3.0'
26
- spec.add_runtime_dependency 'astrolabe', '>= 0.6', '< 0.7'
26
+ spec.add_runtime_dependency 'astrolabe', '~> 1.2'
27
27
  spec.add_runtime_dependency 'bundler', '~> 1.3'
28
28
  spec.add_runtime_dependency 'rainbow', '>= 1.99.1', '< 3.0'
29
29
  spec.add_runtime_dependency 'json', '~> 1.8'
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.6
4
+ version: 2.3.7
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-07-18 00:00:00.000000000 Z
11
+ date: 2014-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -34,22 +34,16 @@ dependencies:
34
34
  name: astrolabe
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: '0.6'
40
- - - "<"
37
+ - - "~>"
41
38
  - !ruby/object:Gem::Version
42
- version: '0.7'
39
+ version: '1.2'
43
40
  type: :runtime
44
41
  prerelease: false
45
42
  version_requirements: !ruby/object:Gem::Requirement
46
43
  requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: '0.6'
50
- - - "<"
44
+ - - "~>"
51
45
  - !ruby/object:Gem::Version
52
- version: '0.7'
46
+ version: '1.2'
53
47
  - !ruby/object:Gem::Dependency
54
48
  name: bundler
55
49
  requirement: !ruby/object:Gem::Requirement
@@ -283,11 +277,11 @@ files:
283
277
  - lib/transpec/converter.rb
284
278
  - lib/transpec/directory_cloner.rb
285
279
  - lib/transpec/dynamic_analyzer.rb
280
+ - lib/transpec/dynamic_analyzer/constants.rb
286
281
  - lib/transpec/dynamic_analyzer/node_util.rb
287
282
  - lib/transpec/dynamic_analyzer/rewriter.rb
288
283
  - lib/transpec/dynamic_analyzer/runtime_data.rb
289
284
  - lib/transpec/dynamic_analyzer/transpec_analysis_helper.rb.erb
290
- - lib/transpec/file_finder.rb
291
285
  - lib/transpec/git.rb
292
286
  - lib/transpec/option_parser.rb
293
287
  - lib/transpec/processed_source.rb
@@ -296,6 +290,7 @@ files:
296
290
  - lib/transpec/report.rb
297
291
  - lib/transpec/rspec_dsl.rb
298
292
  - lib/transpec/rspec_version.rb
293
+ - lib/transpec/spec_file_finder.rb
299
294
  - lib/transpec/spec_suite.rb
300
295
  - lib/transpec/static_context_inspector.rb
301
296
  - lib/transpec/syntax.rb
@@ -360,7 +355,6 @@ files:
360
355
  - spec/transpec/directory_cloner_spec.rb
361
356
  - spec/transpec/dynamic_analyzer/rewriter_spec.rb
362
357
  - spec/transpec/dynamic_analyzer_spec.rb
363
- - spec/transpec/file_finder_spec.rb
364
358
  - spec/transpec/git_spec.rb
365
359
  - spec/transpec/option_parser_spec.rb
366
360
  - spec/transpec/processed_source_spec.rb
@@ -368,6 +362,7 @@ files:
368
362
  - spec/transpec/record_spec.rb
369
363
  - spec/transpec/report_spec.rb
370
364
  - spec/transpec/rspec_version_spec.rb
365
+ - spec/transpec/spec_file_finder_spec.rb
371
366
  - spec/transpec/spec_suite_spec.rb
372
367
  - spec/transpec/static_context_inspector_spec.rb
373
368
  - spec/transpec/syntax/allow_spec.rb
@@ -444,7 +439,6 @@ test_files:
444
439
  - spec/transpec/directory_cloner_spec.rb
445
440
  - spec/transpec/dynamic_analyzer/rewriter_spec.rb
446
441
  - spec/transpec/dynamic_analyzer_spec.rb
447
- - spec/transpec/file_finder_spec.rb
448
442
  - spec/transpec/git_spec.rb
449
443
  - spec/transpec/option_parser_spec.rb
450
444
  - spec/transpec/processed_source_spec.rb
@@ -452,6 +446,7 @@ test_files:
452
446
  - spec/transpec/record_spec.rb
453
447
  - spec/transpec/report_spec.rb
454
448
  - spec/transpec/rspec_version_spec.rb
449
+ - spec/transpec/spec_file_finder_spec.rb
455
450
  - spec/transpec/spec_suite_spec.rb
456
451
  - spec/transpec/static_context_inspector_spec.rb
457
452
  - spec/transpec/syntax/allow_spec.rb