2
我在軌道上跟隨ruby教程。停留在獲得註冊頁面集成測試通行證。這是錯誤:軌道上的紅寶石signup_path不可用 - 在軌道上的紅寶石教程
Failures:
1) User signup with valid information should create a user
Failure/Error: before { visit signup_path }
NameError:
undefined local variable or method `signup_path' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_14::Nested_2:0x007fb7a99749e8>
# ./spec/models/user_spec.rb:127:in `block (3 levels) in <top (required)>'
2) User signup with invalid information should not create a user
Failure/Error: before { visit signup_path }
NameError:
undefined local variable or method `signup_path' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_14::Nested_1:0x007fb7a9bf84d0>
# ./spec/models/user_spec.rb:127:in `block (3 levels) in <top (required)>'
該測試抱怨說路由signup_path不存在。這裏是路線文件:
SampleApp::Application.routes.draw do
# get "users/new"
resources :users
# get "static_pages/home"
root to: 'static_pages#home'
# get "static_pages/help"
match '/help', to: 'static_pages#help'
# get "static_pages/about"
match '/about', to: 'static_pages#about'
# automatically creates:
# about_path => '/about'
# about_url => 'http://localhost:3000/about'
# get "static_pages/contact"
match '/contact', to: 'static_pages#contact'
match '/signup', to: 'users#new'
end
和路由命令:
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
root / static_pages#home
help /help(.:format) static_pages#help
about /about(.:format) static_pages#about
contact /contact(.:format) static_pages#contact
signup /signup(.:format) users#new
請標記爲已解決 – Fa11enAngel
它說「你明天可以接受你的答案」。明天會做。 –