2013-07-05 68 views
4

我有一个失败的测试,我很难理解。我在应用程序/控制器/用户/ queries_controller.rb控制器class Users::QueriesController < ApplicationController具有show作用,并有相应的命名空间路线:Rails 4:在名称空间控制器上测试GET请求

namespace :users do 
    resources :queries 
end 

我也有在测试/控制器/用户/ queries_controller_test.rb测试:

require 'test_helper' 

class Users::QueriesControllerTest < ActionController::TestCase 

    test "accessing :show action" do 
    get :show 
    assert_response :success 
    end 

end 

运行此测试结果ActionController::UrlGenerationError: No route matches {:controller=>"users/queries", :action=>"show"}

正在运行rake routes包含此行:users_query GET /users/queries/:id(.:format) users/queries#show

这里怎么回事?我正在使用Rails 4.0.0。

回答

8

我认为你需要提供一个ID,显示行动

test "accessing :show action" do 
    get :show, {:id => 1} 
    assert_response :success 
    end 

这是之前以正确的方式导轨4

请试一试,让我知道结果。

+2

啊!这样一个简单的错误。猜猜是其中之一。谢谢! – 6twenty

相关问题