Last active
October 23, 2015 07:57
-
-
Save kalarani/ef23555ff0c7148a9052 to your computer and use it in GitHub Desktop.
Structure of unit tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
player = game.createPlayer('Player 1') # invokes the method | |
expect(player).to_not be_nil # asserts the result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
game = Game.new # creates the variable | |
game.start # sets up the object state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
game.stop # reverts the object to the state before test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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