Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Eliminate the need for full_title test helper

  • Loading branch information...
commit c435eaa26d41c41c9d7fa9cfa57867071f7d2284 1 parent d3f4460
@dskecse authored
View
2  app/helpers/application_helper.rb
@@ -1,5 +1,5 @@
module ApplicationHelper
- def build_full_title(page_title)
+ def full_title(page_title)
base_title = 'Ruby on Rails Tutorial Sample App'
return base_title if page_title.blank?
"#{ base_title } | #{ page_title }"
View
2  app/views/layouts/application.html.slim
@@ -2,7 +2,7 @@ doctype html
html
head
meta charset='utf-8'
- title= build_full_title(yield(:title))
+ title= full_title(yield(:title))
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag 'application', 'data-turbolinks-track' => true
= csrf_meta_tags
View
21 spec/helpers/application_helper_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe ApplicationHelper do
+ describe 'full_title' do
+ context 'with page title provided' do
+ it 'includes the page title' do
+ expect(full_title('foo')).to match(/foo/)
+ end
+
+ it 'includes the base title' do
+ expect(full_title('foo')).to match(/\ARuby on Rails Tutorial Sample App/)
+ end
+ end
+
+ context 'without page title provided' do
+ it 'not includes the bar for the home page' do
+ expect(full_title('')).not_to match(/\|/)
+ end
+ end
+ end
+end
View
6 spec/support/utilities.rb
@@ -1,5 +1 @@
-def full_title(page_title)
- base_title = 'Ruby on Rails Tutorial Sample App'
- return base_title if page_title.blank?
- "#{ base_title } | #{ page_title }"
-end
+include ApplicationHelper
Please sign in to comment.
Something went wrong with that request. Please try again.