Last active
August 29, 2015 14:11
-
-
Save universal/e0b60f9f701037381a5e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ApplicationHelper | |
| def title(*parts) | |
| unless parts.empty? | |
| parts << t(:website) | |
| content_for(:title) do | |
| parts.join(' - ') | |
| end | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'test_helper' | |
| class ApplicationHelperTest < ActionView::TestCase | |
| include ApplicationHelper | |
| test "no title should return nil" do | |
| assert title == nil | |
| end | |
| test "title(*parts) should generate title" do | |
| assert title([1, 2, 3, 'This is a test']) == "1 - 2 - 3 - This is a test - WebsiteName" | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ApplicationHelperTest#test_title(*parts)_should_generate_title: | |
| NoMethodError: undefined method `append' for nil:NilClass | |
| app/helpers/application_helper.rb:3:in `title' | |
| test/helpers/application_helper_test.rb:11:in `block in <class:ApplicationHelperTest>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment