Sha256: b6dcddb4f232ef2c3164a613b608f0521fad101b0a898419e62f409cce3d53fc
Contents?: true
Size: 779 Bytes
Versions: 87
Compression:
Stored size: 779 Bytes
Contents
require 'exercise_cases' class BowlingCase < OpenStruct def test_name "test_#{description.downcase.tr(' ', '_')}" end def skipped index.zero? ? '# skip' : 'skip' end def work_load indent_lines(assert) end private def roll "roll(#{rolls})" end def assert if assert_error? [ 'assert_raises Game::BowlingError do', " #{roll}", ' @game.score', 'end' ] else [roll, "assert_equal #{expected}, @game.score"] end end def assert_error? expected == -1 end def indent_lines(code) code.join("\n" + ' ' * 4) end end BowlingCases = proc do |data| JSON.parse(data)['score']['cases'].map.with_index do |row, i| BowlingCase.new(row.merge('index' => i)) end end
Version data entries
87 entries across 87 versions & 1 rubygems