Skip to content

Instantly share code, notes, and snippets.

@rhysforyou
Created March 5, 2012 11:47
Show Gist options
  • Select an option

  • Save rhysforyou/1977977 to your computer and use it in GitHub Desktop.

Select an option

Save rhysforyou/1977977 to your computer and use it in GitHub Desktop.
describe SubjectsController do
context "POST create" do
it "creates a new record and shows it given valid attributes" do
subject_attrs = Factory.attributes_for(:subject)
post :create, subject: subject_attrs
# The following line raises an exception:
# Failure/Error: response.should redirect_to(:action => :show)
# Expected response to be a redirect to <http://test.host/assets?action=show&controller=subjects> but was a redirect to <http://test.host/subjects/1>
response.should redirect_to(action: :show)
end
end
end
@Fitzsimmons
Copy link
Copy Markdown

We figured this out when we got a similar error. It turned out our implementation was passing nil for an id in a call to url_for, which confused the router. The nil was thanks to an oversight when mocking the model for the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment