You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
754 B

1 year ago
require "minitest"
require "rank_king"
class TestRankKing < Minitest::Test
10 months ago
def run(*args, &block)
DB.transaction(rollback: :always, auto_savepoint: true) { super }
end
1 year ago
def setup
@pool = Pool.create(name: "pool")
@axis = Axis.create(pool: @pool, name: "axis")
@items = (?a..?d).map { Item.create(pool: @pool, title: _1) }
end
def test_rank_king
ratings = @pool.items.map {|item| Rating.first(axis: @axis, item:) || OS.rating }
original_sigma_sq = Math.sqrt(ratings.sum { _1.sigma ** 2 })
game = RankKing.suggest_game(@axis)
winner, loser = game.shuffle
RankKing.rank(@axis, winner:, loser:)
sigma_sq = Math.sqrt(@axis.ratings.sum { _1.sigma ** 2 })
assert original_sigma_sq > sigma_sq
end
end