Skip to content

Commit

Permalink
Refine rspec test syntax. Convert css to scss.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarnhart committed Jan 29, 2012
1 parent 3fd18b6 commit 9122ecd
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 153 deletions.
111 changes: 0 additions & 111 deletions app/assets/stylesheets/layout.css

This file was deleted.

7 changes: 4 additions & 3 deletions app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<header>
<%= image_tag("logo.png", alt: "Sample App", class: "round") %>
<% logo = image_tag("logo.png", alt: "Sample App", class: "round") %>
<%= link_to logo, root_path %>
<nav class="round">
<ul>
<li><%= link_to "Home", '#' %></li>
<li><%= link_to "Help", '#' %></li>
<li><%= link_to "Home", root_path %></li>
<li><%= link_to "Help", page_path('help') %></li>
<li><%= link_to "Sign In", '#' %></li>
</ul>
</nav>
Expand Down
57 changes: 18 additions & 39 deletions spec/requests/static_pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,33 @@

describe "Static pages" do

let(:base_title) { "Ruby on Rails Tutorial Sample App" }
subject { page }

describe "Home page" do
it "should have the content 'Sample App'" do
visit root_path
page.should have_selector('h1', :text=>'Sample App')
end
it "should have the right title" do
visit root_path
page.should have_selector('title',
:text => "#{base_title} | Home")
end
before { visit root_path }

it { should have_selector('h1', text:'Sample App') }
it { should have_selector('title', text: full_title('Home')) }
end

describe "Help page" do
it "should have the content 'Help'" do
visit page_path('help')
page.should have_selector('h1', :text=>'Help')
end
it "should have the right title" do
visit page_path('help')
page.should have_selector('title',
:text => "#{base_title} | Help")
end
end
before { visit page_path('help') }

it { should have_selector('h1', text: 'Help') }
it { should have_selector('title', text: full_title('Help')) }
end

describe "About page" do
it "should have the content 'About'" do
visit page_path('about')
page.should have_selector('h1', :text => 'About')
end
it "should have the right title" do
visit page_path('about')
page.should have_selector('title',
:text => "#{base_title} | About")
end
before { visit page_path('about') }

it { should have_selector('h1', text: 'About') }
it { should have_selector('title', text: full_title('About')) }
end

describe "Contact page" do
it "should have the h1 'Contact'" do
visit page_path('contact')
page.should have_selector('h1', text: 'Contact')
end

it "should have the title 'Contact'" do
visit page_path('contact')
page.should have_selector('title',
text: "Ruby on Rails Tutorial Sample App | Contact")
end
before { visit page_path('contact') }

it { should have_selector('h1', text: 'Contact') }
it { should have_selector('title', text: full_title('Contact')) }
end
end
8 changes: 8 additions & 0 deletions spec/support/utilities.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def full_title(page_title)
base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end

0 comments on commit 9122ecd

Please sign in to comment.