Skip to content
This repository has been archived by the owner on Sep 13, 2017. It is now read-only.

journey 1.0.4 functional test environment differs from production/dev #59

Closed
GSI opened this issue Feb 8, 2013 · 1 comment
Closed

Comments

@GSI
Copy link

GSI commented Feb 8, 2013

Journey 1.0.4 appears to be stricter than an application in production is able to be.

Functional tests fail with ActionController::RoutingError: No route matches while the dev and production environment continue to work flawlessly (!)

(See also http://stackoverflow.com/questions/11466917/routing-error-when-updating-to-rails-3-2-6-or-rspec-2-11-0#comment-16419315 - and a lot of other similar reports there)

Apparently the testing environment requires exact parameter names while they are obviously invisible and thus irrelevant to the router in production. Due to this we might consider that a bug in journey.

Example:

If there is a route like this:

# rake routes
user GET    /users/:id(.:format)  users#show

Nothing tells the application the variable name (id). It can only be estimated by looking at the structure of the route definition.

Now, in a functional test on the other hand, we need to (?) declare a parameter by providing its name and assign the desired value like so:

get :show, id: @user.id
# or /users/1 in URL format

If we use a different parameter name like so:

get :show, encoded_id: @user.encoded_id

That technically still matches the route definition of /users/1. However, in a functional test, the system knows about the absence of a parameter named encoded_id and thus believes we try to use an inexistant route.

It might appear elegant to disallow that, but it fails to reflect the behaviour of the production environment while exactly that should be the goal of the testing env.

In a project I worked around that problem by adding according routes (e.g. get ':encoded_id' => 'users#show'), but as that is only necessary for the tests to run and irrelevant for production, that is, of course, very dirty.

@pixeltrix
Copy link

Journey 1.0.4 is more strict in that previously unmatched routes would still generate a url along the lines of '/assets?controller=users&action=show'. This will now generate a routing error in functional tests unlike production or development because there are no recall parameters for it to find missing parameters from. You need to specify all of the parameters in the route for it to generate correctly in your tests.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants