Consider the following controller test fragment:

…
        it 'should call the kill function on the user' do
byebug
          expect(@user1).to receive(:kill)
          put :update, id: :user_kill, user_id: @user1.id
        end
…

At the breakpoint in byebug, I set a breakpoint at "User#kill" and display the 
value "@user1.id". When the program breaks at User#kill, I view “self.id” — 
same value. I then continue and the est fails with the message:

     Failure/Error: expect(@user1).to receive(:kill)
       (#<User:0x007fc38cd6a248>).kill(any args)
           expected: 1 time with any arguments
           received: 0 times with any arguments

If I put another breakpoint after the “put” command, I can verify that the 
record has been deleted (which is the effect of calling User#kill. I can test 
the effect instead of testing the method call directly, but I’d rather do it 
this way (I have several other functions whose effect is less easy to detect, 
therefore I’d like to get this style of test to work). Any thoughts?

If it makes a difference, running RSpec 2.99 on Rails 3.2.21. (Please don’t 
advise me to upgrade, I’m adding tests preparatory to upgrading.)

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/992F7F4F-6033-420B-A70B-552B6EF94A42%40pobox.com.

Reply via email to