我正在我的应用程序中测试一个控制器,并在我的控制器中有以下代码:
describe CsdlController do
describe "GET /csdl/inclusive" do
before do
# Create domains that are included
@domain = create(:validated_domain)
end
it "returns a CSDL with valid domains" do
get "/csdl/include.json"
response.body.should =~ /#{@domain.text}/
end
end
end
我也有以下路线:
match "/csdl/:type" => 'csdl#show'
但是,当我运行规范时,它给了我以下错误:
No route matches {:controller=>"csdl", :action=>"/csdl/include.json"}
我有一种感觉,我在这里错误地使用了 RSpec,但不知道如何解决它。有任何想法吗?
我应该补充一点,当我通过浏览器实际调用它时,它似乎工作得很好。