Sha256: 35bf7c721a06c8ee3081bc948140060296d78e1218a5613b72f905bc32408242
Contents?: true
Size: 738 Bytes
Versions: 58
Compression:
Stored size: 738 Bytes
Contents
require 'exercise_cases' class PangramCase < OpenStruct def name 'test_%s' % description.downcase.tr_s(" -'", '_').sub(/_$/, '') end def workload [ "phrase = '#{input}'", " result = Pangram.pangram?(phrase)", " #{assertion} result, \"#{message}\"" ].join("\n") end def message "Expected #{expected}, got: \#{result.inspect}. \#{phrase.inspect} #{is_or_isnt} a pangram" end def is_or_isnt expected ? 'IS' : 'is NOT' end def assertion expected ? 'assert' : 'refute' end def skipped? index.zero? ? '# skip' : 'skip' end end PangramCases = proc do |data| JSON.parse(data)['cases'].map.with_index do |row, i| PangramCase.new(row.merge('index' => i)) end end
Version data entries
58 entries across 58 versions & 1 rubygems