mumukit-assistant 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a60cd7990b918459cf5ca6d880988803b2ae05fcaf134027962288da648dcc88
4
- data.tar.gz: 0282f96960a30e776ec04472024f35f4f6e1423a18143bc80bdf7240560b63fe
3
+ metadata.gz: 61831f6e3b8b9148533c7750c6cd1fe00da152b7b65f1b17c8e03a2230702299
4
+ data.tar.gz: a50ed94ad78bbf063979f101a0598f6ef868e1b62d852f1dd5102bfed8cef6b2
5
5
  SHA512:
6
- metadata.gz: 50954bef56f3b6a7490aa883523f483648787a6ee0e54ed7d719c4f282c172839892f0d09738e2288d81fc2a5bc34d695b6c523d09cf1a89442dcd0cf3bbcf83
7
- data.tar.gz: b2744d1e36db6e2f91d201c7c449a60f925932f81a1e1c9f40ae882ea26c89c95b06869cebf85e7ef0ebfa8f7cae73b9e64eae5610266f412d6cf51ea5eec596
6
+ metadata.gz: 9ae461914bc5d0af93cdb177ddbd7c29bda4757f8505ccf15a8c6033659e0ff0ff693600350861c32ca3621a3ff863dbec569c8b6ea35d3a44e1bf0f99a9c083
7
+ data.tar.gz: 71477eb4923bba10efdb08fb9763c5e76c26f05a62069bb4a34921a6ecfed66d9365a7d57b374dace95f18028e0f4442a7b34b7cd5afe8d3aa0759d1e67548a7
@@ -22,10 +22,13 @@ module Mumukit::Assistant::Rule
22
22
  def self.parse_complex_when(w, message)
23
23
  condition, value = *w
24
24
  case condition.to_sym
25
- when :error_contains then Mumukit::Assistant::Rule::ErrorContains.new(message, value)
26
- when :these_tests_failed then Mumukit::Assistant::Rule::TheseTestsFailed.new(message, value)
27
- when :only_these_tests_failed then Mumukit::Assistant::Rule::OnlyTheseTestsFailed.new(message, value)
28
- when :these_expectations_failed then Mumukit::Assistant::Rule::TheseExpectationsFailed.new(message, value)
25
+ when :error_contains then Mumukit::Assistant::Rule::ErrorContains.new(message, value)
26
+ when :these_tests_failed then Mumukit::Assistant::Rule::TheseTestsFailed.new(message, value)
27
+ when :only_these_tests_failed then Mumukit::Assistant::Rule::OnlyTheseTestsFailed.new(message, value)
28
+ when :these_expectations_failed then Mumukit::Assistant::Rule::TheseExpectationsFailed.new(message, value)
29
+ when :only_these_expectations_failed then Mumukit::Assistant::Rule::OnlyTheseExpectationsFailed.new(message, value)
30
+ when :submission_passed_with_these_warnings then Mumukit::Assistant::Rule::TheseExpectationsFailed.new(message, value, strict: true)
31
+ when :submission_passed_with_only_these_warnings then Mumukit::Assistant::Rule::OnlyTheseExpectationsFailed.new(message, value, strict: true)
29
32
  else raise "Unsupported rule #{condition}"
30
33
  end
31
34
  end
@@ -38,5 +41,6 @@ require_relative 'rule/these_tests_failed.rb'
38
41
  require_relative 'rule/only_these_tests_failed.rb'
39
42
  require_relative 'rule/submission_passed_with_warnings.rb'
40
43
  require_relative 'rule/these_expectations_failed.rb'
44
+ require_relative 'rule/only_these_expectations_failed.rb'
41
45
  require_relative 'rule/submission_errored.rb'
42
46
  require_relative 'rule/error_contains.rb'
@@ -0,0 +1,5 @@
1
+ class Mumukit::Assistant::Rule::OnlyTheseExpectationsFailed < Mumukit::Assistant::Rule::TheseExpectationsFailed
2
+ def matches_failing_expectations?(submission)
3
+ super && failed_expectations(submission).count == @expectations.count
4
+ end
5
+ end
@@ -1,22 +1,27 @@
1
1
  class Mumukit::Assistant::Rule::TheseExpectationsFailed < Mumukit::Assistant::Rule::SubmissionPassedWithWarnings
2
- def initialize(message, expectations)
2
+ def initialize(message, expectations, strict: false)
3
3
  raise 'missing expectations' if expectations.blank?
4
4
  super(message)
5
5
  @expectations = expectations
6
+ @strict = strict
6
7
  end
7
8
 
8
9
  def matches?(submission)
9
- super && matches_failing_expectations?(submission)
10
+ (!@strict || super) && matches_failing_expectations?(submission)
10
11
  end
11
12
 
12
13
  def matches_failing_expectations?(submission)
13
14
  @expectations.all? do |it|
14
- includes_failing_expectation? it, submission.expectation_results
15
+ includes_failing_expectation? it, submission
15
16
  end
16
17
  end
17
18
 
18
- def includes_failing_expectation?(humanized_expectation, expectation_results)
19
+ def failed_expectations(submission)
20
+ @failed_expectations ||= submission.expectation_results.select { |it| it[:result].failed? }
21
+ end
22
+
23
+ def includes_failing_expectation?(humanized_expectation, submission)
19
24
  binding, inspection = humanized_expectation.split(' ')
20
- expectation_results.include? binding: binding, inspection: inspection, result: :failed
25
+ failed_expectations(submission).any? { |it| it[:binding] == binding && it[:inspection] == inspection }
21
26
  end
22
27
  end
@@ -20,6 +20,6 @@ class Mumukit::Assistant::Rule::TheseTestsFailed < Mumukit::Assistant::Rule::Sub
20
20
  end
21
21
 
22
22
  def failed_tests(submission)
23
- submission.test_results.select { |it| it[:status].failed? }
23
+ @failed_tests ||= submission.test_results.select { |it| it[:status].failed? }
24
24
  end
25
25
  end
@@ -1,5 +1,5 @@
1
1
  module Mumukit
2
2
  class Assistant
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumukit-assistant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julián Berbel Alt
@@ -9,22 +9,28 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-06-08 00:00:00.000000000 Z
12
+ date: 2019-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.16'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '3'
21
24
  type: :development
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
- - - "~>"
28
+ - - ">="
26
29
  - !ruby/object:Gem::Version
27
30
  version: '1.16'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '3'
28
34
  - !ruby/object:Gem::Dependency
29
35
  name: rake
30
36
  requirement: !ruby/object:Gem::Requirement
@@ -85,6 +91,7 @@ files:
85
91
  - lib/mumukit/assistant/rule/base.rb
86
92
  - lib/mumukit/assistant/rule/content_empty.rb
87
93
  - lib/mumukit/assistant/rule/error_contains.rb
94
+ - lib/mumukit/assistant/rule/only_these_expectations_failed.rb
88
95
  - lib/mumukit/assistant/rule/only_these_tests_failed.rb
89
96
  - lib/mumukit/assistant/rule/submission_errored.rb
90
97
  - lib/mumukit/assistant/rule/submission_failed.rb