Reputation: 7718
I have a method (send_to) on model that I want to avoid be called during one specific test. But it always got executed.
Im doing this.
subject { create(:batch_with_jobs) } #Batch hasMany Jobs
...
it 'raise if all jobs are not in right state' do
Job.stub(:sent_to){true} #first attempt, doesnt work
Job.any_instance.stub(:sent_to).and_return(true) #second attempt, doesnt work
subject.jobs.first.update_attribute :state, :error_submitting
expect{subject.commit}.to raise_error
end
the commit method continue executing the original send_to method.
EDIT: YES, ISSUE IS BECAUSE I WAS STUBING SENT_TO AND IT SHOULD BE SEND_TO.
Upvotes: 0
Views: 42
Reputation: 11069
Two comments on your code.
sent_to
, but claim the method is named send_to
.Upvotes: 1