<commit_before>require 'spec_helper'

describe Tournakit::Game do
	let(:game) { Tournakit::Game.parse(File.read("data/SingleRound.json")) }

	describe "::parse" do
		it "parses a single game" do
			expect(game).to be_instance_of Tournakit::Game
			expect(game.teams[0]).to eq "Byron"
		end
	end

	describe Tournakit::Game, "#bonus_stats" do
		it "calculates ppb for both teams" do
			expect(game.bonus_stats[0][:ppb]).to be_instance_of Float
			expect(game.bonus_stats[0][:ppb]).to be_within(0.5).of(7.14)
			expect(game.bonus_stats[1][:ppb]).to be_instance_of Float
			expect(game.bonus_stats[1][:ppb]).to be_within(0.5).of(8.89)
		end

		it "returns an array of hashes" do
			expect(game.bonus_stats).to be_instance_of Array
			expect(game.bonus_stats[0]).to be_instance_of Hash
		end
	end
end

describe JSON, "#load" do
	it "can parse a full set of rounds" do
		games = JSON.load(File.read("data/Czupryn.json"))
		expect(games).to be_instance_of Array
		expect(games.length).to eq 10
		expect(games[3]).to be_instance_of Tournakit::Game
	end
end<commit_msg>failing spec for stat_line<commit_after>require 'spec_helper'

describe Tournakit::Game do
	let(:game) { Tournakit::Game.parse(File.read("data/SingleRound.json")) }

	describe "::parse" do
		it "parses a single game" do
			expect(game).to be_instance_of Tournakit::Game
			expect(game.teams[0]).to eq "Byron"
		end
	end

	describe "#bonus_stats" do
		it "calculates ppb for both teams" do
			expect(game.bonus_stats[0][:ppb]).to be_instance_of Float
			expect(game.bonus_stats[0][:ppb]).to be_within(0.5).of(7.14)
			expect(game.bonus_stats[1][:ppb]).to be_instance_of Float
			expect(game.bonus_stats[1][:ppb]).to be_within(0.5).of(8.89)
		end

		it "returns an array of hashes" do
			expect(game.bonus_stats).to be_instance_of Array
			expect(game.bonus_stats[0]).to be_instance_of Hash
		end
	end

	describe "#stat_line" do
		let(:royline)  { {:tens => 7, :negs => 1, :powers => 0, :points => 65} }
		let(:zachline) { {:tens => 4, :negs => 0, :powers => 0, :points => 40}}
		it "gives the stat line for a player by name" do
			expect(game.stat_line("Roy Slick")).to eq royline
		end

		it "gives the stat line for a player by index" do
			expect(game.stat_line(1,1)).to eq zachline
		end
	end
end

describe JSON, "#load" do
	it "can parse a full set of rounds" do
		games = JSON.load(File.read("data/Czupryn.json"))
		expect(games).to be_instance_of Array
		expect(games.length).to eq 10
		expect(games[3]).to be_instance_of Tournakit::Game
	end
end
{'fraction_non_alphanumeric': 0.13972929936305734, 'fraction_numerical': 0.019904458598726114, 'mean_word_length': 4.5597345132743365, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 11, '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': '1953605', 'n_tokens_mistral': 1075, 'n_tokens_neox': 957, 'n_words': 230}