Greetings!
I am trying to test a controller method with rspec that looks like this:
def email_customer @quote = Quote.find(params[:quote_id]) hash = { quote: @quote, body: params[:email_body], subject: params[:email_subject] } QuoteMailer.email_customer(hash).deliver redirect_to edit_quote_path params[:quote_id] end
And the relevant specification looks like this:
describe 'POST email_customer' do let!(:quote) { create(:valid_quote) } it 'assigns the quote and sends the customer an email' do post :email_customer, quote_id: quote.id expect(assigns(:quote)).to eq(quote) expect(QuoteMailer).to receive(:email_customer).with(an_instance_of(Hash)).and_return( double('QuoteMailer', deliver: true)) end end
When the test passes, I get this message:
Failure/Error: expect(QuoteMailer).to receive(:email_customer).with(an_instance_of(Hash)).and_return( double('QuoteMailer', deliver: true)) (<QuoteMailer (class)>).email_customer(an instance of Hash) expected: 1 time with arguments: (
I scattered the puts instructions on the controller method, as well as the email_customer method, so I know that he is completing the course and using the correct method, but I'm not sure why it failed. I assume this is a stupid syntax error that I'm not sure about. Thanks in advance for your help!
source share