If I have a simple login function:
def login
@user = User.find_by_email params[:email]
if @user
if BCrypt::Password.new(@user.encrypted_password).is_password? params[:password]
session[:current_user_id] = @user.id
render json: true
else
render json: false
end
else
render json: false
end
end
and I want to test if this function actually will return false if user does not exist I have created the following test:
def test_my_action
post :login, :format => 'json', :email => 'foo@bar.com', :password => 'test'
assert_response json:false
end
I know that assert_response will return status 200 or other, but I cant figure out how to create the necessary assert.
How do I test if my login function actually return false?