Sha256: b91ff8a8bc67aa37dc6f4d7c3a60a60105bf80d6f5f0b242517a6b8492aea46c

Contents?: true

Size: 761 Bytes

Versions: 2

Compression:

Stored size: 761 Bytes

Contents

class Mumukit::Assistant::Rule::TheseExpectationsFailed < Mumukit::Assistant::Rule::SubmissionPassedWithWarnings
  def initialize(message, expectations)
    raise 'missing expectations' if expectations.blank?
    super(message)
    @expectations = expectations
  end

  def matches?(submission)
    super && matches_failing_expectations?(submission)
  end

  def matches_failing_expectations?(submission)
    @expectations.all? do |it|
      includes_failing_expectation? it, submission.expectation_results
    end
  end

  def includes_failing_expectation?(humanized_expectation, expectation_results)
    binding, inspection = humanized_expectation.split(' ')
    expectation_results.include? binding: binding, inspection: inspection, result: :failed
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mumukit-assistant-0.1.1 lib/mumukit/assistant/rule/these_expectations_failed.rb
mumukit-assistant-0.1.0 lib/mumukit/assistant/rule/these_expectations_failed.rb