transpec 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/Guardfile +18 -14
  4. data/README.md +1 -1
  5. data/README.md.erb +1 -1
  6. data/lib/transpec/cli.rb +2 -2
  7. data/lib/transpec/context_error.rb +23 -0
  8. data/lib/transpec/converter.rb +5 -5
  9. data/lib/transpec/dynamic_analyzer/rewriter.rb +1 -2
  10. data/lib/transpec/report.rb +5 -5
  11. data/lib/transpec/rspec_version.rb +10 -7
  12. data/lib/transpec/syntax.rb +76 -49
  13. data/lib/transpec/syntax/expect.rb +2 -6
  14. data/lib/transpec/syntax/have.rb +1 -2
  15. data/lib/transpec/syntax/its.rb +1 -1
  16. data/lib/transpec/syntax/method_stub.rb +29 -3
  17. data/lib/transpec/syntax/mixin/any_instance.rb +19 -18
  18. data/lib/transpec/syntax/mixin/have_matcher_owner.rb +35 -0
  19. data/lib/transpec/syntax/mixin/send.rb +33 -33
  20. data/lib/transpec/syntax/mixin/should_base.rb +22 -8
  21. data/lib/transpec/syntax/oneliner_should.rb +2 -7
  22. data/lib/transpec/syntax/operator_matcher.rb +4 -3
  23. data/lib/transpec/syntax/should.rb +4 -9
  24. data/lib/transpec/syntax/should_receive.rb +3 -5
  25. data/lib/transpec/version.rb +1 -1
  26. data/spec/support/shared_context.rb +2 -3
  27. data/spec/transpec/dynamic_analyzer/rewriter_spec.rb +1 -1
  28. data/spec/transpec/report_spec.rb +1 -2
  29. data/spec/transpec/rspec_version_spec.rb +7 -1
  30. data/spec/transpec/syntax/double_spec.rb +4 -4
  31. data/spec/transpec/syntax/example_spec.rb +1 -1
  32. data/spec/transpec/syntax/method_stub_spec.rb +65 -11
  33. data/spec/transpec/syntax/should_receive_spec.rb +14 -14
  34. data/spec/transpec/syntax/should_spec.rb +10 -10
  35. data/transpec.gemspec +2 -2
  36. metadata +6 -5
  37. 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.invalid_context_errors <<
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', true],
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 '.target_node?' do
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.target_node?(send_node).should be_true
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.target_node?(send_node).should be_true
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.target_node?(send_node, runtime_data).should be_false
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.target_node?(node)
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 '.target_node?' do
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.target_node?(send_node).should be_true
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.target_node?(send_node, runtime_data).should be_true
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.target_node?(send_node, runtime_data).should be_false
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 InvalidContextError' do
212
+ it 'raises ContextError' do
159
213
  -> { method_stub_object.allowize!(rspec_version) }
160
- .should raise_error(InvalidContextError)
214
+ .should raise_error(ContextError)
161
215
  end
162
216
  end
163
217
 
164
218
  context 'without runtime information' do
165
- it 'raises InvalidContextError' do
219
+ it 'raises ContextError' do
166
220
  -> { method_stub_object.allowize!(rspec_version) }
167
- .should raise_error(InvalidContextError)
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 InvalidContextError' do
244
+ it 'raises ContextError' do
191
245
  -> { method_stub_object.allowize!(rspec_version) }
192
- .should raise_error(InvalidContextError)
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 InvalidContextError' do
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 InvalidContextError' do
108
- -> { should_receive_object.expectize! }.should raise_error(InvalidContextError)
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 InvalidContextError' do
114
- -> { should_receive_object.expectize! }.should raise_error(InvalidContextError)
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 InvalidContextError' do
142
- -> { should_receive_object.expectize! }.should raise_error(InvalidContextError)
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 InvalidContextError' do
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 InvalidContextError' do
684
+ it 'raises ContextError' do
685
685
  -> { should_receive_object.allowize_useless_expectation! }
686
- .should raise_error(InvalidContextError)
686
+ .should raise_error(ContextError)
687
687
  end
688
688
  end
689
689
 
690
690
  context 'without runtime information' do
691
- it 'raises InvalidContextError' do
691
+ it 'raises ContextError' do
692
692
  -> { should_receive_object.allowize_useless_expectation! }
693
- .should raise_error(InvalidContextError)
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 InvalidContextError' do
716
+ it 'raises ContextError' do
717
717
  -> { should_receive_object.allowize_useless_expectation! }
718
- .should raise_error(InvalidContextError)
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 InvalidContextError' do
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 InvalidContextError' do
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 InvalidContextError' do
260
- -> { should_object.expectize! }.should raise_error(InvalidContextError)
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 InvalidContextError' do
287
- -> { should_object.expectize! }.should raise_error(InvalidContextError)
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 InvalidContextError' do
293
- -> { should_object.expectize! }.should raise_error(InvalidContextError)
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 InvalidContextError' do
317
- -> { should_object.expectize! }.should raise_error(InvalidContextError)
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 InvalidContextError' do
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 = 'An RSpec syntax converter'
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 = 'https://github.com/yujinakayama/transpec'
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.0
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-06 00:00:00.000000000 Z
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/have_matcher.rb
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: https://github.com/yujinakayama/transpec
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: An RSpec syntax converter
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