我想在我的rspec调用中传递一个命名变量来匹配
这是路线:
match '/api/get-pairings/:global_id' => 'api#get_pairings', :as => :get_pairings
这是我所拥有但不起作用的:
it "should get pairings for a specific id" do
{:get => get_pairings_path, :global_id => 1000 }.should route_to(:controller => "api", :action => "get_pairings")
{:get => get_pairings_path, :params => { :global_id => 1000 } }.should route_to(:controller => "api", :action => "get_pairings")
end
有什么想法吗?
事先提前答案 0 :(得分:1)
您需要将变量传递给_path
方法以使规范生效:
it "should get pairings for a specific id" do
{:get => get_pairings_path(:global_id => 1000) }.
should route_to(:controller => "api",
:action => "get_pairings",
:global_id => "1000")
end