Cucumber and Routing

Hi folks,

I’ve made a simple rails app that reads the PDFs contained in /public/
files/, and creates links to those files. I’m doing this for the
purpose of using cucumber to perform automated tests on PDFs as
outlined here:
http://upstream-berlin.com/2009/02/14/testing-pdfs-with-cucumber-and-rails/

When I access the list, everything works great. When I ask Cucumber to
click on the link, it complains about there being no route.

When I follow the PDF link “TestPDF” # features/step_definitions/
webrat_steps.rb:117
No route matches “/files/TestPDF.pdf” with {:method=>:get}
(ActionController::RoutingError)
(evl):2:in click_link' ./features/step_definitions/webrt_steps.rb:118:in/^I follow
the PDF link “([^”]*)"$/’
features/PDF.feature:8:in `When I follow the PDF link “TestPDF”’

I just have a lists Controller with an empty index action, and the
following view:

Listing PDFs

    <% @files = Dir.glob("public/files/*.pdf") %> <% for file in @files %> <% file.sub!("public", "")%> <% filename = file.sub("/files/", "")%>
  • <%= link_to filename.chomp(".pdf"), file%>
  • <% end %>

My step definition for cucumber looks like this, mostly commented out
When /^I follow the PDF link “([^”]*)"$/ do |link|
click_link(link)
#temp_pdf = Tempfile.new(‘pdf’)
#temp_pdf << response.body
#temp_pdf.close
#temp_txt = Tempfile.new(‘txt’)
#temp_txt.close
#‘pdftotext -q #{temp_pdf.path} #{temp_txt.path}’
#response.body = File.read temp_txt.path
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs