Sha256: 7a8606a850259dd0f3c2113e4a3e7d80f16242dc7a00477aaa930e6a114b6478
Contents?: true
Size: 753 Bytes
Versions: 41
Compression:
Stored size: 753 Bytes
Contents
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
41 entries across 41 versions & 1 rubygems