From 56227a4c3ebdd53b8b0976eb8296ceb7a093496f Mon Sep 17 00:00:00 2001 From: Frances McMullin Date: Wed, 16 Oct 2024 21:08:21 +0100 Subject: [PATCH] Improve ancestor classes spec --- spec/concurrent/struct_shared.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/spec/concurrent/struct_shared.rb b/spec/concurrent/struct_shared.rb index 6dd91870..4c73a9e4 100644 --- a/spec/concurrent/struct_shared.rb +++ b/spec/concurrent/struct_shared.rb @@ -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