Sha256: ce3309cd5a7d34a005eccc38802d8f6db56ef59b8d6c58b1323a532059a712f5
Contents?: true
Size: 818 Bytes
Versions: 233
Compression:
Stored size: 818 Bytes
Contents
require 'generator/exercise_case' class BowlingCase < Generator::ExerciseCase def workload indent_lines(assert) end private def roll_previous "record(#{previous_rolls})" end def assert if assert_error? property == 'score' ? score_raises : roll_raises else [roll_previous, "assert_equal #{expected}, @game.score"] end end def roll_raises [ roll_previous, 'assert_raises Game::BowlingError do', ' @game.roll(' + roll.to_s + ')', 'end' ] end def score_raises [ roll_previous, 'assert_raises Game::BowlingError do', ' @game.score', 'end' ] end def assert_error? expected.respond_to?(:key?) && expected.key?('error') end def indent_lines(code) code.join("\n" + ' ' * 4) end end
Version data entries
233 entries across 233 versions & 1 rubygems