Files
codeocean/lib/mocha_adapter.rb
Sebastian Serth 3d3478d859 Test Adapters: Always use the last output for score runs
* This prevents learners from cheating by printing the required status line themselves
2021-11-02 15:52:49 +01:00

17 lines
470 B
Ruby

# frozen_string_literal: true
class MochaAdapter < TestingFrameworkAdapter
SUCCESS_REGEXP = /(\d+) passing/.freeze
FAILURES_REGEXP = /(\d+) failing/.freeze
def self.framework_name
'Mocha'
end
def parse_output(output)
success = output[:stdout].scan(SUCCESS_REGEXP).try(:last).try(:first).try(:to_i) || 0
failed = output[:stdout].scan(FAILURES_REGEXP).try(:last).try(:first).try(:to_i) || 0
{count: success + failed, failed: failed}
end
end