Class: SciolyFF::Events
- Inherits:
-
Minitest::Test
- Object
- Minitest::Test
- SciolyFF::Events
- Defined in:
- lib/sciolyff/events.rb
Overview
Tests that also serve as the specification for the sciolyff file format
Instance Method Summary collapse
- #setup ⇒ Object
- #test_each_event_does_not_have_extra_info ⇒ Object
- #test_each_event_has_unique_name ⇒ Object
- #test_each_event_has_valid_name ⇒ Object
- #test_each_event_has_valid_scoring ⇒ Object
- #test_each_event_has_valid_tiers ⇒ Object
- #test_each_event_has_valid_trial ⇒ Object
- #test_each_event_has_valid_trialed ⇒ Object
- #test_has_valid_events ⇒ Object
Instance Method Details
#setup ⇒ Object
10 11 12 13 14 |
# File 'lib/sciolyff/events.rb', line 10 def setup skip unless SciolyFF.rep.instance_of? Hash @events = SciolyFF.rep[:Events] skip unless @events.instance_of? Array end |
#test_each_event_does_not_have_extra_info ⇒ Object
22 23 24 25 26 27 |
# File 'lib/sciolyff/events.rb', line 22 def test_each_event_does_not_have_extra_info @events.select { |e| e.instance_of? Hash }.each do |event| info = Set.new i[name trial trialed scoring tiers] assert Set.new(event.keys).subset? info end end |
#test_each_event_has_unique_name ⇒ Object
60 61 62 63 64 |
# File 'lib/sciolyff/events.rb', line 60 def test_each_event_has_unique_name names = @events.select { |e| e.instance_of? Hash } .map { |e| e[:name] } assert_nil names.uniq! end |
#test_each_event_has_valid_name ⇒ Object
29 30 31 32 33 |
# File 'lib/sciolyff/events.rb', line 29 def test_each_event_has_valid_name @events.select { |e| e.instance_of? Hash }.each do |event| assert_instance_of String, event[:name] end end |
#test_each_event_has_valid_scoring ⇒ Object
47 48 49 50 51 |
# File 'lib/sciolyff/events.rb', line 47 def test_each_event_has_valid_scoring @events.select { |e| e.instance_of? Hash }.each do |event| assert_includes %w[high low], event[:scoring] if event.key? :scoring end end |
#test_each_event_has_valid_tiers ⇒ Object
53 54 55 56 57 58 |
# File 'lib/sciolyff/events.rb', line 53 def test_each_event_has_valid_tiers @events.select { |e| e.instance_of? Hash }.each do |event| assert_instance_of Integer, event[:tiers] if event.key? :tiers assert_includes (1..), event[:tiers] if event.key? :tiers end end |
#test_each_event_has_valid_trial ⇒ Object
35 36 37 38 39 |
# File 'lib/sciolyff/events.rb', line 35 def test_each_event_has_valid_trial @events.select { |e| e.instance_of? Hash }.each do |event| assert_includes [true, false], event[:trial] if event.key? :trial end end |
#test_each_event_has_valid_trialed ⇒ Object
41 42 43 44 45 |
# File 'lib/sciolyff/events.rb', line 41 def test_each_event_has_valid_trialed @events.select { |e| e.instance_of? Hash }.each do |event| assert_includes [true, false], event[:trialed] if event.key? :trialed end end |
#test_has_valid_events ⇒ Object
16 17 18 19 20 |
# File 'lib/sciolyff/events.rb', line 16 def test_has_valid_events @events.each do |event| assert_instance_of Hash, event end end |