Capybara throws printer errors with every test

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

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 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