Skip to content

Commit

Permalink
Modify spec
Browse files Browse the repository at this point in the history
  • Loading branch information
simonewebdesign committed Dec 6, 2012
1 parent 3fdefda commit eed6374
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
10 changes: 10 additions & 0 deletions app/helpers/application_helper.rb
@@ -1,2 +1,12 @@
module ApplicationHelper

# Returns the full title on a per-page basis.
def full_title(page_title)
base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
"#{page_title} | #{base_title}"
end
end
end
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title><%= yield(:title) %> | Ruby on Rails Tutorial Sample App</title>
<title><%= full_title yield(:title) %></title>
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
Expand Down
1 change: 0 additions & 1 deletion app/views/static_pages/home.html.erb
@@ -1,3 +1,2 @@
<% provide(:title, 'Home') %>
<h1>Home</h1>
<p>Welcome.</p>
2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -52,7 +52,7 @@

# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
# root :to => 'welcome#index'
root :to => 'static_pages#home'

# See how all your routes lay out with "rake routes"

Expand Down
6 changes: 5 additions & 1 deletion spec/requests/static_pages_spec.rb
Expand Up @@ -11,8 +11,12 @@
end
it "should have the right title" do
visit '/static_pages/home'
page.should have_selector('title', text: "Home | #{base_title}")
page.should have_selector('title', text: "#{base_title}")
end
it "should not have a custom page title" do
visit '/static_pages/home'
page.should_not have_selector('title', text: 'Home | ')
end
end
describe "Help page" do
it "should have the content 'Help'" do
Expand Down

0 comments on commit eed6374

Please sign in to comment.