ruby on rails - RSpec Error: Mock "Employee_1" received unexpected message:to_ary with(no args) -
my application has 2 models: user , employee, , relation user has_many employees.
as trying write rspec test case employee controller:
describe "get 'edit'" "should user/edit log in" log_in(@user) employee = mock_model(employee, :id=>1, :user_id=>@user.id) :edit, :id=>employee response.should be_success end end
i got result as:
....f failures: 1) employeescontroller 'edit' should user/edit log in failure/error: :edit, :id=>employee mock "employee_1" received unexpected message :to_ary (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 me out please? thanks
rails able infer id true model instance, how works:
@employee = employee.create :edit, :id => @employee
this doesn't work mock_model
, reasons unclear me. can pass in id explicitly:
employee = mock_model(employee, :id => 1, :user_id=>@user.id) :edit, :id => employee.id # or :id => 1
Comments
Post a Comment