From 4dc3abec894211e1eae03ca8059f143dab501094 Mon Sep 17 00:00:00 2001 From: Lisa Hamm Date: Thu, 19 Mar 2015 17:37:45 -0500 Subject: [PATCH] Added test for clearing session data with a GET '/' request --- spec/tic_tac_toe_controller_spec.rb | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/spec/tic_tac_toe_controller_spec.rb b/spec/tic_tac_toe_controller_spec.rb index 5fbb8d6..89beb6b 100644 --- a/spec/tic_tac_toe_controller_spec.rb +++ b/spec/tic_tac_toe_controller_spec.rb @@ -16,11 +16,18 @@ def app TicTacToeController end - it "gets the setup page" do - get '/' - expect(last_response).to be_ok - expect(last_response.status).to eq 200 - expect(last_response.body).to include "Select your mark" + describe "GET '/'" do + it "loads the setup page with game setup options" do + get '/' + expect(last_response).to be_ok + expect(last_response.status).to eq 200 + expect(last_response.body).to include "Select your mark" + end + + it "clears the session" do + get '/', {}, {'rack.session' => {:computer_opponent => "O"}} + expect(rack_mock_session.cookie_jar[:computer_opponent]).to be_nil + end end describe "POST '/setup'" do @@ -49,7 +56,7 @@ def app "moves" => [nil, nil, nil, nil, nil, nil, nil, nil, nil]}} expect(last_response).to be_ok expect(last_response.status).to eq 200 - expect(last_response.body).to include('
') + expect(last_response.body).to include '' end @@ -61,7 +68,7 @@ def app "moves" => ["X", nil, nil, nil, nil, nil, nil, nil, nil]}} expect(last_response).to be_ok expect(last_response.status).to eq 200 - expect(last_response.body).to include('name="0" value=" X " readonly') + expect(last_response.body).to include 'name="0" value=" X " readonly' end end