Here the docu: https://relishapp.com/rspec/rspec-mocks/v/3-0/docs/message-expectations/expect-a-message-on-any-instance-of-a-class
Im wondering what is the right use of it.
I have a controller
class UserController < ApplicationController
def edit
generate_token!
end
end
And the method generate_token!
is defined in the model.
class User < ActiveRecord::Base
def generate_token!
self.update!(token: 'something')
end
end
I just want to check if the method receives something. The spec would be something like.
describe 'edit'
it 'receives something' do
expect_any_instance_of(Object).to receive(:generate_token!)
end
end
But what do I have to use for the Object? I tried the class and some other random stuff, but nothing worked yet. It seems I dont get the Mock at all. Any suggestions?
best regards denym_