I'm trying to make sense of the last exercise in Chapter 5 of Hartl's Rails Tutorial but don't really understand it nor what it strives to do. My rationale:
It speaks of "full_title helper", which refers to the code we placed in app/controllers/helpers/application_helper.rb:
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
The exercise is:
1) Include the above application_helper.rb file in the test_helper by adding the line "include ApplicationHelper"
to /test/test_helper.rb
2) We can then extend test/integration/site_layout_test.rb with:
get signup_path
assert_select "title", full_title("Sign up")
which uses the full_title method with "Sign up" as page_title.
However, this test would not test for for example typos in the base_title within the full_title method.
3) Assignment: Solve this limitation by creating a test helper "test/helpers/application_helper_test.rb" that tests this. Solution code for test/helpers/application_helper_test.rb:
require 'test_helper'
class ApplicationHelperTest < ActionView::TestCase
test "full title helper" do
assert_equal full_title, "Ruby on Rails Tutorial Sample App"
assert_equal full_title("Help"), "Help | Ruby on Rails Tutorial Sample App"
end
end
The result at least in my case is that the above full title helper test is only executed when running "bundle exec rake test" and not when running "bundle exec rake test:integration". But for running "bundle exec rake test" we already had a fine working test that checks each page title; we made that previously. What I though this exercise wanted to achieve that we also test for the page title when running "bundle exec rake test:integration".
What am I missing?