Skip to content
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

[NPE-5] Address Singleton #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

ojameso
Copy link

@ojameso ojameso commented Apr 26, 2023

Rails 5.2 has singleton issues that break specs. Adding escape for errors raised by these singletons.

Confirmed that this passes specs in Rails 5.2.

NOTE: If we happen to write code that passes singleton objects as values, we will not see the error captured in specs.

@ojameso ojameso self-assigned this Apr 26, 2023
@ojameso ojameso force-pushed the npe-5/address_singleton branch from 8b1a59e to 04250df Compare April 27, 2023 22:19
@ojameso ojameso requested a review from obrie May 3, 2023 02:26
def singleton_safe_marshal(value)
# Rspec mocks create singletons out of objects in order to track calls
# However, singletons can't be dumped, so skip marshaling
return value if value.singleton_methods.any?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need to be careful here -- while Object defines singleton_methods, its superclass (BasicObject) doesn't. We could consider doing a defined?(value.singleton_methods) here.

Alternatively, can we check for the mock class? (i.e. is there a way to remain aware of integration issues while still avoiding the rspec mock issues)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants