Created
October 17, 2013 18:54
-
-
Save dennisfaust/7030268 to your computer and use it in GitHub Desktop.
Rspec for Testing Static Pages in a Ruby on Rails Site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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