私はRubyonRailsチュートリアルをフォローしています。サインアップページ統合テストに合格するのに行き詰まりました。エラーは次のとおりです。
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
およびroutesコマンド:
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