don*_*ald 17 rspec2 ruby-on-rails-3
我找不到任何解释如何在Rails 3中测试路由的内容.即使在Rspec书中,也没有解释清楚.
谢谢
zet*_*tic 32
rspec-rails Github网站上有一个简短的例子.您还可以使用脚手架生成器来生成一些罐装示例.例如,
rails g scaffold Article
应该产生这样的东西:
require "spec_helper"
describe ArticlesController do
describe "routing" do
it "routes to #index" do
get("/articles").should route_to("articles#index")
end
it "routes to #new" do
get("/articles/new").should route_to("articles#new")
end
it "routes to #show" do
get("/articles/1").should route_to("articles#show", :id => "1")
end
it "routes to #edit" do
get("/articles/1/edit").should route_to("articles#edit", :id => "1")
end
it "routes to #create" do
post("/articles").should route_to("articles#create")
end
it "routes to #update" do
put("/articles/1").should route_to("articles#update", :id => "1")
end
it "routes to #destroy" do
delete("/articles/1").should route_to("articles#destroy", :id => "1")
end
end
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9067 次 |
| 最近记录: |