[rspec-users] Counter.should_not_receive(:message) not working?

Pete Campbell lists at ruby-forum.com
Thu Mar 17 17:25:17 EDT 2011


I'm trying to test a Rails controller and am having trouble getting
SHOULD_NOT_RECEIVE to work on a class method. I can never get
Counter.should_not_receive(:xxx) to fail when the message 'xxx' is sent.

Controller:
def show
  @counter = Counter.increment if count_me
end


RSpec:
describe 'Show' do
  it "should INCREMENT only when count-me is true" do
    Counter.should_receive(:increment)
    Counter.should_receive(:increment).never
    Counter.should_not_receive(:increment)
    get :show, :count_me => 'true'
  end
end

Why does this pass? Counter.should_receive(:increment) passes
correctly (or fails if COUNT_ME isn't set correctly), but shouldn't the
next 2 statements fail?

This is in Rails 2.3.11 & MongoDB.

Thanks!

-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list