From 320a6da9e938c2346efa4929f8f0a7706615ca9f Mon Sep 17 00:00:00 2001 From: Giovanni Cappellotto Date: Sun, 3 Dec 2017 16:04:22 -0500 Subject: [PATCH] Replace assert_template assertions Let's test the result of the action by inspecting response's body as @hoffmanc already did for a couple of other tests. --- test/functional/pages_controller_test.rb | 1 + test/functional/welcome_controller_test.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/test/functional/pages_controller_test.rb b/test/functional/pages_controller_test.rb index 9683eedf..c7cea336 100644 --- a/test/functional/pages_controller_test.rb +++ b/test/functional/pages_controller_test.rb @@ -8,5 +8,6 @@ def setup test 'should get how_to' do get :show, params: { id: 'how_to' } assert_response :success + assert response.body.include? '

How to

' end end diff --git a/test/functional/welcome_controller_test.rb b/test/functional/welcome_controller_test.rb index 803f23cd..8de09aba 100644 --- a/test/functional/welcome_controller_test.rb +++ b/test/functional/welcome_controller_test.rb @@ -12,6 +12,14 @@ class WelcomeControllerTest < ActionController::TestCase test 'should get index' do get :index assert_response :success + # It includes the public header + assert( + response.body.include?( + 'Tomatoes is a Pomodoro Technique® driven time tracker' + ) + ) + # It doesn't include the current user's list of tomatoes + assert_not response.body.include? 'Today's tomatoes' end test 'current user should get index' do @@ -19,5 +27,13 @@ class WelcomeControllerTest < ActionController::TestCase get :index assert_response :success + # It doesn't include the public header + assert_not( + response.body.include?( + 'Tomatoes is a Pomodoro Technique® driven time tracker' + ) + ) + # It includes the current user's list of tomatoes + assert response.body.include? 'Today's tomatoes' end end