spectus 2.0.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +12 -0
- data/README.md +51 -11
- data/Rakefile +0 -1
- data/VERSION.semver +1 -1
- data/lib/spectus.rb +3 -3
- data/lib/spectus/challenge.rb +22 -0
- data/lib/spectus/expectation_target.rb +35 -39
- data/lib/spectus/level/base.rb +72 -0
- data/lib/spectus/level/high.rb +25 -0
- data/lib/spectus/level/low.rb +25 -0
- data/lib/spectus/level/medium.rb +25 -0
- data/lib/spectus/result/base.rb +83 -0
- data/lib/spectus/result/fail.rb +28 -0
- data/lib/spectus/result/pass.rb +30 -0
- data/lib/spectus/sandbox.rb +24 -8
- data/spectus.gemspec +10 -10
- data/test/support/coverage.rb +3 -0
- data/test/test_high_fail.rb +140 -0
- data/test/test_high_pass.rb +44 -0
- data/test/test_low_fail.rb +51 -0
- data/test/test_low_pass.rb +47 -0
- data/test/test_medium_fail.rb +50 -0
- data/test/test_medium_pass.rb +82 -0
- metadata +72 -89
- metadata.gz.sig +0 -0
- data/lib/spectus/matcher.rb +0 -20
- data/lib/spectus/requirement.rb +0 -29
- data/lib/spectus/requirement_level/high.rb +0 -16
- data/lib/spectus/requirement_level/low.rb +0 -22
- data/lib/spectus/requirement_level/medium.rb +0 -22
metadata.gz.sig
CHANGED
Binary file
|
data/lib/spectus/matcher.rb
DELETED
@@ -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
|
data/lib/spectus/requirement.rb
DELETED
@@ -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
|