Skip to content

Instantly share code, notes, and snippets.

@yihyang
Created February 11, 2018 03:14
Show Gist options
  • Select an option

  • Save yihyang/27c5a69947f8c56db7da71ec72a47356 to your computer and use it in GitHub Desktop.

Select an option

Save yihyang/27c5a69947f8c56db7da71ec72a47356 to your computer and use it in GitHub Desktop.
Rspec Metatags Matcher
within('head', visible: false) do
expect(page.body).to have_selector('title', text: title, visible: false)
expect(page).to have_css(%!meta[name="description"][content="#{description}"]!, visible: false)
expect(page).to have_css(%!link[hreflang="en"][rel="alternate"]!, visible: false)
expect(page).to have_css(%!link[hreflang="id"][rel="alternate"]!, visible: false)
expect(page).to have_css(%!meta[property="og:locale"][content="zh_HK"]!, visible: false)
expect(page).to have_css(%!meta[property="og:locale:alternate"][content="id_ID"]!, visible: false)
expect(page).to have_css(%!meta[property="og:locale:alternate"][content="en_US"]!, visible: false)
expect(page).to have_css(%!meta[property="og:title"][content="#{title}"]!, visible: false)
expect(page).to have_css(%!meta[property="og:description"][content="#{description}"]!, visible: false)
expect(page).to have_css(%!meta[property="og:image"][content="#{og_image}"]!, visible: false)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment