Skip to content

Instantly share code, notes, and snippets.

@keeperofthenecklace
Created August 18, 2012 18:02
Show Gist options
  • Save keeperofthenecklace/3388758 to your computer and use it in GitHub Desktop.
Save keeperofthenecklace/3388758 to your computer and use it in GitHub Desktop.
spec/requests/static_pages_spec.rb
require 'spec_helper'
describe "StaticPages" do
subject { page }
shared_examples_for "all static pages" do
it { should have_selector('h1', text: heading) }
it { should have_selector('title', text: full_title(page_title)) }
end
describe "Home page" do
before { visit root_path }
let(:heading) {'CNN QUICK NEWS UPDATE - DEMO APP'}
let(:page_title) { '' }
it_should_behave_like "all static pages"
it { should_not have_selector 'title', text: '| Home'}
end
describe " Help Page " do
before { visit help_path }
it { should have_selector('h1', text: 'Help') }
it { should have_selector('title', text: full_title('Help')) }
end
describe "About Page" do
before { visit about_path }
it { should have_selector('h1', text: 'About') }
it { should have_selector('title', text: full_title('About Us')) }
end
describe "Contact Page" do
before { visit contact_path }
it { should have_selector('h1', text: 'Contact') }
it { should have_selector('title', text: full_title('Contact')) }
end
describe "Static pages" do
it "should have the right links on the layout" do
visit root_path
click_link "About"
page.should have_selector 'title', text: full_title('About us')
click_link "Help"
page.should have_selector 'title', text: full_title('Help')
click_link "Contact"
page.should have_selector 'title', text: full_title('Contact')
click_link "Home"
click_link "Sign up today!"
page.should have_selector 'title', text: full_title('Sign up')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment