spectus 2.0.3 → 2.1.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.
metadata.gz.sig CHANGED
Binary file
@@ -1,20 +0,0 @@
1
- require 'matchi'
2
-
3
- module Spectus
4
- # This module provides matchers to define expectations.
5
- module Matcher
6
- # Evaluate the expectation with the passed block.
7
- #
8
- # @param [Hash, Symbol] definition
9
- #
10
- # @return [Boolean] report if the expectation is true or false
11
- def self.pass?(definition, &actual)
12
- params = Array(definition).flatten(1)
13
- name = params.first.to_s.split('_').map(&:capitalize).join.to_sym
14
- expected_args = params[1..-1]
15
- matcher = Matchi.const_get(name).new(*expected_args)
16
-
17
- matcher.matches?(&actual)
18
- end
19
- end
20
- end
@@ -1,29 +0,0 @@
1
- require_relative 'sandbox'
2
-
3
- module Spectus
4
- # Requirement level's base class.
5
- #
6
- # @api private
7
- #
8
- class Requirement < BasicObject
9
- # Initialize the requirement level class.
10
- #
11
- # @param [Hash] definition
12
- # @param [Boolean] negate
13
- def initialize(definition, negate = false)
14
- @definition = definition
15
- @negate = negate
16
- end
17
-
18
- protected
19
-
20
- # Run the actual block against the definition.
21
- #
22
- # @yieldparam actual the value which is compared with the expected value.
23
- #
24
- # @return [Boolean] report if the expectation is true or false.
25
- def sandbox(&actual)
26
- Sandbox.new(@definition, @negate, &actual)
27
- end
28
- end
29
- end
@@ -1,16 +0,0 @@
1
- require_relative File.join '..', 'requirement'
2
-
3
- module Spectus
4
- # Contains requirement levels.
5
- module RequirementLevel
6
- # _High_ requirement level.
7
- class High < Requirement
8
- # Evaluate the expectation with the passed block.
9
- #
10
- # @return [Boolean] report if the expectation is true or false.
11
- def pass?(&actual)
12
- sandbox(&actual).pass?
13
- end
14
- end
15
- end
16
- end
@@ -1,22 +0,0 @@
1
- require_relative File.join '..', 'requirement'
2
-
3
- module Spectus
4
- # Contains requirement levels.
5
- module RequirementLevel
6
- # _Low_ requirement level.
7
- class Low < Requirement
8
- # Evaluate the expectation with the passed block.
9
- #
10
- # @return [Boolean] report if the expectation is true or false.
11
- def pass?(&actual)
12
- result = sandbox(&actual)
13
-
14
- if result.exception.class.equal?(::NoMethodError)
15
- true
16
- else
17
- result.pass?
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,22 +0,0 @@
1
- require_relative File.join '..', 'requirement'
2
-
3
- module Spectus
4
- # Contains requirement levels.
5
- module RequirementLevel
6
- # _Medium_ requirement level.
7
- class Medium < Requirement
8
- # Evaluate the expectation with the passed block.
9
- #
10
- # @return [Boolean] report if the expectation is true or false.
11
- def pass?(&actual)
12
- result = sandbox(&actual)
13
-
14
- if result.pass?
15
- true
16
- else
17
- result.exception.nil?
18
- end
19
- end
20
- end
21
- end
22
- end