1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-12 16:25:41 +00:00

extracting methods from test setup

This commit is contained in:
R.J. Osborne
2015-05-19 23:25:49 -04:00
parent 0e954c1789
commit d0926420b2

View File

@@ -8,26 +8,44 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
def createTournament(numberOfWrestlers) def createTournament(numberOfWrestlers)
@id = 6000 + numberOfWrestlers @id = 6000 + numberOfWrestlers
@tournament3 = Tournament.new tournament = create_tournament
@tournament3.id = @id create_school
@tournament3.tournament_type = "Pool to bracket" create_weight
@tournament3.name = "Something" create_wrestlers(numberOfWrestlers)
@tournament3.address = "Some Place" tournament
@tournament3.director = "Some Guy" end
@tournament3.director_email = "test@test.com"
@tournament3.save def create_tournament
@school3 = School.new tournament = Tournament.new(
@school3.id = @id id: @id,
@school3.name = "Shit Show" tournament_type: "Pool to bracket",
@school3.tournament_id = @id name: "Something",
@school3.save address: "Some Place",
@weight3 = Weight.new director: "Some Guy",
@weight3.id = @id director_email: "test@test.com"
@weight3.tournament_id = @id )
@weight3.save tournament.save
numberOfWrestlers.times do |x| tournament
count = x + 1 end
@wrestler2 = Wrestler.new(
def create_school
School.new(
id: @id,
name: "Shit Show",
tournament_id: @id
).save!
end
def create_weight
Weight.new(
id: @id,
tournament_id: @id
).save!
end
def create_wrestlers(numberOfWrestlers)
(1..numberOfWrestlers).each do |count|
Wrestler.new(
name: "Guy #{count}", name: "Guy #{count}",
school_id: @id, school_id: @id,
weight_id: @id, weight_id: @id,
@@ -35,27 +53,25 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
season_loss: 0, season_loss: 0,
season_win: 0, season_win: 0,
criteria: nil criteria: nil
) ).save!
@wrestler2.save
end end
return @tournament3
end end
def checkForByeInPool(tournament) def checkForByeInPool(tournament)
tournament.upcomingMatches tournament.upcomingMatches
@matchups = tournament.matches matchups = tournament.matches
tournament.weights.each do |w| tournament.weights.each do |w|
w.wrestlers.each do |wr| w.wrestlers.each do |wr|
@round = 1 round = 1
if w.totalRounds(@matchups) > 5 if w.totalRounds(matchups) > 5
until @round > w.poolRounds(@matchups) do until round > w.poolRounds(matchups) do
if wr.boutByRound(@round,@matchups) == "BYE" if wr.boutByRound(round, matchups) == "BYE"
@message = "BYE" message = "BYE"
end end
@round = @round + 1 round += 1
end end
assert_equal "BYE", @message assert_equal "BYE", message
@message = nil message = nil
end end
end end
end end