Skip to content

Commit

Permalink
Improve ancestor classes spec
Browse files Browse the repository at this point in the history
  • Loading branch information
francesmcmullin authored and eregon committed Oct 19, 2024
1 parent 56fd240 commit 56227a4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions spec/concurrent/struct_shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
end

it 'ignores methods on ancestor classes' do
ancestor = described_class.ancestors.first
ancestor.class_eval { def foo; end }
ancestor = described_class.ancestors.last
ancestor.class_eval { def foo(bar); end }

clazz = described_class.new(:foo)
expect{ described_class.const_get(clazz.to_s) }.to raise_error(NameError)
expect(clazz).to be_a Class
expect(clazz.ancestors).to include described_class
struct = clazz.new

expect(struct).to respond_to :foo
method = struct.method(:foo)
expect(method.arity).to eq 0

ancestor.send :remove_method, :foo
end
Expand Down

0 comments on commit 56227a4

Please sign in to comment.