Sha256: 26ca2e6ac58584ddea5f5d2efcf9e9d51aadb047b3696e57d16fe2549bf91dab

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

require 'studio_game/game'

module StudioGame
  describe 'Game' do
    before(:example) do
      $stdout = StringIO.new #prevent puts methods from logging to the console while running the tests
    
      @game = Game.new("Knuckleheads")
      @initial_health = 100
      @player = Player.new("moe", @initial_health)
    
      @game.add_player(@player)
    end
  
    it "w00ts the player if a high number is rolled" do
      Die.any_instance.stub(:roll).and_return(5)
      @game.play(2)
      expect(@player.health).to eq(@initial_health + (15 * 2))
    end
  
    it "skips the player if a medium number is rolled" do
      Die.any_instance.stub(:roll).and_return(3)
      @game.play(2)
      expect(@player.health).to eq(@initial_health)
    end
  
    it "blams the player if a low number is rolled" do
      Die.any_instance.stub(: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
pragma_studio_game-1.0.0 spec/studio_game/game_spec.rb