Using RSpec to test meta descriptions

A little code snippet to show you how to test meta descriptions in RSpec

How I went about testing the meta description on a view:

within('head', visible: false) do
  expect(page).to have_css("meta[name=description][content='The meta description for my webpage.']")
end

Something which helped me out a lot was using puts page.source in my test, this puts the HTML of the page out in my terminal so I could see exactly what was being put out.


Recent posts View all

Web Dev

What does --no-owner mean in Postgres?

You have read a guide to doing Postgres exports or imports and seen --no-owner, this is what it means

Web Dev

What does --no-acl mean in Postgres?

You have read a guide to doing Postgres exports or imports and seen --no-acl, this is what it means