Permalink
Browse files

Added a few more layout tweaks

  • Loading branch information...
1 parent e0e10ca commit 77b4ff824798c2a1694960bbf5e825e04c1434f0 @rcherveny committed Feb 19, 2012
Showing with 41 additions and 9 deletions.
  1. +5 −0 app/helpers/application_helper.rb
  2. +0 −1 app/views/layouts/_header.html.erb
  3. +36 −8 spec/requests/static_pages_spec.rb
@@ -1,4 +1,9 @@
module ApplicationHelper
+
+ def logo
+ logo = image_tag("logo.png", alt: "Sample App", class: "round")
+ end
+
# Returns the full title on a per-page basis.
def full_title(page_title)
@@ -1,5 +1,4 @@
<header>
- <% logo = image_tag("logo.png", alt: "Sample App", class: "round") %>
<%= link_to logo, root_path %>
<nav class="round">
<ul>
@@ -4,27 +4,55 @@
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 }
- it { should have_selector('h1', text: 'Sample App') }
- it { should have_selector('title', text: full_title('Home')) }
+ let(:heading) {'Sample App'}
+ let(:page_title) {'Home'}
+ it_should_behave_like "all static pages"
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')) }
+ let(:heading) {'Help'}
+ let(:page_title) {'Help'}
+ it_should_behave_like "all static pages"
end
describe "About page" do
before { visit about_path }
- it { should have_selector('h1', text: 'About Us') }
- it { should have_selector('title', text: full_title('About Us')) }
+ let(:heading) {'About Us'}
+ let(:page_title) {'About Us'}
+ it_should_behave_like "all static pages"
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')) }
+ let(:heading) {'Contact'}
+ let(:page_title) {'Contact'}
+ it_should_behave_like "all static pages"
end
+
+ 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')
+ visit root_path
+ click_link "Help"
+ page.should have_selector 'title', text: full_title('Help')
+ visit root_path
+ click_link "Contact"
+ page.should have_selector 'title', text: full_title('Contact')
+ visit root_path
+ click_link "Home"
+ page.should have_selector 'title', text: full_title('Home')
+ visit root_path
+ click_link "Sign up now!"
+ page.should have_selector 'title', text: full_title('Sign up')
+ end
+
end

0 comments on commit 77b4ff8

Please sign in to comment.