I'm trying to write a very basic functional test for one of my controllers, but the problem is that it's not recognising any of my routes. They all work in the app via HTTP and can be seen in rake routes.
In fact I even added
puts ActionController::Routing::Routes.inspect
and it put out all my routes before the error.
Here's the test:
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
test "should get signup" do
get :new
assert_response :success
assert_not_nil assigns(:users)
end
end
The error:
1) Error:
test_should_get_signup(UsersControllerTest):
ActionController::RoutingError: No route matches {:controller=>"users", :action=>"new"}
/test/functional/users_controller_test.rb:5:in `test_should_get_signup'
1 tests, 0 assertions, 0 failures, 1 errors
rake aborted!
Command failed with status (1): [/Users/projectzebra/.rvm/rubies/ruby-1开发者_如何学Go.8.7...]
(See full trace by running task with --trace)
Rake routes:
POST /users(.:format) {:controller=>"users", :action=>"create"}
new_user_en_gb GET /users/new(.:format) {:controller=>"users", :action=>"new"}
Try adding a functional test for the route itself, see if that passes, and go from there.
Something like:
test "should route to new user" do
assert_routing '/users/new', { :controller => "users", :action => "new" }
end
It was a problem in my "journey" gem. They made routes more stricter in journey 1.0.4 which only show up on "test" environment. It is good for "developement" and "production".
** Ensure you are using exactly the same parameters as declared in routes **
Either add:
get :index, :locale => "en"
or in your Gemfile update:
gem 'journey', '1.0.3'
精彩评论