Routing error when upgrading to Rails 3.2.6 or Rspec 2.11.0

After upgrading to Rails 3.2.6 or Rspec 2.11.0, my specifications start showing routing errors, as shown below:

4) UsersController GET activate activation code not exist Failure/Error: subject{ get :activate } ActionController::RoutingError: No route matches {:controller=>"users", :action=>"activate"} 

There is also after each error hook

 An error occurred in an after(:each) hook RSpec::Mocks::MockExpectationError: (#<EmailSubscriber[...]>).update_attributes({:enable=>true}) expected: 1 time received: 0 times occurred at [...]/spec/controllers/users_controller_spec.rb:75:in `block (3 levels) in <top (required)>' 

The application in development mode is still working fine.

+7
source share
2 answers

Both Rspec 2.11.0 and Rails 3.2.6 use the latest Journey gem (1.0.4). This has some problems, and by explicitly blocking it to the previous version, the specification error disappears.

 gem 'journey', '1.0.3' 

UPDATE

I recently upgraded Rails to 3.2.11 with Journey 1.0.4, and the whole specification went through. My Rspec is 2.11.0 So you don’t have to travel down anymore, just update Rails.

+7
source

In functional tests, the environment seems to be more stringent than in production or development.

In the last two cases, he cannot β€œknow” the parameter names in advance, since they are determined by defining the corresponding / associated route.

In the test , however, the parameter name is explicitly specified. This allows the environment to be more picky.

Since this behavior deviates from the principle of the maximum possible compliance prov-env test-env, I consider it a mistake and filed accordingly ( https://github.com/rails/journey/issues/59 ).

To solve the problem , make sure that your parameter names exactly match your routes.

I suggest adding the appropriate routes until the issue of the problem is resolved. Thus, if this caused an error and resolved, you just need to delete the routes again - instead of messing with your production logic at the controller level (which works flawlessly already).

+2
source

All Articles