Skip to content

Instantly share code, notes, and snippets.

@patrickcurl
Created December 24, 2012 19:26
Show Gist options
  • Save patrickcurl/4370441 to your computer and use it in GitHub Desktop.
Save patrickcurl/4370441 to your computer and use it in GitHub Desktop.
rspec errors... Failure/Error: get 'create' NoMethodError: undefined method `include?' for nil:NilClass
#app/controllers/sessions.rb
def create
@login = params[:login]
#user = User.find__by_email_or_mobile(params[:login])
if @login.include?("@")
user = User.find_by_email(@login.downcase)
else
user = User.find_by_mobile(@login.gsub(/\D/, '').gsub(/^(1|0)+/,''))
end
if user && user.authenticate(params[:password])
#session[:user_id] = user.id
if params[:remember_me]
cookies.permanent[:auth_token] = user.auth_token
else
cookies[:auth_token] = user.auth_token
end
redirect_to root_url, :notice => "Logged in!"
else
flash.now.alert = "Invalid email or password"
render "new"
end
end
#sessions_controller_spec.rb
describe "GET 'create'" do
it "returns http success" do
get 'create'
response.should redirect_to(root_url)
end
end
@patrickcurl
Copy link
Author

test

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