Skip to content
Browse files

Added helper function for full title and passed rspec

  • Loading branch information...
1 parent 37f4154 commit 276ab206e338d8184ef321957c3c534d42b8dac7 @safalmj committed Aug 19, 2012
View
9 app/helpers/application_helper.rb
@@ -1,2 +1,11 @@
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
+ "#{base_title} | #{page_title}"
+ end
+ end
end
View
2 app/views/layouts/application.html.erb
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>Ruby on Rails Tutorial Sample App | <%= yield(:title)%></title>
+ <title><%= full_title(yield(:title)) %></title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
View
0 app/views/layouts/route
No changes.
View
0 app/views/layouts/route.rb
No changes.
View
15 spec/requests/static_pages_spec.rb
@@ -11,10 +11,21 @@
:text => 'Sample App')
end
- it "should have title page 'Home'" do
+ # it "should have title page 'Home'" do
+ # visit '/static_pages/home'
+ # page.should have_selector('title',
+ # :text => "#{base_title} | Home")
+ # end
+
+ it "should have base title" do
visit '/static_pages/home'
page.should have_selector('title',
- :text => "#{base_title} | Home")
+ :text => "#{base_title}")
+ end
+
+ it "shoudl have custom page title" do
+ visit '/static_pages/home'
+ page.should have_selector('title', :text => 'Home')
end
end

0 comments on commit 276ab20

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