Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added a few more layout tweaks

  • Loading branch information...
commit 77b4ff824798c2a1694960bbf5e825e04c1434f0 1 parent e0e10ca
Rob authored
5 app/helpers/application_helper.rb
... ... @@ -1,4 +1,9 @@
1 1 module ApplicationHelper
  2 +
  3 + def logo
  4 + logo = image_tag("logo.png", alt: "Sample App", class: "round")
  5 + end
  6 +
2 7
3 8 # Returns the full title on a per-page basis.
4 9 def full_title(page_title)
1  app/views/layouts/_header.html.erb
... ... @@ -1,5 +1,4 @@
1 1 <header>
2   - <% logo = image_tag("logo.png", alt: "Sample App", class: "round") %>
3 2 <%= link_to logo, root_path %>
4 3 <nav class="round">
5 4 <ul>
44 spec/requests/static_pages_spec.rb
@@ -4,27 +4,55 @@
4 4
5 5 subject { page }
6 6
  7 + shared_examples_for "all static pages" do
  8 + it { should have_selector('h1', text: heading) }
  9 + it { should have_selector('title', text: full_title(page_title)) }
  10 + end
  11 +
7 12 describe "Home page" do
8 13 before { visit root_path }
9   - it { should have_selector('h1', text: 'Sample App') }
10   - it { should have_selector('title', text: full_title('Home')) }
  14 + let(:heading) {'Sample App'}
  15 + let(:page_title) {'Home'}
  16 + it_should_behave_like "all static pages"
11 17 end
12 18
13 19 describe "Help page" do
14 20 before { visit help_path }
15   - it { should have_selector('h1', text: 'Help') }
16   - it { should have_selector('title', text: full_title('Help')) }
  21 + let(:heading) {'Help'}
  22 + let(:page_title) {'Help'}
  23 + it_should_behave_like "all static pages"
17 24 end
18 25
19 26 describe "About page" do
20 27 before { visit about_path }
21   - it { should have_selector('h1', text: 'About Us') }
22   - it { should have_selector('title', text: full_title('About Us')) }
  28 + let(:heading) {'About Us'}
  29 + let(:page_title) {'About Us'}
  30 + it_should_behave_like "all static pages"
23 31 end
24 32
25 33 describe "Contact page" do
26 34 before { visit contact_path }
27   - it { should have_selector('h1', text: 'Contact') }
28   - it { should have_selector('title', text: full_title('Contact')) }
  35 + let(:heading) {'Contact'}
  36 + let(:page_title) {'Contact'}
  37 + it_should_behave_like "all static pages"
29 38 end
  39 +
  40 + it "should have the right links on the layout" do
  41 + visit root_path
  42 + click_link "About"
  43 + page.should have_selector 'title', text: full_title('About Us')
  44 + visit root_path
  45 + click_link "Help"
  46 + page.should have_selector 'title', text: full_title('Help')
  47 + visit root_path
  48 + click_link "Contact"
  49 + page.should have_selector 'title', text: full_title('Contact')
  50 + visit root_path
  51 + click_link "Home"
  52 + page.should have_selector 'title', text: full_title('Home')
  53 + visit root_path
  54 + click_link "Sign up now!"
  55 + page.should have_selector 'title', text: full_title('Sign up')
  56 + end
  57 +
30 58 end

0 comments on commit 77b4ff8

Please sign in to comment.
Something went wrong with that request. Please try again.