mumukit 2.26.0 → 2.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3ff9be27328e92ddbb2839b5516184611a2bc7668fc12104543c42e652fa1ad
4
- data.tar.gz: a65d361bd7ca62cceb96c2612b2fb329ab3cf162a20465f90c43c607ef701fba
3
+ metadata.gz: aa9b52569d8acc92b3996ab2797748cb26b04c8b424eabe47c8ea1fcd8f554a0
4
+ data.tar.gz: 18a004a9b5ccf64c278952ac02ac3fc1f5942c3acbd06ed583c5623c8c422f49
5
5
  SHA512:
6
- metadata.gz: bfcd703a70856249f859ce1f9b5a1e422a791558d2b0c3532d5a8b577043cdc09e7e67a4835c0ef76f0485dc6c112ebaa36ae8e0e6a1c5ebf54949564fa96102
7
- data.tar.gz: daf555d8f5bd48540354e9b80b5554e4bcfa600b51aa7c6227513bb7310845de1d74833076854d91491bb7b1335b47964d4454a1a17c1c7cbca16d2f21f78763
6
+ metadata.gz: 7c403421b59fde8fb7a27ca8448d43a1331b86d590199278b5bf26f7ae76c165220ab67d97bf6eff63c8a082aa1b3de59ab51e1b90968dbf7056c2db36182603
7
+ data.tar.gz: a03dba8b04f49b4dfa4a0127db26021f47d6d9ca550ef8bd0ac30c2578c660ac990701622e887120293369c7c2efdebd290c87a2cf8c4b6763ab9abe2a7b44fb
@@ -1,10 +1,39 @@
1
1
  module Mumukit::Metatest
2
2
  class Checker
3
- def check(result, example)
4
- example[:postconditions].each { |key, arg| check_assertion key, result, arg, example }
5
- [example[:name], :passed, render_success_output(result)]
3
+
4
+ ## Check an input against a metatest example.
5
+ ## The example has the following shape:
6
+ ##
7
+ ## ```
8
+ ## {
9
+ ## name: 'an example name',
10
+ ## postconditions: {
11
+ ## an_assertion: assertion_config,
12
+ ## another_assertion: assertion_config,
13
+ ## }
14
+ ## }
15
+ ## ```
16
+ ##
17
+ ## Alternatively, the `postconditions` key may be omitted:
18
+ ##
19
+ ## ```
20
+ ## {
21
+ ## name: 'an example name',
22
+ ## an_assertion: assertion_config,
23
+ ## another_assertion: assertion_config,
24
+ ## }
25
+ ##
26
+ def check(input, example)
27
+ check_assertions input, postconditions_for(example), example
28
+ [example[:name], :passed, render_success_output(input)]
6
29
  rescue => e
7
- [example[:name], :failed, render_error_output(result, e.message)]
30
+ [example[:name], :failed, render_error_output(input, e.message)]
31
+ end
32
+
33
+ ## If no postconditions are included in the example,
34
+ ## all the example except by the name is considered as postconditions
35
+ def postconditions_for(example)
36
+ example[:postconditions] || example.except(:name)
8
37
  end
9
38
 
10
39
  def render_success_output(value)
@@ -15,8 +44,14 @@ module Mumukit::Metatest
15
44
  error
16
45
  end
17
46
 
18
- def check_assertion(key, result, arg, example)
19
- send "check_#{key}", result, arg
47
+ def check_assertions(input, assertions_hash, example)
48
+ assertions_hash.each do |assertion_name, assertion_config|
49
+ check_assertion assertion_name, input, assertion_config, example
50
+ end
51
+ end
52
+
53
+ def check_assertion(assertion_name, input, assertion_config, _example)
54
+ send "check_#{assertion_name}", input, assertion_config
20
55
  end
21
56
 
22
57
  def fail(message)
@@ -31,4 +66,4 @@ module Mumukit::Metatest
31
66
  raise Mumukit::Metatest::Errored, message
32
67
  end
33
68
  end
34
- end
69
+ end
@@ -1,3 +1,3 @@
1
1
  module Mumukit
2
- VERSION = '2.26.0'
2
+ VERSION = '2.27.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumukit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.26.0
4
+ version: 2.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Leonardo Bulgarelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-14 00:00:00.000000000 Z
11
+ date: 2018-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler