サインイン ページを作成しようとするテストで、同じ 2 つのエラーが発生し続けます。
エラー メッセージは次のとおりです。 $ bundle exec rspec spec/requests/user_pages_spec.rb FF
失敗:
1) ユーザーページのサインアップページの失敗/エラー: before { visit signup_path } ActionView::Template::Error: undefined method |' for "Ruby on Rails Tutorial Sample App":String
# ./app/helpers/application_helper.rb:9:in
full_title' # ./app/views/layouts/application.html.erb:4:in_app_views_layouts_application_html_erb__2148911516627374684_2168968760'
# ./spec/requests/user_pages_spec.rb:8:in
ブロック (3 レベル)の '
2) ユーザー ページのサインアップ ページの失敗/エラー: before { signup_path にアクセス } ActionView::Template::Error: undefined method |' for "Ruby on Rails Tutorial Sample App":String
# ./app/helpers/application_helper.rb:9:in
full_title' # ./app/views/layouts/application.html.erb:4:in_app_views_layouts_application_html_erb__2148911516627374684_2168968760'
# ./spec/requests/user_pages_spec.rb:8:in
ブロック (3 レベル)の '
0.17668 秒で終了 2 例、2 失敗
失敗した例:
rspec ./spec/requests/user_pages_spec.rb:10 # ユーザーページのサインアップページ rspec ./spec/requests/user_pages_spec.rb:11 # ユーザーページのサインアップページ
そして、ここにファイル user_pages_spec.rb があります
「spec_helper」が必要
「ユーザーページ」について説明する
件名{ページ}
{ visit signup_path } の前に「サインアップページ」を記述する
it { should have_selector('h1', text: 'Sign up') }
it { should have_selector('title', text: full_title('Sign up')) }
終了 終了
ファイルapplication_helper.rbは次のとおりです。
モジュール ApplicationHelper
# Returns the full title on a per-page basis.
def full_title(page_title)
base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
"#{base_title}" | "#{page_title}"
end
end
end
ここにファイル routes.rb があります SampleApp::Application.routes.draw は "users/new" を取得します
root to: 'static_pages#home'
match '/signup', to: 'users#new'
match '/help', to: 'static_pages#help'
match '/about', to: 'static_pages#about'
match '/contact', to: 'static_pages#contact'
私はこれにかなりの時間を費やしてきたので、どんな助けも大歓迎です!
ありがとう!