Reputation: 8461
I have this spec:
it 'makes a request to google if redis is empty' do
fetch_cfm_data
expect(GoogleCalendarApi::V1::Client).to receive(:get_cfm)
end
I've debugged the messages being called during this process of my test and GoogleCalendarApi::V1::Client.get_cfm
is certainly being called because I can pry inside of that method during the test run. Why does my test return this failure?
Failure/Error: expect(GoogleCalendarApi::V1::Client).to receive(:get_cfm)
(GoogleCalendarApi::V1::Client (class)).get_cfm(*(any args))
expected: 1 time with any arguments
received: 0 times with any arguments
Upvotes: 3
Views: 245
Reputation: 23317
You need to first set expectations, and then call the method under test:
expect(GoogleCalendarApi::V1::Client).to receive(:get_cfm)
fetch_cfm_data
See more in rspec-mocks
docs.
Upvotes: 5