Skip to content

Instantly share code, notes, and snippets.

@kalarani
Last active October 23, 2015 07:57
Show Gist options
  • Save kalarani/ef23555ff0c7148a9052 to your computer and use it in GitHub Desktop.
Save kalarani/ef23555ff0c7148a9052 to your computer and use it in GitHub Desktop.
Structure of unit tests
describe Game do
it 'should let players to be created' do
game = Game.new
game.start
player = game.createPlayer('Player 1')
expect(player).to_not be_nil
game.stop
end
end
player = game.createPlayer('Player 1') # invokes the method
expect(player).to_not be_nil # asserts the result
game = Game.new # creates the variable
game.start # sets up the object state
game.stop # reverts the object to the state before test
describe Game do
it ‘should let palyers to be created’
it ‘should keep track of live players’
it ‘should end the game when a player wins’
end
spec/
- unit/
- controller/
- model/
- game_spec.rb
- player_spec.rb
- etc.,
- service/
- integration/
- controller/
- repository/
- etc.,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment