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

Cannot override :type of specs in spec/routing in order to test external redirect scenarios #801

Closed
shyam-habarakada opened this issue Aug 5, 2013 · 10 comments · Fixed by #807

Comments

@shyam-habarakada
Copy link

I have a route that does an external redirect, which I want to test like,

it "should route to the www site" do
  get "/some/path"
  response.should redirect_to("http://www.google.com")
end

There is apparently no standard way to test for redirects (see http://stackoverflow.com/questions/10842448/do-routing-specs-support-redirect-routes-rspec), which is why I am trying to use a request spec for this.

However, I'm unable to override the :type of my spec like,

describe "redirected routes", :type => :request do
  ...
end

This looks like a bug.

@JonRowe
Copy link
Member

JonRowe commented Aug 5, 2013

I'm guessing the rspec-rails auto typing is happening later in the scope (or both are applying), so a workaround for this would be to place the spec in a different folder...

@shyam-habarakada
Copy link
Author

Yes, I worked around by putting it in spec/external_routing. The issue is about this being confusing. We should add something to the docs (or a feature) to make it clearer how to spec external redirects.

@JonRowe
Copy link
Member

JonRowe commented Aug 5, 2013

Well I also feel you should be able to specify the type metadata regardless of any auto setup happening behind the scenes. A caveat could also be added to the documentation, but that's actually a Rails issue too (as it's there test helpers in use)

@alindeman
Copy link
Contributor

Docs welcomed as a PR, but I'm going to close this issue as I think everything is technically performing correctly.

@shyam-habarakada
Copy link
Author

Would you like me to update the README and send a pull request?

@alindeman
Copy link
Contributor

Sure!

@JonRowe
Copy link
Member

JonRowe commented Aug 10, 2013

@alindeman are we concerned at all by the fact that the magic overrides manually set :type?

@myronmarston
Copy link
Member

FWIW, I'd advocate moving away from the auto-assignment of :type based on file location. I suggested an alternate approach in #662, and if we're going to move in that direction the 3.0 release is the time to do so.

@shyam-habarakada
Copy link
Author

Keeping with the rails way, it would be great if by default :type was derived based on location but does not overwrite an override that the spec author has put in.

@shyam-habarakada
Copy link
Author

Looks great, and thanks!

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 a pull request may close this issue.

4 participants