Even simpler...
describe 'Show' do
it 'should fail because increment is called' do
Counter.should_not_receive(:increment)# Incorrectly passes
get :show, :count_me => 'true'
end
it 'should fail because increment is not called' do
Counter.should_receive(:increment)# Correct
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
Justin Ko wrote in post #988060:
> I would say "count_me" is not returning what you think it is. Try adding
> "raise count_me.inspect" in the controller action to see if this is the
> case.
Thanks for the feedback. The code snippet isn't the exact code, it is
simplified to demonstrate the proble