It seems I can not pass this test, and I do not understand why.
controller_spec.rb:
require 'rails_helper' RSpec.describe QuotationRequestsController, type: :controller do describe "GET download" do it "streams the sample text as a text file" do
controller:
def download @quotation_request = QuotationRequest.find(params[:id]) send_data @quotation_request.sample_text, { filename: @quotation_request.sample_text_file, type: "text/plain", disposition: "attachment" } end
Test output:
1) QuotationRequestsController GET download streams the sample text as a text file Failure/Error: expect(@controller).to receive(:send_data).with(file_options) { @controller.render nothing: true } (# <QuotationRequestsController:0x007ff35f926058>).send_data({ :filename=>"1-peter-johnson.txt", :type=>"plain/text", :disposition=>"attachment" }) expected: 1 time with arguments: ({ :filename=>"1-peter-johnson.txt", :type=>"plain/text", :disposition=>"attachment" }) received: 0 times # ./spec/controllers/quotation_requests_controller_spec.rb:380:in `block (3 levels) in <top (required)>' # -e:1:in `<main>'
ruby-on-rails rspec
chell
source share