开发者

Rails 3 functional test can't find my controller

开发者 https://www.devze.com 2023-01-28 01:41 出处:网络
I\'m trying to test my authlogic code in my Ruby on Rails 3 app and I\'m running into some trouble testing my users controller.

I'm trying to test my authlogic code in my Ruby on Rails 3 app and I'm running into some trouble testing my users controller.

This is my test for the users controller

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

And this is the section of my route which sets up the controller

resource :account, :controller => 'users'

When I run my test I get the message

1) Error: test_should_be_asked_to开发者_开发百科_login_on_show_action(AccountsControllerTest): ActionController::RoutingError: No route matches {:controller=>"users"}

Any idea what I'm doing wrong here?


Well that was a school boy error.

The problem was calling index on the test. I guess when you define something as a resource as opposed to resources it doesn't get an index action. Changing it to :show worked for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消