transpec 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Guardfile +18 -14
- data/README.md +1 -1
- data/README.md.erb +1 -1
- data/lib/transpec/cli.rb +2 -2
- data/lib/transpec/context_error.rb +23 -0
- data/lib/transpec/converter.rb +5 -5
- data/lib/transpec/dynamic_analyzer/rewriter.rb +1 -2
- data/lib/transpec/report.rb +5 -5
- data/lib/transpec/rspec_version.rb +10 -7
- data/lib/transpec/syntax.rb +76 -49
- data/lib/transpec/syntax/expect.rb +2 -6
- data/lib/transpec/syntax/have.rb +1 -2
- data/lib/transpec/syntax/its.rb +1 -1
- data/lib/transpec/syntax/method_stub.rb +29 -3
- data/lib/transpec/syntax/mixin/any_instance.rb +19 -18
- data/lib/transpec/syntax/mixin/have_matcher_owner.rb +35 -0
- data/lib/transpec/syntax/mixin/send.rb +33 -33
- data/lib/transpec/syntax/mixin/should_base.rb +22 -8
- data/lib/transpec/syntax/oneliner_should.rb +2 -7
- data/lib/transpec/syntax/operator_matcher.rb +4 -3
- data/lib/transpec/syntax/should.rb +4 -9
- data/lib/transpec/syntax/should_receive.rb +3 -5
- data/lib/transpec/version.rb +1 -1
- data/spec/support/shared_context.rb +2 -3
- data/spec/transpec/dynamic_analyzer/rewriter_spec.rb +1 -1
- data/spec/transpec/report_spec.rb +1 -2
- data/spec/transpec/rspec_version_spec.rb +7 -1
- data/spec/transpec/syntax/double_spec.rb +4 -4
- data/spec/transpec/syntax/example_spec.rb +1 -1
- data/spec/transpec/syntax/method_stub_spec.rb +65 -11
- data/spec/transpec/syntax/should_receive_spec.rb +14 -14
- data/spec/transpec/syntax/should_spec.rb +10 -10
- data/transpec.gemspec +2 -2
- metadata +6 -5
- data/lib/transpec/syntax/mixin/have_matcher.rb +0 -23
@@ -57,7 +57,7 @@ module Transpec
|
|
57
57
|
<<-END
|
58
58
|
describe 'example' do
|
59
59
|
it 'matches to foo' do
|
60
|
-
transpec_analysis((transpec_analysis((subject), self, { :should_source_location => [:object, "method(:should).source_location"] }, __FILE__, 93, 100).should), self, { :expect_available? => [:context, "self.class.ancestors.any? { |a| a.name.start_with?('RSpec::') } && respond_to?(:expect)"] }, __FILE__, 93, 107) =~ transpec_analysis((<<-HEREDOC.gsub('foo', 'bar')
|
60
|
+
transpec_analysis((transpec_analysis((subject), self, { :should_source_location => [:object, "method(:should).source_location"] }, __FILE__, 93, 100).should), self, { :"=~_source_location" => [:object, "method(:=~).source_location"], :expect_available? => [:context, "self.class.ancestors.any? { |a| a.name.start_with?('RSpec::') } && respond_to?(:expect)"] }, __FILE__, 93, 107) =~ transpec_analysis((<<-HEREDOC.gsub('foo', 'bar')
|
61
61
|
foo
|
62
62
|
HEREDOC
|
63
63
|
), self, { :arg_is_enumerable? => [:object, "is_a?(Enumerable)"] }, __FILE__, 111, 188)
|
@@ -13,8 +13,7 @@ module Transpec
|
|
13
13
|
report.records << Record.new('obj.stub(:message)', 'allow(obj).to receive(:message)')
|
14
14
|
report.records << Record.new('obj.should', 'expect(obj).to')
|
15
15
|
report.records << Record.new('obj.should', 'expect(obj).to')
|
16
|
-
report.
|
17
|
-
Syntax::InvalidContextError.new(double('range'), '#should', '#expect')
|
16
|
+
report.context_errors << ContextError.new(double('range'), '#should', '#expect')
|
18
17
|
end
|
19
18
|
|
20
19
|
describe '#unique_record_counts' do
|
@@ -27,8 +27,10 @@ module Transpec
|
|
27
27
|
include_examples 'feature availability', method, [
|
28
28
|
['2.14.0', false],
|
29
29
|
['2.99.0.beta1', true],
|
30
|
+
['2.99.0.beta2', true],
|
30
31
|
['2.99.0', true],
|
31
32
|
['3.0.0.beta1', true],
|
33
|
+
['3.0.0.beta2', true],
|
32
34
|
['3.0.0', true]
|
33
35
|
]
|
34
36
|
end
|
@@ -39,7 +41,8 @@ module Transpec
|
|
39
41
|
['2.99.0.beta1', false],
|
40
42
|
['2.99.0.beta2', true],
|
41
43
|
['2.99.0', true],
|
42
|
-
['3.0.0.beta1',
|
44
|
+
['3.0.0.beta1', false],
|
45
|
+
['3.0.0.beta2', true],
|
43
46
|
['3.0.0', true]
|
44
47
|
]
|
45
48
|
end
|
@@ -48,8 +51,10 @@ module Transpec
|
|
48
51
|
include_examples 'feature availability', method, [
|
49
52
|
['2.14.0', false],
|
50
53
|
['2.99.0.beta1', false],
|
54
|
+
['2.99.0.beta2', false],
|
51
55
|
['2.99.0', false],
|
52
56
|
['3.0.0.beta1', true],
|
57
|
+
['3.0.0.beta2', true],
|
53
58
|
['3.0.0', true]
|
54
59
|
]
|
55
60
|
end
|
@@ -58,6 +63,7 @@ module Transpec
|
|
58
63
|
include_examples 'feature availability', method, [
|
59
64
|
['2.14.0', false],
|
60
65
|
['2.99.0.beta1', false],
|
66
|
+
['2.99.0.beta2', false],
|
61
67
|
['2.99.0', false],
|
62
68
|
['3.0.0.beta1', false],
|
63
69
|
['3.0.0.beta2', true],
|
@@ -9,7 +9,7 @@ module Transpec
|
|
9
9
|
include_context 'parsed objects'
|
10
10
|
include_context 'syntax object', Double, :double_object
|
11
11
|
|
12
|
-
describe '.
|
12
|
+
describe '.conversion_target_node?' do
|
13
13
|
let(:send_node) do
|
14
14
|
ast.each_descendent_node do |node|
|
15
15
|
next unless node.type == :send
|
@@ -33,7 +33,7 @@ module Transpec
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'returns true' do
|
36
|
-
Double.
|
36
|
+
Double.conversion_target_node?(send_node).should be_true
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -53,7 +53,7 @@ module Transpec
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'returns true' do
|
56
|
-
Double.
|
56
|
+
Double.conversion_target_node?(send_node).should be_true
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -88,7 +88,7 @@ module Transpec
|
|
88
88
|
end
|
89
89
|
|
90
90
|
it 'returns false' do
|
91
|
-
Double.
|
91
|
+
Double.conversion_target_node?(send_node, runtime_data).should be_false
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
@@ -159,7 +159,7 @@ module Transpec
|
|
159
159
|
|
160
160
|
let(:example_objects) do
|
161
161
|
ast.each_node.reduce([]) do |objects, node|
|
162
|
-
objects << Example.new(node, source_rewriter, runtime_data) if Example.
|
162
|
+
objects << Example.new(node, source_rewriter, runtime_data) if Example.conversion_target_node?(node)
|
163
163
|
objects
|
164
164
|
end
|
165
165
|
end
|
@@ -12,7 +12,7 @@ module Transpec
|
|
12
12
|
|
13
13
|
let(:record) { method_stub_object.report.records.first }
|
14
14
|
|
15
|
-
describe '.
|
15
|
+
describe '.conversion_target_node?' do
|
16
16
|
let(:send_node) do
|
17
17
|
ast.each_descendent_node do |node|
|
18
18
|
next unless node.type == :send
|
@@ -35,7 +35,23 @@ module Transpec
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'returns true' do
|
38
|
-
MethodStub.
|
38
|
+
MethodStub.conversion_target_node?(send_node).should be_true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when Factory.stub node is passed' do
|
43
|
+
let(:source) do
|
44
|
+
<<-END
|
45
|
+
describe 'example' do
|
46
|
+
it "is not RSpec's #stub" do
|
47
|
+
Factory.stub(:foo)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
END
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'returns false' do
|
54
|
+
MethodStub.conversion_target_node?(send_node).should be_false
|
39
55
|
end
|
40
56
|
end
|
41
57
|
|
@@ -54,7 +70,7 @@ module Transpec
|
|
54
70
|
end
|
55
71
|
|
56
72
|
it 'returns true' do
|
57
|
-
MethodStub.
|
73
|
+
MethodStub.conversion_target_node?(send_node, runtime_data).should be_true
|
58
74
|
end
|
59
75
|
end
|
60
76
|
|
@@ -75,7 +91,45 @@ module Transpec
|
|
75
91
|
end
|
76
92
|
|
77
93
|
it 'returns false' do
|
78
|
-
MethodStub.
|
94
|
+
MethodStub.conversion_target_node?(send_node, runtime_data).should be_false
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "when Factory.stub node is passed and it's RSpec's #stub" do
|
99
|
+
let(:source) do
|
100
|
+
<<-END
|
101
|
+
module Factory
|
102
|
+
end
|
103
|
+
|
104
|
+
describe 'example' do
|
105
|
+
it 'responds to #foo' do
|
106
|
+
Factory.stub(:foo)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
END
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'returns true' do
|
113
|
+
MethodStub.conversion_target_node?(send_node, runtime_data).should be_true
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'when Factory.stub node is passed and it has not been run' do
|
118
|
+
let(:source) do
|
119
|
+
<<-END
|
120
|
+
module Factory
|
121
|
+
end
|
122
|
+
|
123
|
+
describe 'example' do
|
124
|
+
it 'responds to #foo' do
|
125
|
+
true || Factory.stub(:foo)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
END
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'returns false' do
|
132
|
+
MethodStub.conversion_target_node?(send_node, runtime_data).should be_false
|
79
133
|
end
|
80
134
|
end
|
81
135
|
end
|
@@ -155,16 +209,16 @@ module Transpec
|
|
155
209
|
context 'with runtime information' do
|
156
210
|
include_context 'dynamic analysis objects'
|
157
211
|
|
158
|
-
it 'raises
|
212
|
+
it 'raises ContextError' do
|
159
213
|
-> { method_stub_object.allowize!(rspec_version) }
|
160
|
-
.should raise_error(
|
214
|
+
.should raise_error(ContextError)
|
161
215
|
end
|
162
216
|
end
|
163
217
|
|
164
218
|
context 'without runtime information' do
|
165
|
-
it 'raises
|
219
|
+
it 'raises ContextError' do
|
166
220
|
-> { method_stub_object.allowize!(rspec_version) }
|
167
|
-
.should raise_error(
|
221
|
+
.should raise_error(ContextError)
|
168
222
|
end
|
169
223
|
end
|
170
224
|
end
|
@@ -187,14 +241,14 @@ module Transpec
|
|
187
241
|
context 'with runtime information' do
|
188
242
|
include_context 'dynamic analysis objects'
|
189
243
|
|
190
|
-
it 'raises
|
244
|
+
it 'raises ContextError' do
|
191
245
|
-> { method_stub_object.allowize!(rspec_version) }
|
192
|
-
.should raise_error(
|
246
|
+
.should raise_error(ContextError)
|
193
247
|
end
|
194
248
|
end
|
195
249
|
|
196
250
|
context 'without runtime information' do
|
197
|
-
it 'does not raise
|
251
|
+
it 'does not raise ContextError' do
|
198
252
|
-> { method_stub_object.allowize!(rspec_version) }
|
199
253
|
.should_not raise_error
|
200
254
|
end
|
@@ -104,14 +104,14 @@ module Transpec
|
|
104
104
|
context 'with runtime information' do
|
105
105
|
include_context 'dynamic analysis objects'
|
106
106
|
|
107
|
-
it 'raises
|
108
|
-
-> { should_receive_object.expectize! }.should raise_error(
|
107
|
+
it 'raises ContextError' do
|
108
|
+
-> { should_receive_object.expectize! }.should raise_error(ContextError)
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
112
|
context 'without runtime information' do
|
113
|
-
it 'raises
|
114
|
-
-> { should_receive_object.expectize! }.should raise_error(
|
113
|
+
it 'raises ContextError' do
|
114
|
+
-> { should_receive_object.expectize! }.should raise_error(ContextError)
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
@@ -138,13 +138,13 @@ module Transpec
|
|
138
138
|
context 'with runtime information' do
|
139
139
|
include_context 'dynamic analysis objects'
|
140
140
|
|
141
|
-
it 'raises
|
142
|
-
-> { should_receive_object.expectize! }.should raise_error(
|
141
|
+
it 'raises ContextError' do
|
142
|
+
-> { should_receive_object.expectize! }.should raise_error(ContextError)
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
146
|
context 'without runtime information' do
|
147
|
-
it 'does not raise
|
147
|
+
it 'does not raise ContextError' do
|
148
148
|
-> { should_receive_object.expectize! }.should_not raise_error
|
149
149
|
end
|
150
150
|
end
|
@@ -681,16 +681,16 @@ module Transpec
|
|
681
681
|
context 'with runtime information' do
|
682
682
|
include_context 'dynamic analysis objects'
|
683
683
|
|
684
|
-
it 'raises
|
684
|
+
it 'raises ContextError' do
|
685
685
|
-> { should_receive_object.allowize_useless_expectation! }
|
686
|
-
.should raise_error(
|
686
|
+
.should raise_error(ContextError)
|
687
687
|
end
|
688
688
|
end
|
689
689
|
|
690
690
|
context 'without runtime information' do
|
691
|
-
it 'raises
|
691
|
+
it 'raises ContextError' do
|
692
692
|
-> { should_receive_object.allowize_useless_expectation! }
|
693
|
-
.should raise_error(
|
693
|
+
.should raise_error(ContextError)
|
694
694
|
end
|
695
695
|
end
|
696
696
|
end
|
@@ -713,14 +713,14 @@ module Transpec
|
|
713
713
|
context 'with runtime information' do
|
714
714
|
include_context 'dynamic analysis objects'
|
715
715
|
|
716
|
-
it 'raises
|
716
|
+
it 'raises ContextError' do
|
717
717
|
-> { should_receive_object.allowize_useless_expectation! }
|
718
|
-
.should raise_error(
|
718
|
+
.should raise_error(ContextError)
|
719
719
|
end
|
720
720
|
end
|
721
721
|
|
722
722
|
context 'without runtime information' do
|
723
|
-
it 'does not raise
|
723
|
+
it 'does not raise ContextError' do
|
724
724
|
-> { should_receive_object.allowize_useless_expectation! }
|
725
725
|
.should_not raise_error
|
726
726
|
end
|
@@ -250,14 +250,14 @@ module Transpec
|
|
250
250
|
context 'with runtime information' do
|
251
251
|
include_context 'dynamic analysis objects'
|
252
252
|
|
253
|
-
it 'does not raise
|
253
|
+
it 'does not raise ContextError' do
|
254
254
|
-> { should_object.expectize! }.should_not raise_error
|
255
255
|
end
|
256
256
|
end
|
257
257
|
|
258
258
|
context 'without runtime information' do
|
259
|
-
it 'raises
|
260
|
-
-> { should_object.expectize! }.should raise_error(
|
259
|
+
it 'raises ContextError' do
|
260
|
+
-> { should_object.expectize! }.should raise_error(ContextError)
|
261
261
|
end
|
262
262
|
end
|
263
263
|
end
|
@@ -283,14 +283,14 @@ module Transpec
|
|
283
283
|
context 'with runtime information' do
|
284
284
|
include_context 'dynamic analysis objects'
|
285
285
|
|
286
|
-
it 'raises
|
287
|
-
-> { should_object.expectize! }.should raise_error(
|
286
|
+
it 'raises ContextError' do
|
287
|
+
-> { should_object.expectize! }.should raise_error(ContextError)
|
288
288
|
end
|
289
289
|
end
|
290
290
|
|
291
291
|
context 'without runtime information' do
|
292
|
-
it 'raises
|
293
|
-
-> { should_object.expectize! }.should raise_error(
|
292
|
+
it 'raises ContextError' do
|
293
|
+
-> { should_object.expectize! }.should raise_error(ContextError)
|
294
294
|
end
|
295
295
|
end
|
296
296
|
end
|
@@ -313,13 +313,13 @@ module Transpec
|
|
313
313
|
context 'with runtime information' do
|
314
314
|
include_context 'dynamic analysis objects'
|
315
315
|
|
316
|
-
it 'raises
|
317
|
-
-> { should_object.expectize! }.should raise_error(
|
316
|
+
it 'raises ContextError' do
|
317
|
+
-> { should_object.expectize! }.should raise_error(ContextError)
|
318
318
|
end
|
319
319
|
end
|
320
320
|
|
321
321
|
context 'without runtime information' do
|
322
|
-
it 'does not raise
|
322
|
+
it 'does not raise ContextError' do
|
323
323
|
-> { should_object.expectize! }.should_not raise_error
|
324
324
|
end
|
325
325
|
end
|
data/transpec.gemspec
CHANGED
@@ -9,10 +9,10 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.version = Transpec::Version.to_s
|
10
10
|
spec.authors = ['Yuji Nakayama']
|
11
11
|
spec.email = ['nkymyj@gmail.com']
|
12
|
-
spec.summary = '
|
12
|
+
spec.summary = 'The RSpec syntax converter'
|
13
13
|
spec.description = 'Transpec converts your specs to the latest RSpec syntax ' +
|
14
14
|
'with static and dynamic code analysis.'
|
15
|
-
spec.homepage = '
|
15
|
+
spec.homepage = 'http://yujinakayama.me/transpec/'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
18
|
spec.files = `git ls-files`.split($/)
|
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: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuji Nakayama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -219,6 +219,7 @@ files:
|
|
219
219
|
- lib/transpec/cli.rb
|
220
220
|
- lib/transpec/commit_message.rb
|
221
221
|
- lib/transpec/configuration.rb
|
222
|
+
- lib/transpec/context_error.rb
|
222
223
|
- lib/transpec/converter.rb
|
223
224
|
- lib/transpec/dynamic_analyzer.rb
|
224
225
|
- lib/transpec/dynamic_analyzer/rewriter.rb
|
@@ -245,7 +246,7 @@ files:
|
|
245
246
|
- lib/transpec/syntax/mixin/allow_no_message.rb
|
246
247
|
- lib/transpec/syntax/mixin/any_instance.rb
|
247
248
|
- lib/transpec/syntax/mixin/expectizable.rb
|
248
|
-
- lib/transpec/syntax/mixin/
|
249
|
+
- lib/transpec/syntax/mixin/have_matcher_owner.rb
|
249
250
|
- lib/transpec/syntax/mixin/monkey_patch.rb
|
250
251
|
- lib/transpec/syntax/mixin/send.rb
|
251
252
|
- lib/transpec/syntax/mixin/should_base.rb
|
@@ -300,7 +301,7 @@ files:
|
|
300
301
|
- tasks/readme.rake
|
301
302
|
- tasks/test.rake
|
302
303
|
- transpec.gemspec
|
303
|
-
homepage:
|
304
|
+
homepage: http://yujinakayama.me/transpec/
|
304
305
|
licenses:
|
305
306
|
- MIT
|
306
307
|
metadata: {}
|
@@ -323,7 +324,7 @@ rubyforge_project:
|
|
323
324
|
rubygems_version: 2.0.14
|
324
325
|
signing_key:
|
325
326
|
specification_version: 4
|
326
|
-
summary:
|
327
|
+
summary: The RSpec syntax converter
|
327
328
|
test_files:
|
328
329
|
- spec/.rubocop.yml
|
329
330
|
- spec/spec_helper.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'transpec/syntax/have'
|
4
|
-
|
5
|
-
module Transpec
|
6
|
-
class Syntax
|
7
|
-
module Mixin
|
8
|
-
module HaveMatcher
|
9
|
-
def have_matcher
|
10
|
-
return @have_matcher if instance_variable_defined?(:@have_matcher)
|
11
|
-
|
12
|
-
@have_matcher ||= begin
|
13
|
-
if Have.target_node?(matcher_node, @runtime_data)
|
14
|
-
Have.new(matcher_node, self, @source_rewriter, @runtime_data, @report)
|
15
|
-
else
|
16
|
-
nil
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|