Skip to content

Instantly share code, notes, and snippets.

@bicepjai
Created January 18, 2012 04:19
Show Gist options
  • Save bicepjai/1630939 to your computer and use it in GitHub Desktop.
Save bicepjai/1630939 to your computer and use it in GitHub Desktop.
redirect_to rspec test error
class UsersController < ApplicationController
def new
@user = User.new
@title = "Sign up"
end
def create
@user = User.new(params[:user])
if @user.save
redirect_to login_url, :notice => "Signed up!"
else
@title = "Sign up"
render :new
end
end
end
describe "Users" do
describe "signup" do
describe "success" do
it "should make a new user" do
lambda do
visit signup_path
fill_in "Username", :with => "foobar"
fill_in "Email", :with => "foo@bar.com"
fill_in "Password", :with => "foobar123"
fill_in "Password confirmation", :with => "foobar123"
click_button
response.should redirect_to(login_path)
response.should have_selector('div.flash.notice',
:content => "Signed up!")
end.should change(User, :count).by(1)
end
end
end
end
test fails saying
1) Users signup success should make a new user
Failure/Error: response.should redirect_to(login_path)
Expected response to be a <:redirect>, but was <200>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment