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
Problem with create/update namespace responders #193
Comments
Have you resolved this issue? I'm running into the exact same problem. |
I am experiencing the same issue. The only work-around I have found is to simply disable the tests. Interestingly, everything seems to work on the actual site, i.e. the "edit" template does get rendered. Yet, response.should render_template("edit") (for update) and response.should render_template("new") (for create) tests fail. |
I think I figured out why it is happening. The problem is we are stubbing only the save method and the controller will use respond_with to handle the response. The catch is that respond_with uses to_format, that will check if get? || !has_errors? || response_overridden?. If true, respond with default_renderer, else, display errors. The request isn't a get, neither has_errors, and was not overriden. So, it will try to call url_for with our object (an instance of Encounter) that was not saved, but has no errors and persisted? is false. I think it will, somehow, be passed to url_for, that relies on the class name. Encounter is not scoped, and url_for(Encouter.first) will try to call encouter_url(@encounter.id) A solution is to stub Encouter.any_instance.stub(:errors).and_return('whatever'). The key concept is that respond_with relies on object errors, instead of the return of save. |
I'm trying to track down this problem with rspec testing namespaced IR controllers. I thought it could be with Responders but I've tried with an without them.
Note: These work in development environment in a browser it just the test cases that fail.
Here is the RSpec2 controller test (note... I'm only including one failing case. Only the update/create actions fail). These are basically the scaffold test cases.
Now the error I'm getting is
undefined method
encounter_url' for #Smd::EncountersController:0x00000005dd2c50` as its not correctly prepending the 'abc_' namespace to the redirect url.Here is the portion of the stack trace I think is critical:
Again its only a problem in RSpec and only on POST and PUT actions that are namespaced. Thanks.
The text was updated successfully, but these errors were encountered: