Rails 3 functional test can't find my 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?

Answers


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.


Need Your Help

How to include Openssl in my project?

c openssl

I have openssl directory for whole openssl code. It has some folder hierarchy.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.