On Jan 12, 2012, at 5:32 PM, Fearless Fool wrote: > I have two blocks of tests: one for testing positive outcomes and one > for testing negative. After poking around, I've concluded that the > underlying :verify_credentials method is getting called, despite the > stub: > > describe 'electricity credentials' do > before(:each) do > @wizard.electricity_service = MeteredService::Base.create!() > end > > it 'with valid credentials should spawn external loader' do > @wizard.electricity_service.stub(:verify_credentials).and_return(true) > @wizard.electricity_loader.stub(:start) > @wizard.electricity_loader.should_receive(:start) > @wizard.validate_setting_electricity_credentials > end > > it 'with invalid credentials should not spawn external loader' do > @wizard.electricity_service.stub(:verify_credentials).and_raise('no > can do') > @wizard.electricity_loader.stub(:start) > @wizard.electricity_loader.should_not_receive(:start) > @wizard.validate_setting_electricity_credentials > end > > end > > Am I missing something fundamental about .stub()? > > - ff > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
What are the failed expectations? Just paste it. Are you sure that @wizard.electricity_service is returning the same object on each call? If a database call is being made, there's a good chance it is returning a different object (which has not mocks). _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users