我使用 minitest 作为测试框架。
**routes.rb file**
Cultiva::Application.routes.draw do
root :to => 'welcome#index'
match "sign-up" => "identities#new", :as => :signup, method: :get
match "sign-up" => redirect("auth/identity/register"), :as => :signup, method: :post
match "sign-off" => "session#destroy", :as => :signoff
resources :identities
路由文件如上。我为上面的获取和发布过程设置了注册页面路由。当它发布时,它会重定向到“auth/identity/register”页面。我将页面的发布地址设置为“auth/identity/register”。我死记硬背下面的测试:
it "must route to auth/identity/register when method is post" do
post(signup_path).must_equal "/auth/identity/register"
end
when i run this test, it gives error:
test_0002_must route to auth/identity/register when method is post(Route Integration Test::signup_path) [/home/developer/Projects/Bilsa/cultiva/test/routes/route_test.rb:13]:
Expected: "/auth/identity/register"
Actual: 200