rspec2 - why controller.should_receive(:before_filter_name) fails in rspec? -
we uses controller.should_receive(:before_filter_name)
in rspec
pass before filter in our rails 3.2 rspec. before filter
, rspec returns error.
here def of before filter check_availability
:
def check_availability if find_config_const('sales_lead', 'customerx').nil? or find_config_const('sales_lead', 'customerx') == 'false' redirect_to authentify.signin_path, :notice => "quit!" end end
in controller, before filter:
before_filter :require_employee before_filter :load_customer before_filter :check_availability
to by-pass check_availability
, put following code in rspec controller:
before(:each) controller.should_receive(:require_signin) controller.should_receive(:check_availability) end
filter require_signin
has no problem. 2nd filter, there error:
2) customerx::salesleadscontroller 'new' should redirect user without proper right ←[31mfailure/error:←[0m ←[31mcontroller.should_receive(:check_availability)←[0m ←[31m(#<customerx::salesleadscontroller:0x6fb3478>).check_availability(any args)←[0m ←[31m expected: 1 time←[0m ←[31m received: 0 times←[0m ←[36m # ./spec/controllers/customerx/sales_leads_controller_spec.rb:7:in `block (2 levels) in <module:customerx>'←[0m
we don't quite understand how should_receive
works here. have seen few cases , find out causes rspec fail. help.
Comments
Post a Comment