<commit_before>require_relative 'player'
require_relative "treasure_trove"

describe Player do
  
  before do
    @initial_health = 150
    @player = Player.new("larry", @initial_health)
    $stdout = StringIO.new
  end
  
  it 'has a capitalized name' do
    expect(@player.name).to eq("Larry")
  end
  
  it 'has an initial health' do
    expect(@player.health).to eq(@initial_health)
  end
    
  it 'has a string representation' do
    @player.found_treasure(Treasure.new(:hammer, 50))
    @player.found_treasure(Treasure.new(:hammer, 50))
    expect(@player.to_s).to eq("I'm Larry with a health = 150, points = 100, and score = 250.")
  end
  
  it 'computes a score as the sum of its health and points' do
    @player.found_treasure(Treasure.new(:hammer, 50))
    @player.found_treasure(Treasure.new(:hammer, 50))
    expect(@player.score).to eq(@initial_health + 100)
  end
  
  it 'increases health by 15 when w00ted' do
    @player.w00t    
    expect(@player.health).to eq(@initial_health + 15)
  end
  
  it 'decreases health by 10 when blammed' do
    @player.blam
    expect(@player.health).to eq(@initial_health - 10)
  end
  
  it 'computes points as the sum of all treasure points' do
    expect(@player.points).to eq(0)
    
    @player.found_treasure(Treasure.new(:hammer, 50))
    expect(@player.points).to eq(50)
    
    @player.found_treasure(Treasure.new(:crowbar, 400))
    expect(@player.points).to eq(450)
    
    @player.found_treasure(Treasure.new(:hammer, 50))
    expect(@player.points).to eq(500)
  end
  
  it 'yields each found treasure and its total points' do
    @player.found_treasure(Treasure.new(:skillet, 100))
    @player.found_treasure(Treasure.new(:skillet, 100))
    @player.found_treasure(Treasure.new(:hammer, 50))
    @player.found_treasure(Treasure.new(:bottle, 5))
    @player.found_treasure(Treasure.new(:bottle, 5))
    @player.found_treasure(Treasure.new(:bottle, 5))
    @player.found_treasure(Treasure.new(:bottle, 5))
    @player.found_treasure(Treasure.new(:bottle, 5))
    
    yielded = []
    @player.each_found_treasure do |t|
      yielded << t
    end
    
    expect(yielded).to eq([
      Treasure.new(:skillet, 200),
      Treasure.new(:hammer, 50),
      Treasure.new(:bottle, 25)])
  end
  
  it 'creates a Player from a CSV' do
    string = "Test,100"
    player = Player.from_csv(string)
    
    expect(player).to be_an_instance_of(Player)
    expect(player.name).to eq("Test")
    expect(player.health).to eq(100)
  end
  
  context 'with a health greater than 100' do
    before do
      @player = Player.new("larry", 150)
    end
    
    it 'is strong' do
      expect(@player).to be_strong
    end
  end
  
  context 'with a health less than or equal to 100' do
    before do
      @player = Player.new("larry", 100)
    end
    
    it 'is wimpy' do
      expect(@player).not_to be_strong
    end
  end
  
  context 'in a collection of players' do
    before do
      @player1 = Player.new("moe", 100)
      @player2 = Player.new("larry", 200)
      @player3 = Player.new("curly", 300)
      
      @players = [@player1, @player2, @player3]
    end
    
    it 'is sorted by decreasing score' do
      expect(@players.sort).to eq([@player3, @player2, @player1])
    end
  end
  
end
<commit_msg>Module 19 removed csv example from spec<commit_after>require_relative 'player'
require_relative "treasure_trove"

describe Player do
  
  before do
    @initial_health = 150
    @player = Player.new("larry", @initial_health)
    $stdout = StringIO.new
  end
  
  it 'has a capitalized name' do
    expect(@player.name).to eq("Larry")
  end
  
  it 'has an initial health' do
    expect(@player.health).to eq(@initial_health)
  end
    
  it 'has a string representation' do
    @player.found_treasure(Treasure.new(:hammer, 50))
    @player.found_treasure(Treasure.new(:hammer, 50))
    expect(@player.to_s).to eq("I'm Larry with a health = 150, points = 100, and score = 250.")
  end
  
  it 'computes a score as the sum of its health and points' do
    @player.found_treasure(Treasure.new(:hammer, 50))
    @player.found_treasure(Treasure.new(:hammer, 50))
    expect(@player.score).to eq(@initial_health + 100)
  end
  
  it 'increases health by 15 when w00ted' do
    @player.w00t    
    expect(@player.health).to eq(@initial_health + 15)
  end
  
  it 'decreases health by 10 when blammed' do
    @player.blam
    expect(@player.health).to eq(@initial_health - 10)
  end
  
  it 'computes points as the sum of all treasure points' do
    expect(@player.points).to eq(0)
    
    @player.found_treasure(Treasure.new(:hammer, 50))
    expect(@player.points).to eq(50)
    
    @player.found_treasure(Treasure.new(:crowbar, 400))
    expect(@player.points).to eq(450)
    
    @player.found_treasure(Treasure.new(:hammer, 50))
    expect(@player.points).to eq(500)
  end
  
  it 'yields each found treasure and its total points' do
    @player.found_treasure(Treasure.new(:skillet, 100))
    @player.found_treasure(Treasure.new(:skillet, 100))
    @player.found_treasure(Treasure.new(:hammer, 50))
    @player.found_treasure(Treasure.new(:bottle, 5))
    @player.found_treasure(Treasure.new(:bottle, 5))
    @player.found_treasure(Treasure.new(:bottle, 5))
    @player.found_treasure(Treasure.new(:bottle, 5))
    @player.found_treasure(Treasure.new(:bottle, 5))
    
    yielded = []
    @player.each_found_treasure do |t|
      yielded << t
    end
    
    expect(yielded).to eq([
      Treasure.new(:skillet, 200),
      Treasure.new(:hammer, 50),
      Treasure.new(:bottle, 25)])
  end
  
  context 'with a health greater than 100' do
    before do
      @player = Player.new("larry", 150)
    end
    
    it 'is strong' do
      expect(@player).to be_strong
    end
  end
  
  context 'with a health less than or equal to 100' do
    before do
      @player = Player.new("larry", 100)
    end
    
    it 'is wimpy' do
      expect(@player).not_to be_strong
    end
  end
  
  context 'in a collection of players' do
    before do
      @player1 = Player.new("moe", 100)
      @player2 = Player.new("larry", 200)
      @player3 = Player.new("curly", 300)
      
      @players = [@player1, @player2, @player3]
    end
    
    it 'is sorted by decreasing score' do
      expect(@players.sort).to eq([@player3, @player2, @player1])
    end
  end
  
end

{'fraction_non_alphanumeric': 0.12456583517524471, 'fraction_numerical': 0.03315440479949479, 'mean_word_length': 3.0556978233034573, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1493664', 'n_tokens_mistral': 2433, 'n_tokens_neox': 2186, 'n_words': 539}