In integration testing, previously working code was throwing an error. The cause was unexpected, so I decided to leave it as an article (although it is not a memorandum)
Terminal
Failures:
1)user Before user registration Can you enter member information?
Failure/Error: expect(page).to have_content("Enter delivery address information")
Capybara::Ambiguous:
Ambiguous match, found 2 elements matching visible xpath "/html"
# ./spec/features/user_spec.rb:20:in `block (3 levels) in <top (required)>'
2)user Cannot log in before user registration
Failure/Error: expect(page).to have_content("Click here if you do not have an account")
Capybara::Ambiguous:
Ambiguous match, found 2 elements matching visible xpath "/html"
# ./spec/features/user_spec.rb:29:in `block (3 levels) in <top (required)>'
3)user Before user registration Press the product listing button to move to the login page.
Failure/Error: expect(page).to have_content("Click here if you do not have an account")
Capybara::Ambiguous:
Ambiguous match, found 2 elements matching visible xpath "/html"
# ./spec/features/user_spec.rb:35:in `block (3 levels) in <top (required)>'
4)user My page is displayed in the header if you can log in after registering as a user
Failure/Error: expect(page).to have_content "My page"
Capybara::Ambiguous:
Ambiguous match, found 2 elements matching visible xpath "/html"
# ./spec/features/user_spec.rb:50:in `block (3 levels) in <top (required)>'
5)user You can log out after registering as a user
Failure/Error: expect(page).to have_content "New member registration"
Capybara::Ambiguous:
Ambiguous match, found 2 elements matching visible xpath "/html"
# ./spec/features/user_spec.rb:56:in `block (3 levels) in <top (required)>'
6)user If you press the product listing button after user registration, you will be taken to the listing page.
Failure/Error: expect(page).to have_content("Exhibition image")
Capybara::Ambiguous:
Ambiguous match, found 2 elements matching visible xpath "/html"
# ./spec/features/user_spec.rb:61:in `block (3 levels) in <top (required)>'
7) Item#create can not save image(image)If you do not have, you cannot register
Failure/Error: expect(item.errors[:images]).to include("Please enter")
expected [] to include "Please enter"
# ./spec/models/item_spec.rb:33:in `block (4 levels) in <top (required)>'
before
haml:application.html.haml
!!!
%html
%head
%meta{content: "text/html; charset=UTF-8", "http-equiv": "Content-Type"}/
%title FreemarketSample68d
%script{src: "https://js.pay.jp/", type: "text/javascript"}
%meta{:content => "summary_large_image", :name => "twitter:card"}/
%meta{:content => "@yGZqMc5IqNbVsw0", :name => "twitter:site"}/
%meta{:content => "http://52.198.247.0/", :property => "og:url"}/
%meta{:content => "freemarket_sample", :property => "og:title"}/
%meta{:content => "This is a sample for team development! Please take a look!", :property => "og:description"}/
%meta{:content => "logo-white.png ", :property => "og:image"}/
= favicon_link_tag 'favicon.ico'
= csrf_meta_tags
= csp_meta_tag
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
= javascript_include_tag 'application', 'data-turbolinks-track': 'reload'
%body
= yield
after
haml:application.html.haml
!!!
%html
%head
%meta{content: "text/html; charset=UTF-8", "http-equiv": "Content-Type"}/
%title FreemarketSample68d
%script{src: "https://js.pay.jp/", type: "text/javascript"}
%meta{:content => "summary_large_image", :name => "twitter:card"}/
%meta{:content => "@yGZqMc5IqNbVsw0", :name => "twitter:site"}/
%meta{:content => "http://52.198.247.0/", :property => "og:url"}/
%meta{:content => "freemarket_sample", :property => "og:title"}/
%meta{:content => "This is a sample for team development! Please take a look!", :property => "og:description"}/
%meta{:content => "logo-white.png ", :property => "og:image"}/
= favicon_link_tag 'favicon.ico'
= csrf_meta_tags
= csp_meta_tag
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
= javascript_include_tag 'application', 'data-turbolinks-track': 'reload'
%body
= yield
Even in the before state, an error did not occur as an application, but an error occurred in the integration test.
The reason seems to be that there is no default nesting in application.html.haml. If you don't nest meta tags or favicon, you will get an error in other places, so be careful!
Recommended Posts