Sha256: 4a5dfc2ee789905e5386bacfa093b9b3ca60a5d2b86c17cd47dd4326998d64df
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
require "studio_game/game" module StudioGame describe Game do before do $stdout = StringIO.new @game = Game.new("Knuckleheads") @initial_health = 100 @player = Player.new("moe", @initial_health) @game.add_player(@player) end it "w00ts the player when a high number is rolled" do allow_any_instance_of(Die).to receive(:roll).and_return(5) @game.play(2) expect(@player.health).to eq(@initial_health + 15 * 2) end it "stays the same when a medium number is rolled" do allow_any_instance_of(Die).to receive(:roll).and_return(3) @game.play(2) expect(@player.health).to eq(@initial_health) end it "should decrease a player's score by 10 when a low number is rolled " do allow_any_instance_of(Die).to receive(:roll).and_return(1) @game.play(2) expect(@player.health).to eq(@initial_health - 10 * 2) end it "assigns a treasure for points during a player's turn" do game = Game.new("Knuckleheads") player = Player.new("moe") game.add_player(player) game.play(1) expect(player.points).not_to be_zero end it "computes total points as the sum of all player points" do game = Game.new("Knuckleheads") player1 = Player.new("moe") player2 = Player.new("larry") game.add_player(player1) game.add_player(player2) player1.found_treasure(Treasure.new(:hammer, 50)) player1.found_treasure(Treasure.new(:hammer, 50)) player2.found_treasure(Treasure.new(:crowbar, 400)) expect(game.total_points).to eq(500) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bennetts_magical_gem-1.0.0 | spec/studio_game/game_spec.rb |