我就简单的写了个 Request specs 测试 ---widgets_controller.rb
describe "Widget other management" do
it "create a Widget an redirects to the Widget's page " do
get "widgets/"
expect(response).to render_template(:index)
get "widgets/1/edit"
expect(response).to render_template(:edit)
get "widgets/1"
expect(response).to render_template(:update)
post "widgets/1", widget: {:name => "My Widget"}
follow_redirect!
expect(response).to render_template(:show)
expect(response.body).to include("Widget was successfully updated.")
end
end
get "widgets/"肯定是没有问题的
但是我想测试 edit,update,destory ,我该怎么写?get "widgets/1/edit"提示没有 id=1,其实我想写成 get"widgets/id/edit"
======================= 怎么没人回答了,这个是不属于功能测试,应该用 capybara?