Class: Mumukit::Assistant::Rule::TheseExpectationsFailed
Instance Attribute Summary
Attributes inherited from Base
#message
Instance Method Summary
collapse
Methods inherited from Base
#message_for
Constructor Details
#initialize(message, expectations, strict: false) ⇒ TheseExpectationsFailed
2
3
4
5
6
7
|
# File 'lib/mumukit/assistant/rule/these_expectations_failed.rb', line 2
def initialize(message, expectations, strict: false)
raise 'missing expectations' if expectations.blank?
super(message)
@expectations = expectations
@strict = strict
end
|
Instance Method Details
#failed_expectations(submission) ⇒ Object
19
20
21
|
# File 'lib/mumukit/assistant/rule/these_expectations_failed.rb', line 19
def failed_expectations(submission)
@failed_expectations ||= submission.expectation_results.select { |it| it[:result].failed? }
end
|
#includes_failing_expectation?(humanized_expectation, submission) ⇒ Boolean
23
24
25
26
|
# File 'lib/mumukit/assistant/rule/these_expectations_failed.rb', line 23
def includes_failing_expectation?(humanized_expectation, submission)
binding, inspection = humanized_expectation.split(' ')
failed_expectations(submission).any? { |it| it[:binding] == binding && it[:inspection] == inspection }
end
|
#matches?(submission) ⇒ Boolean
9
10
11
|
# File 'lib/mumukit/assistant/rule/these_expectations_failed.rb', line 9
def matches?(submission)
(!@strict || super) && matches_failing_expectations?(submission)
end
|
#matches_failing_expectations?(submission) ⇒ Boolean
13
14
15
16
17
|
# File 'lib/mumukit/assistant/rule/these_expectations_failed.rb', line 13
def matches_failing_expectations?(submission)
@expectations.all? do |it|
includes_failing_expectation? it, submission
end
end
|