我想爲我的一個控制器編寫一個非常基本的功能測試,但問題是它不能識別我的任何路由。他們都通過HTTP在應用程序中工作,並可以在耙路中看到。不能識別任何路由的功能測試
事實上我甚至增加
puts ActionController::Routing::Routes.inspect
,它的錯誤之前把我的所有路由。
這裏的測試:
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
test "should get signup" do
get :new
assert_response :success
assert_not_nil assigns(:users)
end
end
錯誤:
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.8.7...]
(See full trace by running task with --trace)
耙路線:
POST /users(.:format) {:controller=>"users", :action=>"create"}
new_user_en_gb GET /users/new(.:format) {:controller=>"users", :action=>"new"}
什麼測試工具是你在用嗎?它對我來說沒有rspec-ish ...這只是因爲我從來沒有使用任何超出rspec的任何東西來進行我的單元測試(功能和其他) – jaydel 2011-06-07 13:20:43
也是,完整的跟蹤是什麼?這可能是真正的錯誤被整個路由錯誤的東西掩蓋... – jaydel 2011-06-07 13:21:41
它是[測試::單元](http://test-unit.rubyforge.org/),測試框架是標準的一部分Ruby庫(Ruby自帶)。 – danneu 2011-06-07 15:50:33