Forum: Ruby on Rails How to test a controller mapped to a non-canonical path?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
366dbda84e78aff8a8a070622aeb63ce?d=identicon&s=25 Gioele Barabucci (Guest)
on 2013-07-30 15:37
(Received via mailing list)
I have a controller `SuperPower` that is responsible for the paths under
`/super-power`, and not the canonical `/super_power` (notice the hyphen
instead of the underscore).

In my `routes.rb` I have

     resources 'super-power', as :super_power

My `super_power_test.rb` contains

     class SuperPowerControllerTest < ActionController::TestCase
         test "shows all available" do
             get :index

             assert_not_nil assign(:powers)

and the test fails with

     # Running tests:

     [1/1] SuperPowerControllerTest#test_shows_all_available = 0.08 s
      1) Error:
       ActionController::RoutingError: No route matches

The test fails because it doesn't use the correct path `/super-power`
but uses the canonical `/super_power`.

Is there a way to associate the tests of a controller to a certain path?
Is there a way to make this change for all the tests?

Gioele Barabucci <>
This topic is locked and can not be replied to.