Skip to content

Instantly share code, notes, and snippets.

@dennisfaust
Created October 17, 2013 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dennisfaust/7030268 to your computer and use it in GitHub Desktop.
Save dennisfaust/7030268 to your computer and use it in GitHub Desktop.
Rspec for Testing Static Pages in a Ruby on Rails Site
describe "StaticPages", type: :feature do
header_links = [
{ name: 'Sign Up', link: '/signup', text: 'Contacts associated with purchases' },
{ name: 'Log In', link: '/login', text: 'Forgot your user name or password?' }
]
footer_links = [
{ name: 'Home', link: '/', text: 'Easily and efficiently track'},
{ name: 'Plans & Pricing', link: '/plan', text: 'Standard Features'},
{ name: 'Features', link: '/site/features', text: 'Save Time & Money'},
{ name: 'FAQ', link: '/faqs', text: 'What is Easy'},
{ name: 'About Us', link: '/site/aboutus', text: 'Meet the Team'},
{ name: 'Terms & Conditions', link: '/site/terms#terms', text: 'Terms & Conditions of Use'},
{ name: 'Privacy Policy', link: '/site/terms#privacy',text: 'The personal information we collect about you'}
]
both_links = [{ name: 'Plans & Pricing', link: '/plan', text: ''}]
(header_links + footer_links + both_links).each do |p|
it "Header, Content and Footer check for page -> #{p[:name]} " do
visit p[:link]
page.status_code.should be(200)
expect(page).to have_content p[:text] unless p[:text].blank?
within '#header' do
(header_links + both_links).each do |l|
expect(page).to have_link(l[:name], l[:link])
end
end
within '#footer' do
(footer_links + both_links).each do |l|
expect(page).to have_link(l[:name], l[:link]) unless p[:name] == l[:name] # Pages don't have links to themselves
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment