Skip to content

Commit

Permalink
Added test for clearing session data with a GET '/' request
Browse files Browse the repository at this point in the history
  • Loading branch information
lisahamm committed Mar 19, 2015
1 parent b70da57 commit 4dc3abe
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions spec/tic_tac_toe_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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('<form action="/make_move" method="POST">')
expect(last_response.body).to include '<form action="/make_move" method="POST">'
end


Expand All @@ -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

Expand Down

0 comments on commit 4dc3abe

Please sign in to comment.