I have a simple controller:
class AccessController < ApplicationController
def login
if request.post?
employee = Employee.authenticate(params[:name], params[:password])
if employee
session[:employee_id] = employee.id
redirect_to(:controller => "timesheets", :action => "index")
else
flash.now[:notice] = "Invalid username/password combination"
end
end
end
end
I have tried a number of ways to create a spec to test the login function,
but am not having any luck.
My current code looks something like this, but I don't really understand
what is going on here.
controller.should_receive(:login).with(no_args())
post :login, params
session[:employee_id].should_not be_nil
I am setting a simple expectation in the first line and then doing a post
with params
I then check to see if the variable is in the session.
What is the best way to make something like this work..
Wayne L. Andersen
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users