Use should_receive
and should be_false
:
context "an exception is thrown" do before do ExternalService.stub(:call) { raise Exception } end it "should log the exception and return false" do c = Capturer.new Logger.should_receive(:log_exception) c.capture.should be_false end end
Also note that you should not get rid of Exception
, but something more specific. Exception
covers everything that is almost certainly not what you want. At best, you should save from StandardError
, which is the default.
source share