-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Undefined method error in restore_original_visibility
#2394
Comments
Rails is messing with the hash here, causing a confusing error, this might need to be transferred back to rspec-mocks if its fixable. |
Off the top of my head you need to require Can you confirm that |
It fails only if expectation is set, so |
Less trouble - I can reproduce on Ruby 2.6.3 as well. |
undefined method
except' for class Hash'
when expect({}).to receive(:except)
on ruby-2.2restore_original_visibility
I could find a way to work this around: # @private
def restore_original_visibility
return unless @original_visibility &&
MethodReference.method_defined_at_any_visibility?(object_singleton_class, @method_name)
+ return if MethodReference.instance_method_visibility_for(object_singleton_class, @method_name) == @original_visibility but I couldn't understand what the root cause is. And as @ojab you mention, it's surely caused by something that @JonRowe By looking at |
Wondering if this is somehow related rspec/rspec-mocks#1218 and could be a better solution. |
The root issue is that the hash when we access it doesn't respond to the method but seems to. |
It does AFAIR, you can call |
Sure, you can, but not in this particular scenario. Probably because the hash is evaluated when the reproduction is loaded, and is thus before Rails installs its extensions. |
As with all such issues with rails, you need to have loaded the extensions before parsing literals. |
@pirj I believe this is the root cause: rspec/rspec-mocks#1395 |
Subject of the issue
It requires running rails application and I'm not that interested to minimize testcase more since I don't use ruby-2.2 and encountered this by making PR to another project.
Your environment
Steps to reproduce
bundle exec rspec /tmp/tst.rb
Expected behavior
No errors
Actual behavior
The text was updated successfully, but these errors were encountered: