Skip to content

Commit

Permalink
Refactored GameSetup class
Browse files Browse the repository at this point in the history
  • Loading branch information
lisahamm committed Feb 26, 2015
1 parent b94f4ec commit e02a99b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
12 changes: 0 additions & 12 deletions lib/game_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,8 @@ def invalid?
private

def run_validations
validate_player
validate_opponent
validate_player_order
end

def validate_player_mark
validate(:player_mark)
end

def validate_opponent
validate(:opponent)
end

def validate_player_order
validate(:player_order)
end

Expand Down
11 changes: 10 additions & 1 deletion spec/game_setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
expect(valid_game_setup.valid?).to eq true
end

it 'checks if game configurations are invalid' do
expect(valid_game_setup.invalid?).to eq false
end

it 'does not produce error messages' do
expect(valid_game_setup.errors.empty?).to eq true
end
Expand All @@ -23,7 +27,12 @@
expect(invalid_game_setup.valid?).to eq false
end

it 'does not produce error messages' do
it 'checks if game configurations are invalid' do
expect(invalid_game_setup.invalid?).to eq true
end

it 'retrieves and stores the appropriate error messages for invalid params' do
invalid_game_setup.valid?
expect(invalid_game_setup.errors.empty?).to eq false
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/tic_tac_toe_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ENV['RACK_ENV'] = 'test'


require 'tic_tac_toe_controller'
require '../tic_tac_toe_controller'
require 'rspec'
require 'rack/test'

Expand Down
1 change: 0 additions & 1 deletion tic_tac_toe_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require './lib/game_setup'

class TicTacToeController < Sinatra::Base
include Validation
enable :sessions

get '/' do
Expand Down

0 comments on commit e02a99b

Please sign in to comment.