Skip to content

Commit

Permalink
Add comprehensive test for block definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed May 5, 2020
1 parent 8510517 commit 8e034e8
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions test/test_ripper_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -808,30 +808,23 @@ class Foo
def test_method_defined_in_block
tags = extract(<<-EOC)
RSpec.describe do
def some_method
a.b { do_smth }
end
def test_method; end
end
some_cool_dsl args do
def another_method
do_smth
module M
included do
def included_method; end
attr_accessor :cache
end
end
another_cool_dsl(args) do
def third_method
do_smth
%w[sub gsub].each do |m|
define_method("\#{m}!") {}
attr_reader m
end
end
EOC

assert_equal 3, tags.size
assert_equal 'some_method', tags[0][:name]
assert_equal 'Object#some_method', tags[0][:full_name]
assert_equal 'another_method', tags[1][:name]
assert_equal 'Object#another_method', tags[1][:full_name]
assert_equal 'third_method', tags[2][:name]
assert_equal 'Object#third_method', tags[2][:full_name]
expected = ["Object#test_method", "M", "M#included_method", "M#cache", "M#cache="]
assert_equal expected, tags.map { |t| t[:full_name] }
end
end

0 comments on commit 8e034e8

Please sign in to comment.