Forum: Ruby on Rails Capybara throws printer errors with every test

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C56d14d32eddc6e2bd6364bc2ebbf542?d=identicon&s=25 Andy Joel (f2andy)
on 2013-10-07 11:41
I am in the process of upgrading from Rails 3 to 4. Whenever I run a
test I always get two errors like this:

Capybara::Rails::TestCase#test_printer_url:
ActionController::UrlGenerationError: No route matches {:action=>"test",
:controller=>"printers"} missing required keys: [:id]

If I test all my controllers I get 2, if I just test one of my models I
get the same 2. They are nothing to do with any test I have written
myself, they seem to be tests Capybara is running on itself.

The problem seems to arise because I have a route for printers in my
project, set up like this.

 resources :printers do
    member do
      get :test
    end
  end

Okay, so just rename it to something to stop the name collision... If I
rename "test" to "test_printer45745dc", or I change it from GET to POST
it still fails! And if I have a second member line in there, I get four
errors.

If I change it to a collection, I get a different error:

Capybara::Rails::TestCase#test_printers_url:
ArgumentError: Missing host to link to! Please provide the :host
parameter, set default_url_options[:host], or set :only_path to true

What Capybara seems to do is to generate tests on the fly, based on the
routes, and then generate errors however they are set up.

Why would it do that? What can I do about it?

I am using JRuby 1.7.4 on Windows, by the way
C56d14d32eddc6e2bd6364bc2ebbf542?d=identicon&s=25 Andy Joel (f2andy)
on 2013-10-08 15:18
The problem seems to be the name of the action, "test", and nothing to
do with printers at all. Any action that starts "test" seems to be
affected, though I am still not sure why.
This topic is locked and can not be replied to.