Rails 3功能测试找不到我的控制器

时间:2010-12-03 20:07:04

标签: unit-testing ruby-on-rails-3 routing routes functional-testing

我正在尝试在Ruby on Rails 3应用程序中测试我的authlogic代码,我在测试用户控制器时遇到了一些麻烦。

这是我对用户控制器的测试

class UsersControllerTest < ActionController::TestCase
  test "should be asked to login on show action" do
    get :index
  end
end

这是我设置控制器的路线部分

resource :account, :controller => 'users'

当我运行测试时,我收到消息

1) Error: test_should_be_asked_to_login_on_show_action(AccountsControllerTest): ActionController::RoutingError: No route matches {:controller=>"users"}

知道我在这里做错了吗?

1 个答案:

答案 0 :(得分:0)

那是学校男生的错误。

问题是在测试中调用索引。我想当你将某些东西定义为资源而不是资源时,它不会获得索引操作。将其更改为:show对我有用。

相关问题