Skip to content

Instantly share code, notes, and snippets.

@universal
Last active August 29, 2015 14:11
Show Gist options
  • Select an option

  • Save universal/e0b60f9f701037381a5e to your computer and use it in GitHub Desktop.

Select an option

Save universal/e0b60f9f701037381a5e to your computer and use it in GitHub Desktop.
module ApplicationHelper
def title(*parts)
unless parts.empty?
parts << t(:website)
content_for(:title) do
parts.join(' - ')
end
end
end
end
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
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