Sha256: a8d84ed8fab081f7b164fcc3c018ab72da20d44ef8c5e64b11398fc05a1507a7
Contents?: true
Size: 1.1 KB
Versions: 67
Compression:
Stored size: 1.1 KB
Contents
class ClockCase < OpenStruct def name 'test_%s' % description .gsub(/[() -]/, '_') .gsub('=', 'is_equal_to') .chomp('_') end def test_body section == 'equal' ? compare_clocks : simple_test end def compare_clocks "clock1 = Clock.at(#{clock1['hour']}, #{clock1['minute']}) clock2 = Clock.at(#{clock2['hour']}, #{clock2['minute']}) #{assert_or_refute} clock1 == clock2" end def simple_test [ "assert_equal #{expected.inspect}, ", "#{'(' if add_to_clock}Clock.at(#{hour}, ", "#{minute})#{add_to_clock}#{')' if add_to_clock}.to_s" ].join end def assert_or_refute expected ? 'assert' : 'refute' end def add_to_clock " + #{add}" if add end def skipped index.zero? ? '# skip' : 'skip' end end ClockCases = proc do |data| i = 0 json = JSON.parse(data) cases = [] %w(create add equal).each do |section| json[section]['cases'].each do |row| row = row.merge(row.merge('index' => i, 'section' => section)) cases << ClockCase.new(row) i += 1 end end cases end
Version data entries
67 entries across 67 versions & 1 rubygems