Class: SciolyFF::Tournament

Inherits:
Minitest::Test
  • Object
show all
Defined in:
lib/sciolyff/tournament.rb

Overview

Tests that also serve as the specification for the sciolyff file format

Instance Method Summary collapse

Instance Method Details

#setupObject



10
11
12
13
14
# File 'lib/sciolyff/tournament.rb', line 10

def setup
  skip unless SciolyFF.rep.instance_of? Hash
  @tournament = SciolyFF.rep[:Tournament]
  skip unless @tournament.instance_of? Hash
end

#test_does_not_have_extra_infoObject



24
25
26
27
28
29
# File 'lib/sciolyff/tournament.rb', line 24

def test_does_not_have_extra_info
  info = Set.new %i[name location level division state year date]
  info << :'short name' << :'worst placings dropped' << :'exempt placings'
  info << :'maximum place'
  assert Set.new(@tournament.keys).subset? info
end

#test_has_infoObject



16
17
18
19
20
21
22
# File 'lib/sciolyff/tournament.rb', line 16

def test_has_info
  refute_nil @tournament[:location]
  refute_nil @tournament[:level]
  refute_nil @tournament[:division]
  refute_nil @tournament[:year]
  refute_nil @tournament[:date]
end

#test_has_valid_dateObject



74
75
76
77
# File 'lib/sciolyff/tournament.rb', line 74

def test_has_valid_date
  skip unless @tournament.key? :date
  assert_instance_of Date, @tournament[:date]
end

#test_has_valid_divisionObject



57
58
59
60
# File 'lib/sciolyff/tournament.rb', line 57

def test_has_valid_division
  skip unless @tournament.key? :division
  assert_includes %w[A B C], @tournament[:division]
end

#test_has_valid_exempt_placingsObject



84
85
86
87
# File 'lib/sciolyff/tournament.rb', line 84

def test_has_valid_exempt_placings
  skip unless @tournament.key? :'exempt placings'
  assert_instance_of Integer, @tournament[:'exempt placings']
end

#test_has_valid_levelObject



51
52
53
54
55
# File 'lib/sciolyff/tournament.rb', line 51

def test_has_valid_level
  skip unless @tournament.key? :level
  level = @tournament[:level]
  assert_includes %w[Invitational Regionals States Nationals], level
end

#test_has_valid_locationObject



46
47
48
49
# File 'lib/sciolyff/tournament.rb', line 46

def test_has_valid_location
  skip unless @tournament.key? :location
  assert_instance_of String, @tournament[:location]
end

#test_has_valid_maximum_placeObject



89
90
91
92
# File 'lib/sciolyff/tournament.rb', line 89

def test_has_valid_maximum_place
  skip unless @tournament.key? :'maximum place'
  assert_instance_of Integer, @tournament[:'maximum place']
end

#test_has_valid_nameObject



31
32
33
34
# File 'lib/sciolyff/tournament.rb', line 31

def test_has_valid_name
  skip unless @tournament.key? :name
  assert_instance_of String, @tournament[:name]
end

#test_has_valid_short_nameObject



36
37
38
39
40
41
42
43
44
# File 'lib/sciolyff/tournament.rb', line 36

def test_has_valid_short_name
  skip unless @tournament.key? :'short name'
  assert @tournament.key?(:name), 'Cannot have short name without name'
  assert_instance_of String, @tournament[:'short name']

  skip unless @tournament[:name].instance_of? String
  assert @tournament[:'short name'].length < @tournament[:name].length,
         'Length of short name must be shorter than length of name'
end

#test_has_valid_stateObject



62
63
64
65
66
67
# File 'lib/sciolyff/tournament.rb', line 62

def test_has_valid_state
  skip unless @tournament.key? :level
  level = @tournament[:level]
  skip unless %w[Regionals States].include? level
  assert_instance_of String, @tournament[:state]
end

#test_has_valid_worst_placings_droppedObject



79
80
81
82
# File 'lib/sciolyff/tournament.rb', line 79

def test_has_valid_worst_placings_dropped
  skip unless @tournament.key? :'worst placings dropped'
  assert_instance_of Integer, @tournament[:'worst placings dropped']
end

#test_has_valid_yearObject



69
70
71
72
# File 'lib/sciolyff/tournament.rb', line 69

def test_has_valid_year
  skip unless @tournament.key? :year
  assert_instance_of Integer, @tournament[:year]
end