Sha256: 17033a65bc11851b5ec9c4157b67396a8275452a7f71c5e4d501d96669dc2fab

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

require 'studio_game/game'

module StudioGame

describe Game do

	before do
	    $stdout = StringIO.new
	end

	before do
		@game = Game.new("knuckleheads")

		@initial_health = 100
		@player = Player.new("moe", @initial_health)

		@game.add_player(@player)
	end

	it "w00ts the player if high number is rolled" do
		Die.any_instance.stub(:roll).and_return(5)

		@game.play(2)
		@player.health.should == @initial_health + (15 * 2)
	end

	it "skips a player when a medium number is rolled" do
		Die.any_instance.stub(:roll).and_return(3)

		@game.play(2)
		@player.health.should == @initial_health
	end

	it "blams a player when a low number is rolled" do
		Die.any_instance.stub(:roll).and_return(1)

		@game.play(2)
		@player.health.should == @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)

		player.points.should_not 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))

		game.total_points.should == 500
	end
end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
studio_game_kb-1.0 spec/studio_game/game_spec.rb