我的应用程序有两种模式:用户和员工,他们的关系是用户has_many员工。RSpec错误:模拟“Employee_1”收到意外消息:to_ary with(no args)
当我试图写为员工控制器Rspec的测试案例:
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
我得到的结果为:
....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
有人可以帮我这个好吗?由于
有同样的问题,设置ID工作 – 2012-11-05 22:36:55