ARTICLE AD BOX
I have a web application in Ruby on Rails which uses the wicked_pdf gem to render a PDF. A week ago the PDF rendering failed and my test suite running didn't show because a test was missing. The opened PDF above opens in a new tab so I want to test the PDF opening itself to be correctly rendering.
I actually am able to run cucumber tests for the click on the PDF link (which renders in a new tab) and double check that on the initial page shows a certain phrase. But if I want to check Then I should see "string_on_pdf" this fails. Probably the test suite is running the code not in the new tab with the PDF opened.
So my questions:
Is there a way in cucumber integration test to switch tabs to the PDF? Can I then test for content with Then I should see on the PDF?As requested in the comments I am adding the controller action of the show action:
def show load_out_invoice if @out_invoice.nil? redirect_to not_found_path else @title = "#{t('titles.out_invoices.show')} #{@out_invoice.number}" respond_to do |format| format.html format.pdf do @current_user = current_user @out_invoice.archived = true if params[:temporary_archived]=="1" render template: "home/out_invoices/pdf.html.erb", pdf: @out_invoice.pdf_name, encoding: 'utf-8' end end end end