tracks/ruby/lib/wordy_cases.rb in trackler-2.1.0.1 vs tracks/ruby/lib/wordy_cases.rb in trackler-2.1.0.2

- old
+ new

@@ -1,23 +1,16 @@ require 'exercise_cases' -class WordyCase < OpenStruct - def test_name - 'test_%s' % description.downcase.tr(' ', '_') - end +class WordyCase < ExerciseCase def workload [ "question = '#{input}'", indent(4, assertion), ].join("\n") end - def skipped - index.zero? ? '# skip' : 'skip' - end - private def indent(size, lines) lines.lines.each_with_object('') { |line, obj| obj << ' ' * size + line } end @@ -42,28 +35,12 @@ 'answer = WordProblem.new(question).answer', "message = \"#{message % '#{answer}'}\"", "assert_equal(#{expected}, answer, message)", ].join("\n") end -end -class WordyCase::PreProcessor - class << self - def call(row) - row.merge('message' => message_for(row)) - end + def message + return unless input == 'What is -3 plus 7 multiplied by -2?' - private - - def message_for(row) - return unless row['input'] == 'What is -3 plus 7 multiplied by -2?' - - 'You should ignore order of precedence. -3 + 7 * -2 = -8, not %s' - end - end -end - -WordyCases = proc do |data| - JSON.parse(data)['cases'].map.with_index do |row, i| - WordyCase.new(WordyCase::PreProcessor.call(row).merge(index: i)) + 'You should ignore order of precedence. -3 + 7 * -2 = -8, not %s' end end