site_layout_specテスト作成後
下記エラーが発生しましたエラー文だけではどこに問題があるのか
全くわからず苦戦中です。
ファイルが多いため
必要なファイルは適時表示していきますのでよろしくお願いいたします。
site_layout_spec
require 'rails_helper' RSpec.describe "SiteLayouts", type: :system do describe "home layout" do it "contains root link" do visit root_path expect(page).to have_link nil, href: root_path, count: 2 end it "contains login link" do visit root_path expect(page).to have_link 'Login', href: login_path end # 中略 end end
エラー
Failures: 1) SiteLayouts home layout contains root link Failure/Error: expect(page).to have_link nil, href: root_path, count: 2 expected to find link nil with href "/" 2 times but there were no matches [Screenshot]: tmp/screenshots/failures_r_spec_example_groups_site_layouts_home_layout_contains_root_link_850.png # ./spec/systems/site_layout_spec.rb:7:in `block (3 levels) in <main>' 2) SiteLayouts home layout contains login link Failure/Error: expect(page).to have_link 'Login', href: login_path NameError: undefined local variable or method `login_path' for #<RSpec::ExampleGroups::SiteLayouts::HomeLayout:0x00007f842ea10d60> [Screenshot]: tmp/screenshots/failures_r_spec_example_groups_site_layouts_home_layout_contains_login_link_530.png # ./spec/systems/site_layout_spec.rb:12:in `block (3 levels) in <main>' Finished in 5.32 seconds (files took 2.81 seconds to load) 4 examples, 2 failures Failed examples: rspec ./spec/systems/site_layout_spec.rb:5 # SiteLayouts home layout contains root link rspec ./spec/systems/site_layout_spec.rb:10 # SiteLayouts home layout contains login link /Users/megataichi/.rbenv/versions/2.7.0/bin/ruby -I/Users/megataichi/portfolio/lantern_app/vendor/bundle/ruby/2.7.0/gems/rspec-core-3.9.1/lib:/Users/megataichi/portfolio/lantern_app/vendor/bundle/ruby/2.7.0/gems/rspec-support-3.9.2/lib /Users/megataichi/portfolio/lantern_app/vendor/bundle/ruby/2.7.0/gems/rspec-core-3.9.1/exe/rspec --pattern spec/**\{,/*/**\}/*_spec.rb failed
追記分
① app/views/static_pages/home.html.erb
<% provide(:title, "Home") %> <h1>Sample App</h1> <p> This is the home page for the <a href="https://railstutorial.jp/">Ruby on Rails Tutorial</a> sample application. </p>
② bundle exec rake routes の実行結果
/Users/megataichi/portfolio/lantern_app/vendor/bundle/ruby/2.7.0/gems/actionpack-5.2.4.2/lib/action_dispatch/middleware/stack.rb:37: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call /Users/megataichi/portfolio/lantern_app/vendor/bundle/ruby/2.7.0/gems/actionpack-5.2.4.2/lib/action_dispatch/middleware/static.rb:111: warning: The called method `initialize' is defined here Prefix Verb URI Pattern Controller#Action static_pages_home GET /static_pages/home(.:format) static_pages#home static_pages_about GET /static_pages/about(.:format) static_pages#about root GET / static_pages#home about GET /about(.:format) static_pages#about rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show rails_blob_representation GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show update_rails_disk_service PUT /rails/active_storage/disk/:encoded_token(.:format) active_storage/disk#update rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format)
あなたの回答
tips
プレビュー