Sha256: a238bc62acea84043ea3793ac999e4e53860a97723d23ae8803f08f7604960a5

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

require 'studio_game/clumsy_player'

module StudioGame
  describe ClumsyPlayer do
    before(:example) do
      $stdout = StringIO.new
    
      @initial_health = 100
      @boost_factor = 5 
      @player = ClumsyPlayer.new("klutz", @initial_health, @boost_factor)
    end
  
    it "only gets half the point value for each treasure" do
      expect(@player.points).to eq(0)

      hammer = Treasure.new(:hammer, 50)
      @player.found_treasure(hammer)
      @player.found_treasure(hammer)
      @player.found_treasure(hammer)

      expect(@player.points).to eq(75)

      crowbar = Treasure.new(:crowbar, 400)
      @player.found_treasure(crowbar)
    
      expect(@player.points).to eq(275) 
    
      yielded = []
      @player.each_found_treasure do |treasure|
        yielded << treasure
      end

      expect(yielded).to eq([Treasure.new(:hammer, 75), Treasure.new(:crowbar, 200)])
    end
  
    it "has a boost factor" do
      expect(@player.boost_factor).to eq(5)
    end
  
    it "gets w00ted a specified boost_factor of times" do
      @player.w00t
      expect(@player.health).to eq(@initial_health + 15 * @boost_factor)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pragma_studio_game-1.0.0 spec/studio_game/clumsy_player_spec.rb