我正在构建一个Rails 3应用程序,我对控制器规范有点困惑。这里是我在申请中的内容:
get "/:user_name/library", :to => 'users#library', :as => :user_library
class UsersController < ApplicationController
def library
end
end
describe "UsersController" do
describe "#library" do
let(:user){FactoryGirl.create(:user)}
it "renders the users/library.html.erb view" do
get :library, :parameters => {:user_name => user.user_name}
end
end
end
此示例未运行且显示以下错误
Failure/Error: get :library,:parameters => {:user_name => user.user_name}
ActionController::RoutingError:
No route matches {:parameters=>{:user_name=>"UserName"}, :controller=>"users", :action=>"library"}
答案 0 :(得分:1)
删除:parameters
中的get
密钥:
get :library, :user_name => user.user_name