Skip to content

Commit

Permalink
Replace assert_template assertions
Browse files Browse the repository at this point in the history
Let's test the result of the action by inspecting response's body
as @hoffmanc already did for a couple of other tests.
  • Loading branch information
potomak committed Dec 3, 2017
1 parent a29d839 commit 320a6da
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/functional/pages_controller_test.rb
Expand Up @@ -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? '<h1>How to</h1>'
end
end
16 changes: 16 additions & 0 deletions test/functional/welcome_controller_test.rb
Expand Up @@ -12,12 +12,28 @@ 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<sup>®</sup> driven time tracker'
)
)
# It doesn't include the current user's list of tomatoes
assert_not response.body.include? 'Today&#39;s tomatoes'
end

test 'current user should get index' do
session[:user_id] = @user.id

get :index
assert_response :success
# It doesn't include the public header
assert_not(
response.body.include?(
'Tomatoes is a Pomodoro Technique<sup>®</sup> driven time tracker'
)
)
# It includes the current user's list of tomatoes
assert response.body.include? 'Today&#39;s tomatoes'
end
end

0 comments on commit 320a6da

Please sign in to comment.