transpec 2.3.1 → 2.3.2

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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/CONTRIBUTING.md +1 -1
  4. data/Gemfile +0 -2
  5. data/README.md +13 -5
  6. data/README.md.erb +13 -5
  7. data/lib/transpec/ast/node.rb +2 -75
  8. data/lib/transpec/directory_cloner.rb +53 -0
  9. data/lib/transpec/dynamic_analyzer.rb +10 -50
  10. data/lib/transpec/record.rb +10 -1
  11. data/lib/transpec/rspec_dsl.rb +0 -2
  12. data/lib/transpec/static_context_inspector.rb +3 -3
  13. data/lib/transpec/syntax/current_example.rb +3 -8
  14. data/lib/transpec/syntax/example.rb +1 -1
  15. data/lib/transpec/syntax/example_group.rb +15 -11
  16. data/lib/transpec/syntax/have/dynamic_analysis.rb +0 -2
  17. data/lib/transpec/syntax/have/record_builder.rb +1 -5
  18. data/lib/transpec/syntax/its.rb +2 -6
  19. data/lib/transpec/syntax/method_stub.rb +6 -21
  20. data/lib/transpec/syntax/mixin/any_instance_block.rb +1 -5
  21. data/lib/transpec/syntax/mixin/expect_base.rb +1 -1
  22. data/lib/transpec/syntax/mixin/metadata.rb +10 -1
  23. data/lib/transpec/syntax/mixin/should_base.rb +4 -0
  24. data/lib/transpec/syntax/mixin/useless_and_return.rb +1 -5
  25. data/lib/transpec/syntax/oneliner_should.rb +4 -23
  26. data/lib/transpec/syntax/operator.rb +1 -1
  27. data/lib/transpec/syntax/raise_error.rb +1 -5
  28. data/lib/transpec/syntax/rspec_configure/config_modification.rb +2 -3
  29. data/lib/transpec/syntax/rspec_configure/framework.rb +2 -3
  30. data/lib/transpec/syntax/rspec_configure/mocks.rb +0 -4
  31. data/lib/transpec/syntax/rspec_configure.rb +0 -4
  32. data/lib/transpec/syntax/should.rb +1 -13
  33. data/lib/transpec/syntax/should_receive.rb +2 -11
  34. data/lib/transpec/syntax.rb +1 -1
  35. data/lib/transpec/util.rb +2 -3
  36. data/lib/transpec/version.rb +1 -1
  37. data/spec/transpec/directory_cloner_spec.rb +74 -0
  38. data/spec/transpec/dynamic_analyzer_spec.rb +0 -57
  39. data/spec/transpec/spec_suite_spec.rb +2 -2
  40. data/spec/transpec/static_context_inspector_spec.rb +0 -7
  41. data/spec/transpec/syntax/current_example_spec.rb +3 -6
  42. data/spec/transpec/syntax/double_spec.rb +3 -6
  43. data/spec/transpec/syntax/example_group_spec.rb +96 -1
  44. data/spec/transpec/syntax/example_spec.rb +3 -5
  45. data/spec/transpec/syntax/expect_spec.rb +3 -6
  46. data/spec/transpec/syntax/have_spec.rb +3 -5
  47. data/spec/transpec/syntax/its_spec.rb +3 -5
  48. data/spec/transpec/syntax/method_stub_spec.rb +3 -6
  49. data/spec/transpec/syntax/oneliner_should_spec.rb +3 -6
  50. data/spec/transpec/syntax/pending_spec.rb +3 -5
  51. data/transpec.gemspec +2 -1
  52. metadata +27 -6
  53. data/spec/transpec/ast/node_spec.rb +0 -323
@@ -21,6 +21,10 @@ module Transpec
21
21
  add_matcher RaiseError
22
22
  end
23
23
 
24
+ def current_syntax_type
25
+ @current_syntax_type ||= :should
26
+ end
27
+
24
28
  def positive?
25
29
  method_name == :should
26
30
  end
@@ -49,11 +49,7 @@ module Transpec
49
49
  end
50
50
 
51
51
  class RecordBuilder < Transpec::RecordBuilder
52
- attr_reader :host
53
-
54
- def initialize(host, *)
55
- @host = host
56
- end
52
+ param_names :host
57
53
 
58
54
  def old_syntax
59
55
  syntax = base_syntax
@@ -14,13 +14,6 @@ module Transpec
14
14
  class OnelinerShould < Syntax
15
15
  include Mixin::ShouldBase, RSpecDSL, Util
16
16
 
17
- attr_reader :current_syntax_type
18
-
19
- def initialize(*)
20
- super
21
- @current_syntax_type = :should
22
- end
23
-
24
17
  def dynamic_analysis_target?
25
18
  super && receiver_node.nil? && [:should, :should_not].include?(method_name)
26
19
  end
@@ -76,9 +69,8 @@ module Transpec
76
69
 
77
70
  @example = nil
78
71
 
79
- node.each_ancestor_node do |node|
80
- next unless node.block_type?
81
- send_node = node.children[0]
72
+ node.each_ancestor(:block) do |block_node|
73
+ send_node = block_node.children[0]
82
74
 
83
75
  found = Syntax.all_syntaxes.find do |syntax_class|
84
76
  next unless syntax_class.ancestors.include?(Mixin::Examplish)
@@ -133,12 +125,7 @@ module Transpec
133
125
  end
134
126
 
135
127
  class ExpectRecordBuilder < RecordBuilder
136
- attr_reader :should, :negative_form_of_to
137
-
138
- def initialize(should, negative_form_of_to = nil)
139
- @should = should
140
- @negative_form_of_to = negative_form_of_to
141
- end
128
+ param_names :should, :negative_form_of_to
142
129
 
143
130
  def old_syntax
144
131
  syntax = 'it { should'
@@ -154,13 +141,7 @@ module Transpec
154
141
  end
155
142
 
156
143
  class HaveRecordBuilder < Have::RecordBuilder
157
- attr_reader :should, :negative_form_of_to
158
-
159
- def initialize(should, have, negative_form_of_to = nil)
160
- super(have)
161
- @should = should
162
- @negative_form_of_to = negative_form_of_to
163
- end
144
+ param_names :should, :have, :negative_form_of_to
164
145
 
165
146
  def old_syntax
166
147
  syntax = should.example.description? ? "it '...' do" : 'it {'
@@ -23,7 +23,7 @@ module Transpec
23
23
 
24
24
  def initialize(node, expectation, source_rewriter = nil, runtime_data = nil, report = nil)
25
25
  operator_node = if node == BE_NODE
26
- node.parent_node
26
+ node.parent
27
27
  else
28
28
  node
29
29
  end
@@ -37,11 +37,7 @@ module Transpec
37
37
  end
38
38
 
39
39
  class RecordBuilder < Transpec::RecordBuilder
40
- attr_reader :raise_error
41
-
42
- def initialize(raise_error)
43
- @raise_error = raise_error
44
- end
40
+ param_names :raise_error
45
41
 
46
42
  def old_syntax
47
43
  syntax = 'expect { }.not_to raise_error('
@@ -32,9 +32,8 @@ module Transpec
32
32
 
33
33
  config_method_name = config_method_name.to_sym
34
34
 
35
- block_node.each_descendent_node.find do |node|
36
- next unless node.send_type?
37
- receiver_node, method_name, = *node
35
+ block_node.each_descendant(:send).find do |send_node|
36
+ receiver_node, method_name, = *send_node
38
37
  next unless receiver_node == s(:lvar, block_arg_name)
39
38
  method_name == config_method_name
40
39
  end
@@ -27,9 +27,8 @@ module Transpec
27
27
  def block_node
28
28
  return @block_node if instance_variable_defined?(:@block_node)
29
29
 
30
- @block_node = rspec_configure.block_node.each_descendent_node.find do |node|
31
- next unless node.block_type?
32
- send_node = node.children.first
30
+ @block_node = rspec_configure.block_node.each_descendant(:block).find do |block_node|
31
+ send_node = block_node.children.first
33
32
  receiver_node, method_name, *_ = *send_node
34
33
  next unless receiver_node == s(:lvar, rspec_configure.block_arg_name)
35
34
  method_name == block_method_name
@@ -11,12 +11,8 @@ module Transpec
11
11
  end
12
12
 
13
13
  def yield_receiver_to_any_instance_implementation_blocks=(value)
14
- # rubocop:disable LineLength
15
- #
16
14
  # Based on the deprecation warning in RSpec 2.99:
17
15
  # https://github.com/rspec/rspec-mocks/blob/aab8dc9/lib/rspec/mocks/message_expectation.rb#L478-L491
18
- #
19
- # rubocop:enable LineLength
20
16
  comment = <<-END.gsub(/^\s+\|/, '').chomp
21
17
  |In RSpec 3, `any_instance` implementation blocks will be yielded the receiving
22
18
  |instance as the first block argument to allow the implementation block to use
@@ -42,14 +42,10 @@ module Transpec
42
42
  return if infer_spec_type_from_file_location?
43
43
  return unless rspec_rails?
44
44
 
45
- # rubocop:disable LineLength
46
- #
47
45
  # Based on the deprecation warning in RSpec 2.99:
48
46
  # https://github.com/rspec/rspec-rails/blob/ab6313b/lib/rspec/rails/infer_type_configuration.rb#L13-L22
49
47
  # and the Myron's post:
50
48
  # http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#filetype_inference_disabled_by_default
51
- #
52
- # rubocop:enable LineLength
53
49
  comment = <<-END.gsub(/^\s+\|/, '').chomp
54
50
  |rspec-rails 3 will no longer automatically infer an example group's spec type
55
51
  |from the file location. You can explicitly opt-in to the feature using this
@@ -11,8 +11,6 @@ module Transpec
11
11
  class Should < Syntax
12
12
  include Mixin::ShouldBase, Mixin::MonkeyPatch, Mixin::Expectizable, Util
13
13
 
14
- attr_reader :current_syntax_type
15
-
16
14
  define_dynamic_analysis do |rewriter|
17
15
  register_syntax_availability_analysis_request(
18
16
  rewriter,
@@ -21,11 +19,6 @@ module Transpec
21
19
  )
22
20
  end
23
21
 
24
- def initialize(*)
25
- super
26
- @current_syntax_type = :should
27
- end
28
-
29
22
  def dynamic_analysis_target?
30
23
  super && receiver_node && [:should, :should_not].include?(method_name)
31
24
  end
@@ -69,12 +62,7 @@ module Transpec
69
62
  end
70
63
 
71
64
  class RecordBuilder < Transpec::RecordBuilder
72
- attr_reader :should, :negative_form_of_to
73
-
74
- def initialize(should, negative_form_of_to)
75
- @should = should
76
- @negative_form_of_to = negative_form_of_to
77
- end
65
+ param_names :should, :negative_form_of_to
78
66
 
79
67
  def old_syntax
80
68
  syntax = if should.proc_subject?
@@ -162,12 +162,7 @@ module Transpec
162
162
  end
163
163
 
164
164
  class ExpectBaseRecordBuilder < RecordBuilder
165
- attr_reader :should_receive, :negative_form_of_to
166
-
167
- def initialize(should_receive, negative_form_of_to)
168
- @should_receive = should_receive
169
- @negative_form_of_to = negative_form_of_to
170
- end
165
+ param_names :should_receive, :negative_form_of_to
171
166
 
172
167
  def syntax_name
173
168
  fail NotImplementedError
@@ -213,11 +208,7 @@ module Transpec
213
208
  end
214
209
 
215
210
  class StubRecordBuilder < RecordBuilder
216
- attr_reader :should_receive
217
-
218
- def initialize(should_receive)
219
- @should_receive = should_receive
220
- end
211
+ param_names :should_receive
221
212
 
222
213
  def old_syntax
223
214
  syntax = "obj.#{should_receive.method_name}(:message)"
@@ -179,7 +179,7 @@ module Transpec
179
179
  end
180
180
 
181
181
  def parent_node
182
- node.parent_node
182
+ node.parent
183
183
  end
184
184
 
185
185
  def expression_range
data/lib/transpec/util.rb CHANGED
@@ -67,7 +67,7 @@ module Transpec
67
67
  end
68
68
 
69
69
  def block_node_taken_by_method(node)
70
- parent_node = node.parent_node
70
+ parent_node = node.parent
71
71
  return nil unless parent_node
72
72
  return nil unless parent_node.block_type?
73
73
  return nil unless parent_node.children.first.equal?(node)
@@ -104,8 +104,7 @@ module Transpec
104
104
 
105
105
  yield origin_node if mode == :include_origin
106
106
 
107
- origin_node.each_ancestor_node.reduce(origin_node) do |child_node, parent_node|
108
- return unless [:send, :block].include?(parent_node.type)
107
+ origin_node.each_ancestor(:send, :block).reduce(origin_node) do |child_node, parent_node|
109
108
  return unless parent_node.children.first.equal?(child_node)
110
109
 
111
110
  if mode == :child_as_second_arg
@@ -5,7 +5,7 @@ module Transpec
5
5
  module Version
6
6
  MAJOR = 2
7
7
  MINOR = 3
8
- PATCH = 1
8
+ PATCH = 2
9
9
 
10
10
  def self.to_s
11
11
  [MAJOR, MINOR, PATCH].join('.')
@@ -0,0 +1,74 @@
1
+ # coding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require 'transpec/directory_cloner'
5
+
6
+ module Transpec
7
+ describe DirectoryCloner do
8
+ include FileHelper
9
+ include_context 'isolated environment'
10
+
11
+ describe '#copy_recursively' do
12
+ it 'copies files recursively' do
13
+ [
14
+ 'src/file1',
15
+ 'src/file2',
16
+ 'src/dir1/file',
17
+ 'src/dir2/file'
18
+ ].each do |path|
19
+ create_file(path, '')
20
+ end
21
+
22
+ DirectoryCloner.copy_recursively('src', 'dst')
23
+
24
+ [
25
+ 'dst/file1',
26
+ 'dst/file2',
27
+ 'dst/dir1/file',
28
+ 'dst/dir2/file'
29
+ ].each do |path|
30
+ File.exist?(path).should be_true
31
+ end
32
+ end
33
+
34
+ it 'copies only directories, files and symlinks' do
35
+ create_file('src/file', '')
36
+ File.symlink('file', 'src/symlink')
37
+ Dir.mkdir('src/dir')
38
+ system('mkfifo', 'src/fifo')
39
+
40
+ DirectoryCloner.copy_recursively('src', 'dst')
41
+
42
+ File.file?('dst/file').should be_true
43
+ File.symlink?('dst/symlink').should be_true
44
+ File.directory?('dst/dir').should be_true
45
+ File.exist?('dst/fifo').should be_false
46
+ end
47
+
48
+ def permission(path)
49
+ format('%o', File.lstat(path).mode)[-4..-1]
50
+ end
51
+
52
+ it 'preserves permission' do
53
+ create_file('src/file', '')
54
+ File.chmod(0755, 'src/file')
55
+
56
+ File.symlink('file', 'src/symlink')
57
+
58
+ Dir.mkdir('src/dir')
59
+ File.chmod(0600, 'src/dir')
60
+
61
+ DirectoryCloner.copy_recursively('src', 'dst')
62
+
63
+ permission('dst/file').should == '0755'
64
+ permission('dst/dir').should == '0600'
65
+ end
66
+
67
+ it 'returns the copied directory path' do
68
+ Dir.mkdir('src')
69
+ path = DirectoryCloner.copy_recursively('src', 'dst')
70
+ path.should == File.expand_path('dst')
71
+ end
72
+ end
73
+ end
74
+ end
@@ -247,62 +247,5 @@ module Transpec
247
247
  end
248
248
  end
249
249
  end
250
-
251
- describe '#copy_recursively' do
252
- it 'copies files recursively' do
253
- [
254
- 'src/file1',
255
- 'src/file2',
256
- 'src/dir1/file',
257
- 'src/dir2/file'
258
- ].each do |path|
259
- create_file(path, '')
260
- end
261
-
262
- dynamic_analyzer.copy_recursively('src', 'dst')
263
-
264
- [
265
- 'dst/file1',
266
- 'dst/file2',
267
- 'dst/dir1/file',
268
- 'dst/dir2/file'
269
- ].each do |path|
270
- File.exist?(path).should be_true
271
- end
272
- end
273
-
274
- it 'copies only directories, files and symlinks' do
275
- create_file('src/file', '')
276
- File.symlink('file', 'src/symlink')
277
- Dir.mkdir('src/dir')
278
- system('mkfifo', 'src/fifo')
279
-
280
- dynamic_analyzer.copy_recursively('src', 'dst')
281
-
282
- File.file?('dst/file').should be_true
283
- File.symlink?('dst/symlink').should be_true
284
- File.directory?('dst/dir').should be_true
285
- File.exist?('dst/fifo').should be_false
286
- end
287
-
288
- def permission(path)
289
- format('%o', File.lstat(path).mode)[-4..-1]
290
- end
291
-
292
- it 'preserves permission' do
293
- create_file('src/file', '')
294
- File.chmod(0755, 'src/file')
295
-
296
- File.symlink('file', 'src/symlink')
297
-
298
- Dir.mkdir('src/dir')
299
- File.chmod(0600, 'src/dir')
300
-
301
- dynamic_analyzer.copy_recursively('src', 'dst')
302
-
303
- permission('dst/file').should == '0755'
304
- permission('dst/dir').should == '0600'
305
- end
306
- end
307
250
  end
308
251
  end
@@ -84,8 +84,8 @@ module Transpec
84
84
  let(:main_rspec_configure_node) do
85
85
  spec_suite.specs.each do |spec|
86
86
  next unless spec.path == 'spec/spec_helper.rb'
87
- spec.ast.each_node do |node|
88
- return node if node.send_type? && node.children[1] == :configure
87
+ spec.ast.each_node(:send) do |send_node|
88
+ return send_node if send_node.children[1] == :configure
89
89
  end
90
90
  end
91
91
  fail 'Main RSpec.configure node not found!'
@@ -160,11 +160,6 @@ module Transpec
160
160
  end
161
161
 
162
162
  def eval_with_rspec_in_context(eval_source, spec_source)
163
- # Clear SPEC_OPTS environment variable so that this spec does not fail
164
- # with dynamic analysis in self-testing.
165
- original_spec_opts = ENV['SPEC_OPTS']
166
- ENV['SPEC_OPTS'] = nil
167
-
168
163
  result_path = 'result'
169
164
 
170
165
  helper_source = <<-END
@@ -182,8 +177,6 @@ module Transpec
182
177
  `rspec #{source_path}`
183
178
 
184
179
  Marshal.load(File.read(result_path))
185
- ensure
186
- ENV['SPEC_OPTS'] = original_spec_opts
187
180
  end
188
181
 
189
182
  describe '#non_monkey_patch_expectation_available?' do
@@ -13,13 +13,10 @@ module Transpec
13
13
 
14
14
  describe '#conversion_target?' do
15
15
  let(:target_node) do
16
- ast.each_descendent_node do |node|
17
- next unless node.send_type?
18
- method_name = node.children[1]
19
- next unless method_name == :example
20
- return node
16
+ ast.each_node(:send).find do |send_node|
17
+ method_name = send_node.children[1]
18
+ method_name == :example
21
19
  end
22
- fail 'No #example node is found!'
23
20
  end
24
21
 
25
22
  let(:current_example_object) do
@@ -11,13 +11,10 @@ module Transpec
11
11
 
12
12
  describe '#conversion_target?' do
13
13
  let(:target_node) do
14
- ast.each_descendent_node do |node|
15
- next unless node.send_type?
16
- method_name = node.children[1]
17
- next unless method_name == :double
18
- return node
14
+ ast.each_node(:send).find do |send_node|
15
+ method_name = send_node.children[1]
16
+ method_name == :double
19
17
  end
20
- fail 'No #double node is found!'
21
18
  end
22
19
 
23
20
  let(:double_object) do
@@ -2,10 +2,12 @@
2
2
 
3
3
  require 'spec_helper'
4
4
  require 'transpec/syntax/example_group'
5
+ require 'ast'
5
6
 
6
7
  module Transpec
7
8
  class Syntax
8
9
  describe ExampleGroup do
10
+ include ::AST::Sexp
9
11
  include_context 'parsed objects'
10
12
  include_context 'syntax object', ExampleGroup, :example_group
11
13
 
@@ -182,6 +184,75 @@ module Transpec
182
184
  end
183
185
  end
184
186
 
187
+ describe '#metadata_key_nodes' do
188
+ subject { example_group.metadata_key_nodes }
189
+
190
+ context "with expression `describe 'something' { }`" do
191
+ let(:source) do
192
+ <<-END
193
+ describe 'example' do
194
+ end
195
+ END
196
+ end
197
+
198
+ it 'returns empty array' do
199
+ should be_empty
200
+ end
201
+ end
202
+
203
+ context "with expression `describe 'something', '#some_method' { }`" do
204
+ let(:source) do
205
+ <<-END
206
+ describe 'something', '#some_method' do
207
+ end
208
+ END
209
+ end
210
+
211
+ it 'returns empty array' do
212
+ should be_empty
213
+ end
214
+ end
215
+
216
+ context "with expression `describe 'something', :foo { }`" do
217
+ let(:source) do
218
+ <<-END
219
+ describe 'something', :foo do
220
+ end
221
+ END
222
+ end
223
+
224
+ it 'returns [(sym :foo)]' do
225
+ should == [s(:sym, :foo)]
226
+ end
227
+ end
228
+
229
+ context "with expression `describe 'something', foo: true { }`" do
230
+ let(:source) do
231
+ <<-END
232
+ describe 'something', foo: true do
233
+ end
234
+ END
235
+ end
236
+
237
+ it 'returns [(sym :foo)]' do
238
+ should == [s(:sym, :foo)]
239
+ end
240
+ end
241
+
242
+ context "with expression `describe 'something', :foo, :bar, baz: true { }`" do
243
+ let(:source) do
244
+ <<-END
245
+ describe 'something', :foo, :bar, baz: true do
246
+ end
247
+ END
248
+ end
249
+
250
+ it 'returns [s(:sym, :foo), s(:sym, :bar), s(:sym, :baz)]' do
251
+ should == [s(:sym, :foo), s(:sym, :bar), s(:sym, :baz)]
252
+ end
253
+ end
254
+ end
255
+
185
256
  describe '#add_explicit_type_metadata!' do
186
257
  before do
187
258
  example_group.add_explicit_type_metadata!
@@ -280,7 +351,31 @@ module Transpec
280
351
  END
281
352
  end
282
353
 
283
- it 'adds metadata ":type => :controller"' do
354
+ it 'adds metadata ":type => :controller" to the beginning of the hash metadata' do
355
+ rewritten_source.should == expected_source
356
+ end
357
+ end
358
+ end
359
+
360
+ context "and expression `describe 'something', '#some_method', :foo, :bar => true do ... end`" do
361
+ let(:source) do
362
+ <<-END
363
+ describe 'something', '#some_method', :foo, :bar => true do
364
+ end
365
+ END
366
+ end
367
+
368
+ context 'and the file path is "spec/controllers/some_spec.rb"' do
369
+ let(:source_path) { 'spec/controllers/some_spec.rb' }
370
+
371
+ let(:expected_source) do
372
+ <<-END
373
+ describe 'something', '#some_method', :foo, :type => :controller, :bar => true do
374
+ end
375
+ END
376
+ end
377
+
378
+ it 'adds metadata ":type => :controller" to the beginning of the hash metadata' do
284
379
  rewritten_source.should == expected_source
285
380
  end
286
381
  end
@@ -15,12 +15,10 @@ module Transpec
15
15
 
16
16
  describe '#conversion_target?' do
17
17
  let(:target_node) do
18
- ast.each_descendent_node do |node|
19
- next unless node.send_type?
20
- method_name = node.children[1]
21
- return node if method_name == :pending
18
+ ast.each_node(:send).find do |send_node|
19
+ method_name = send_node.children[1]
20
+ method_name == :pending
22
21
  end
23
- fail 'No #pending node is found!'
24
22
  end
25
23
 
26
24
  let(:example_object) do
@@ -11,13 +11,10 @@ module Transpec
11
11
 
12
12
  describe '#conversion_target?' do
13
13
  let(:target_node) do
14
- ast.each_node do |node|
15
- next unless node.send_type?
16
- method_name = node.children[1]
17
- next unless method_name == :expect
18
- return node
14
+ ast.each_node(:send).find do |send_node|
15
+ method_name = send_node.children[1]
16
+ method_name == :expect
19
17
  end
20
- fail 'No #expect node is found!'
21
18
  end
22
19
 
23
20
  let(:expect_object) do
@@ -74,12 +74,10 @@ module Transpec
74
74
 
75
75
  describe '#conversion_target?' do
76
76
  let(:should_node) do
77
- ast.each_descendent_node do |node|
78
- next unless node.send_type?
79
- method_name = node.children[1]
80
- return node if method_name == :should
77
+ ast.each_node(:send).find do |send_node|
78
+ method_name = send_node.children[1]
79
+ method_name == :should
81
80
  end
82
- fail 'No #should node is found!'
83
81
  end
84
82
 
85
83
  let(:should_object) do
@@ -13,12 +13,10 @@ module Transpec
13
13
 
14
14
  describe '#conversion_target?' do
15
15
  let(:its_node) do
16
- ast.each_descendent_node do |node|
17
- next unless node.send_type?
18
- method_name = node.children[1]
19
- return node if method_name == :its
16
+ ast.each_node(:send).find do |send_node|
17
+ method_name = send_node.children[1]
18
+ method_name == :its
20
19
  end
21
- fail 'No #its node is found!'
22
20
  end
23
21
 
24
22
  let(:its_object) do