transpec 2.3.7 → 2.3.8
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 +3 -0
- data/CHANGELOG.md +4 -0
- data/README.md +1 -16
- data/README.md.erb +1 -16
- data/lib/transpec/converter.rb +1 -1
- data/lib/transpec/option_parser.rb +1 -1
- data/lib/transpec/syntax/oneliner_should.rb +22 -6
- data/lib/transpec/version.rb +1 -1
- data/spec/transpec/syntax/oneliner_should_spec.rb +36 -0
- 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: cb9406724bb6b0b2dd4a820087ce298134d0abbf
|
|
4
|
+
data.tar.gz: c9cd123d3c4a95f6f74cb536b8f0e614362defb9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 067c988d340e8d447ec75fafd9697d465651e7731c8b43fca3b76559139c16b0ee867bc57f3a06344df5127aff1af51e2ad8b3c5531d162729e705ddb2c00e50
|
|
7
|
+
data.tar.gz: 5b96068adbf78f05d7ca66faa64b6377248b51733114f916e2a67e92b9c47b3537d1f368de2dd369f7427fa4ab979509ac92fcb469972ef432246bbf9b8d39a2
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## Development
|
|
4
4
|
|
|
5
|
+
## v2.3.8
|
|
6
|
+
|
|
7
|
+
* Fix an error on processing one-liner `should` that is not directly encloses in an example block. ([#93](https://github.com/yujinakayama/transpec/issues/93))
|
|
8
|
+
|
|
5
9
|
## v2.3.7
|
|
6
10
|
|
|
7
11
|
* 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))
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
[](https://gemnasium.com/yujinakayama/transpec)
|
|
3
3
|
[](https://travis-ci.org/yujinakayama/transpec)
|
|
4
4
|
[](https://coveralls.io/r/yujinakayama/transpec)
|
|
5
|
-
[](https://codeclimate.com/github/yujinakayama/transpec)
|
|
6
6
|
|
|
7
7
|
# Transpec
|
|
8
8
|
|
|
@@ -128,21 +128,6 @@ Then, run `transpec` in the project root directory:
|
|
|
128
128
|
```bash
|
|
129
129
|
$ cd some-project
|
|
130
130
|
$ transpec
|
|
131
|
-
Copying the project for dynamic analysis...
|
|
132
|
-
Running dynamic analysis with command "bundle exec rspec"...
|
|
133
|
-
...............................................................................
|
|
134
|
-
...................
|
|
135
|
-
|
|
136
|
-
Finished in 13.07 seconds
|
|
137
|
-
100 examples, 0 failures
|
|
138
|
-
|
|
139
|
-
Gathering the spec suite data...
|
|
140
|
-
|
|
141
|
-
Converting spec/spec_helper.rb
|
|
142
|
-
Converting spec/support/cache_helper.rb
|
|
143
|
-
Converting spec/support/file_helper.rb
|
|
144
|
-
Converting spec/support/shared_context.rb
|
|
145
|
-
Converting spec/transpec/ast/node_spec.rb
|
|
146
131
|
```
|
|
147
132
|
|
|
148
133
|
This will run the specs, convert them, and overwrite all spec files in the `spec` directory.
|
data/README.md.erb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
[](https://gemnasium.com/yujinakayama/transpec)
|
|
3
3
|
[](https://travis-ci.org/yujinakayama/transpec)
|
|
4
4
|
[](https://coveralls.io/r/yujinakayama/transpec)
|
|
5
|
-
[](https://codeclimate.com/github/yujinakayama/transpec)
|
|
6
6
|
|
|
7
7
|
# Transpec
|
|
8
8
|
|
|
@@ -102,21 +102,6 @@ Then, run `transpec` in the project root directory:
|
|
|
102
102
|
```bash
|
|
103
103
|
$ cd some-project
|
|
104
104
|
$ transpec
|
|
105
|
-
Copying the project for dynamic analysis...
|
|
106
|
-
Running dynamic analysis with command "bundle exec rspec"...
|
|
107
|
-
...............................................................................
|
|
108
|
-
...................
|
|
109
|
-
|
|
110
|
-
Finished in 13.07 seconds
|
|
111
|
-
100 examples, 0 failures
|
|
112
|
-
|
|
113
|
-
Gathering the spec suite data...
|
|
114
|
-
|
|
115
|
-
Converting spec/spec_helper.rb
|
|
116
|
-
Converting spec/support/cache_helper.rb
|
|
117
|
-
Converting spec/support/file_helper.rb
|
|
118
|
-
Converting spec/support/shared_context.rb
|
|
119
|
-
Converting spec/transpec/ast/node_spec.rb
|
|
120
105
|
```
|
|
121
106
|
|
|
122
107
|
This will run the specs, convert them, and overwrite all spec files in the `spec` directory.
|
data/lib/transpec/converter.rb
CHANGED
|
@@ -102,7 +102,7 @@ module Transpec
|
|
|
102
102
|
def process_operator(operator)
|
|
103
103
|
return unless config.convert_should?
|
|
104
104
|
return if operator.expectation.is_a?(Syntax::OnelinerShould) &&
|
|
105
|
-
|
|
105
|
+
!rspec_version.oneliner_is_expected_available?
|
|
106
106
|
operator.convert_operator!(config.parenthesize_matcher_arg?)
|
|
107
107
|
end
|
|
108
108
|
|
|
@@ -204,7 +204,7 @@ module Transpec
|
|
|
204
204
|
|
|
205
205
|
def highlight_text(text)
|
|
206
206
|
text.gsub(/`.+?`/) { |code| code.gsub('`', '').underline }
|
|
207
|
-
|
|
207
|
+
.gsub(/\*.+?\*/) { |code| code.gsub('*', '').bright }
|
|
208
208
|
end
|
|
209
209
|
|
|
210
210
|
def convert_deprecated_options(raw_args)
|
|
@@ -111,6 +111,8 @@ module Transpec
|
|
|
111
111
|
fail 'This one-liner #should does not have #have matcher!'
|
|
112
112
|
end
|
|
113
113
|
|
|
114
|
+
return unless example
|
|
115
|
+
|
|
114
116
|
unless example.description?
|
|
115
117
|
example.insert_description!(build_description(have_matcher.size_source))
|
|
116
118
|
end
|
|
@@ -144,9 +146,9 @@ module Transpec
|
|
|
144
146
|
param_names :should, :have, :negative_form_of_to
|
|
145
147
|
|
|
146
148
|
def old_syntax
|
|
147
|
-
syntax =
|
|
149
|
+
syntax = had_description? ? "it '...' do" : 'it {'
|
|
148
150
|
syntax << " #{should.method_name} #{have.method_name}(n).#{old_items} "
|
|
149
|
-
syntax << (
|
|
151
|
+
syntax << (had_description? ? 'end' : '}')
|
|
150
152
|
end
|
|
151
153
|
|
|
152
154
|
def new_syntax
|
|
@@ -155,14 +157,19 @@ module Transpec
|
|
|
155
157
|
syntax << new_expectation
|
|
156
158
|
syntax << ' '
|
|
157
159
|
syntax << source_builder.replacement_matcher_source
|
|
158
|
-
syntax << '
|
|
160
|
+
syntax << ' '
|
|
161
|
+
syntax << (has_description? ? 'end' : '}')
|
|
159
162
|
end
|
|
160
163
|
|
|
161
164
|
def new_description
|
|
162
|
-
if
|
|
163
|
-
|
|
165
|
+
if has_description?
|
|
166
|
+
if had_description?
|
|
167
|
+
"it '...' do"
|
|
168
|
+
else
|
|
169
|
+
"it '#{should.build_description('n')}' do"
|
|
170
|
+
end
|
|
164
171
|
else
|
|
165
|
-
|
|
172
|
+
'it {'
|
|
166
173
|
end
|
|
167
174
|
end
|
|
168
175
|
|
|
@@ -178,6 +185,15 @@ module Transpec
|
|
|
178
185
|
def new_subject
|
|
179
186
|
build_new_subject('subject')
|
|
180
187
|
end
|
|
188
|
+
|
|
189
|
+
def had_description?
|
|
190
|
+
return false unless should.example
|
|
191
|
+
should.example.description?
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def has_description? # rubocop:disable PredicateName
|
|
195
|
+
!should.example.nil?
|
|
196
|
+
end
|
|
181
197
|
end
|
|
182
198
|
end
|
|
183
199
|
end
|
data/lib/transpec/version.rb
CHANGED
|
@@ -586,6 +586,42 @@ module Transpec
|
|
|
586
586
|
record.new_syntax.should == "it 'does not have n items' do expect(subject.size).not_to eq(n) end"
|
|
587
587
|
end
|
|
588
588
|
end
|
|
589
|
+
|
|
590
|
+
context 'when the oneliner #should is not directly enclosed in an example block' do
|
|
591
|
+
let(:source) do
|
|
592
|
+
<<-END
|
|
593
|
+
describe 'example' do
|
|
594
|
+
def some_method
|
|
595
|
+
should have(2).items
|
|
596
|
+
end
|
|
597
|
+
|
|
598
|
+
it { some_method }
|
|
599
|
+
end
|
|
600
|
+
END
|
|
601
|
+
end
|
|
602
|
+
|
|
603
|
+
let(:expected_source) do
|
|
604
|
+
<<-END
|
|
605
|
+
describe 'example' do
|
|
606
|
+
def some_method
|
|
607
|
+
expect(subject.size).to eq(2)
|
|
608
|
+
end
|
|
609
|
+
|
|
610
|
+
it { some_method }
|
|
611
|
+
end
|
|
612
|
+
END
|
|
613
|
+
end
|
|
614
|
+
|
|
615
|
+
it 'does not insert example description' do
|
|
616
|
+
rewritten_source.should == expected_source
|
|
617
|
+
end
|
|
618
|
+
|
|
619
|
+
it 'adds record ' \
|
|
620
|
+
'`it { should have(n).items }` -> `it { expect(subject.size).to eq(n) }`' do
|
|
621
|
+
record.old_syntax.should == 'it { should have(n).items }'
|
|
622
|
+
record.new_syntax.should == 'it { expect(subject.size).to eq(n) }'
|
|
623
|
+
end
|
|
624
|
+
end
|
|
589
625
|
end
|
|
590
626
|
end
|
|
591
627
|
end
|
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.
|
|
4
|
+
version: 2.3.8
|
|
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-11-11 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.
|
|
423
|
+
rubygems_version: 2.4.2
|
|
424
424
|
signing_key:
|
|
425
425
|
specification_version: 4
|
|
426
426
|
summary: The RSpec syntax converter
|