0

我想在我的 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

有任何想法吗?

提前谢谢

4

1 回答 1

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
于 2012-09-25T01:28:18.847 回答