I'm running tests to render and check a PDF. I've got it working but the PDF's are date stamped in the filename. I'm looking for a way to always have today's generated file to be opened. I've tried the Date.today
approach but had no joy as PDF reader doesn't see it as a correct filename. Here is my code so you can see what I'm trying to do:
today = Date.today
Given /^I open the saved PDF and confirm the VRM is "(.*?)"$/ do |vrm|
filename = 'C:\Users\user\Downloads\vehicle_summary_VRM_#{today}.pdf'
PDF::Reader.open(filename) do |reader|
reader.pages.each do |page|
expect(reader.page(1)).to have_content vrm
puts page.text
end
end
end
I get the following exception: input must be an IO-like object or a filename (ArgumentError)
Any ideas?
Thanks
Change single quotes in:
filename = 'C:\Users\user\Downloads\vehicle_summary_VRM_#{today}.pdf'
to double quotes:
filename = "C:\Users\user\Downloads\vehicle_summary_VRM_#{today}.pdf"