-
Notifications
You must be signed in to change notification settings - Fork 419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid error when member is present on ancestor class #1068
Avoid error when member is present on ancestor class #1068
Conversation
Niche case - when clearing class members for new definition, avoid trying to remove members present on ancestor classes.
66ab6f7
to
bc930ab
Compare
spec/concurrent/struct_shared.rb
Outdated
@@ -26,6 +26,18 @@ | |||
expect(clazz.ancestors).to include described_class | |||
end | |||
|
|||
it 'ignores methods on ancestor classes' do | |||
ancestor = described_class.ancestors.first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
described_class.ancestors.first
is the same as described_class
, no?
Unless prepended modules are involved here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I double checked and it works as well using ancestors.last
👍🏻
spec/concurrent/struct_shared.rb
Outdated
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems not meaningful to test here, let's just that that creating an instance of it plus accessing that member works as expected.
e4e1d20
to
3a775c4
Compare
I've updated the spec now based on comments - the ancestor method is added to the end of the ancestor chain, and I'm testing the more relevant method presence and arity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
Fix #1067
Niche case - when clearing class members for new definition, avoid trying to remove members present on ancestor classes.
I'm happy to make any updates for style or structure if needed - I've added a spec that does fail without this fix, very happy to receive feedback if it would fit better in a different location or with different emphasis.