-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix const errors being hidden by bug in const_missing #1876
Fix const errors being hidden by bug in const_missing #1876
Conversation
@dblock I've added a spec for the issue I experienced (fails on master, passes with this fix). It's tied to mounted modules and is resolved by checking |
Yes absolutely. |
I know it's unrelated, but care to fix the Rails edge problem as well for 💚, please |
I can take a look if you point me in the right direction - I haven't touched Rails in a long while though so no promises! |
according to ce4966d, If this is true then |
The Rails/edge failure seems trivial: This PR seems to be fixing #1871, as it no longer uses Let's see what @myxoh says. |
Hi, thanks for tagging me! in response to @dandehavilland: when I used I will have a deeper look at the issue and suggest an alternative |
I'm surprised no specs are failing after this change, I would have expected some to be. We probably need to add some coverage there. I imagine that |
I haven't been able to reproduce the issue with this spec, I'm assuming it's because I'm not using the right version of Active Support (I'm using the one on the gemfile lock on edge) |
I can't provide any extra info on the proper fix until I can reproduce the issue. After that I'm happy to help |
I'm using ActiveSupport 5.2.3 - does that help? |
Also, I'm using Grape outside of Rails and it seems |
@dandehavilland I see! yes, that sounds to be the likely cause of the issue! Could we add a Travis grid for your scenario? If you are right, then the solution would probably to add the reqiurement to that module, or to solve what I was trying to do without ActiveSupport (finding the base module of a class) |
It's weird. The spec provided in this issue is red in my case, and this is expected behaviour as grape does not load explicitly bundle exec rspec spec/grape/api_spec.rb:3873
[Coveralls] Set up the SimpleCov formatter.
[Coveralls] Using SimpleCov's default settings.
Run options: include {:locations=>{"./spec/grape/api_spec.rb"=>[3873]}}
Grape::API
const_missing
raises an error (FAILED - 1)
Failures:
1) Grape::API const_missing raises an error
Failure/Error: expect { get '/const/missing' }.to raise_error(NameError).with_message('uninitialized constant Mounted::SomeRandomConst')
expected NameError with "uninitialized constant Mounted::SomeRandomConst", got #<NameError: undefined local variable or method `parent' for Mounted:Class
Did you mean? print> with backtrace:
... |
I don't know why yesterday I wasn't able to reproduce this, I now have been able to. It seems to be the case that that branch of the if condition was no longer required, I think the issue that made it required was fixed on commit 532c08d Therefore the proper solution for the issue you are presenting here is just removing the whole def const_missing(*args)
if base_instance.const_defined?(*args)
base_instance.const_get(*args)
else
super
end
end I've already run the specs (including the one you've introduced) and it seems to be fixed when doing this |
@dandehavilland just a friendly pig whether you can update the PR, I think that will also fix the spec that's currently failing |
Ok will do that later today!
…On Thu, 11 Apr 2019, 11:05 Nicolas Klein, ***@***.***> wrote:
@dandehavilland <https://github.com/dandehavilland> just a friendly pig
whether you can update the PR, I think that will also fix the spec that's
currently failing
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1876 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAF2bs28gDsUpKX6hNkQniGm8zinj5wyks5vfvrMgaJpZM4chlTd>
.
|
Well the spec is still failing, not sure what to make of it, I think it might be worth updating the spec in this instance as the error message is being generated on a low level, and I don't think this is indicative of a larger issue. I'll leave this to your criteria |
The spec failure is trivial:
Note the namespace in the error vs. no namespace in the expected error Change to |
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.
Two more minor things please. Apologies for my OCD.
I missed both of those - fixed! |
Merged, thanks. |
I had not included a file and so a constant was missing. I did not receive the correct error as the custom
const_missing
was throwing an error of its own.This PR resolves that for me.