环境:Rails 3.2.12,rspec 2.12
我正在尝试使用非常简单的路由测试来引导应用程序。测试失败了,我看不出有什么问题。
这是失败的测试:
# spec/routing/meow_route_spec.rb
require 'spec_helper'
describe "meow routes" do
it "routes post /meows to meows#create" do
expect(:post => "/meows").to route_to(
:controller => "meows",
:action => "create",
)
end
end
还有我的路线:
# config/routes.rb
Meowserver::Application.routes.draw do
resources :meows
end
rake routes
告诉我:
polk:meowserver dpassage$ rake routes
meows GET /meows(.:format) meows#index
POST /meows(.:format) meows#create
new_meow GET /meows/new(.:format) meows#new
edit_meow GET /meows/:id/edit(.:format) meows#edit
meow GET /meows/:id(.:format) meows#show
PUT /meows/:id(.:format) meows#update
DELETE /meows/:id(.:format) meows#destroy
但是当我运行 rspec 时,我得到了这个错误:
1) meow routes routes post /meows to meows#create
Failure/Error: expect(:post => "/meows").to route_to(
No route matches "/meows"
# ./spec/routing/meow_route_spec.rb:4:in `block (2 levels) in <top (required)>'
这到底是怎么回事?到目前为止,这些确实是我的应用程序中唯一重要的文件——甚至没有任何控制器或模型,只是试图从外向内构建它。