-
-
Notifications
You must be signed in to change notification settings - Fork 1k
No route matches Anonymous controller problem #636
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
Comments
I am running into a similar issue. Not sure how to test this type of scenario. |
Thanks for the detailed report. I'll see if I can figure out what's going on here soon; in the mean time, you might be able to test the coverage you want by testing this at a higher level using request specs. |
I think this is expected, see this: |
I have similar issue and wondering what's the best way to handle this. |
Anonymus controllers only create resource routes. So routes like Does this resolve the issue you were seeing? |
It is possible to do something like this: require "spec_helper"
describe ApplicationController do
controller do
def custom
render :text => "custom!"
end
end
describe "#custom" do
before do
routes.draw { get "custom" => "anonymous#custom" }
end
it "responds to GET" do
get :custom
expect(response.body).to eq "custom!"
end
end
end YMMV as to whether it's a good idea for your app :) And @vanstee is correct in that we only draw the default |
Very nice! Thanks @alindeman . That should be on the docs. |
The routes are rolled back automatically. If you'd like to submit a documentation update, I'd likely pull it in :) |
I got a problem with this too: usage of |
Another data point, without having delved deep into the issue: If I add an index action (do
EDIT: Ah, the docs go into this: https://relishapp.com/rspec/rspec-rails/docs/controller-specs/anonymous-controller#anonymous-controllers-only-create-resource-routes |
As i see, anonymous controller doesn`t work. I expect test custom 404 error handling, but have only errors:
I already looked to similar cases (like #573 or http://stackoverflow.com/questions/7027518/no-route-matches-rspecs-anonymous-controller) but it doesn`t helped me, so i writed this issue.
rails (3.2.1)
rspec (2.11.0, 2.10.0)
rspec-core (2.11.1, 2.10.1)
rspec-expectations (2.11.3, 2.10.0)
rspec-mocks (2.11.3, 2.10.1)
rspec-rails (2.11.4, 2.10.1)
The text was updated successfully, but these errors were encountered: