My application has two models: User and Employee, and their relationship is the user has_many.
As I try to write an Rspec test case for an employee controller:
describe "GET 'edit'" do it "should get user/edit with log in" do log_in(@user) employee = mock_model(Employee, :id=>1, :user_id=>@user.id) get :edit, :id=>employee response.should be_success end end
I got the result as:
.... F
Failures:
1) EmployeesController GET 'edit' should get user / edit with log in
Failure / Error: get: edit,: id => employee
Mock "Employee_1" received unexpected message: to_ary with (no args)
# C: in `find '
# ./app/controllers/employees_controller.rb:41:in `edit '
# ./spec/controllers/employees_controller_spec.rb:51:in `block (3 levels) in '
Finished in 4.31 seconds
5 examples, 1 failure
Can someone help me with this please? Thanks
source share