0

i have added include Sorcery::TestHelpers::Rails inside sorcery.rb my controller spec looks like

describe "success" do
  before(:each) do
    @user = Factory(:user)
    @attr = { :username => @user.username, :password => @user.password }
  end
  it "should sign the user in" do
    post :create, :session => @attr
    # controller.current_user.should == @user
    controller.should be_logged_in
  end
end

my controller looks like

class SessionsController < ApplicationController
  def create
    user = login(params[:username], params[:password], params[:remember_me])
    if user
      redirect_back_or_to root_url, :notice => "Logged in!"
    else
      flash.now.alert = "Email or password was invalid"
      render :new
    end
  end
end

i have User model migrated to my test environment, when i run the test it always ends up saying not logged in.

1
  • seems like the sorcery methods are not getting called inside rspec. any ideas appreciated ?
    – bicepjai
    Jan 17, 2012 at 0:55

1 Answer 1

1

You're passing params[:session] into the method from your test, but in the action you're referencing params[:username] and params[:password].

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.