spectus 3.0.10 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +66 -77
- data/lib/spectus.rb +2 -4
- data/lib/spectus/exam.rb +56 -0
- data/lib/spectus/expectation_target.rb +87 -70
- data/lib/spectus/requirement_level/base.rb +48 -73
- data/lib/spectus/requirement_level/may.rb +17 -0
- data/lib/spectus/requirement_level/must.rb +17 -0
- data/lib/spectus/requirement_level/should.rb +17 -0
- data/lib/spectus/result/common.rb +174 -0
- data/lib/spectus/result/fail.rb +40 -17
- data/lib/spectus/result/pass.rb +48 -21
- metadata +22 -24
- data/lib/spectus/matchers.rb +0 -33
- data/lib/spectus/report.rb +0 -92
- data/lib/spectus/requirement_level/high.rb +0 -27
- data/lib/spectus/requirement_level/low.rb +0 -27
- data/lib/spectus/requirement_level/medium.rb +0 -27
- data/lib/spectus/result/base.rb +0 -112
- data/lib/spectus/sandbox.rb +0 -61
data/lib/spectus/sandbox.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Spectus
|
4
|
-
# This class evaluate the expectation with the passed block.
|
5
|
-
#
|
6
|
-
# @api private
|
7
|
-
#
|
8
|
-
class Sandbox
|
9
|
-
# rubocop:disable Style/RescueStandardError
|
10
|
-
|
11
|
-
# Execute the untested code from the passed block against the matcher.
|
12
|
-
#
|
13
|
-
# @param matcher [#matches?] The matcher.
|
14
|
-
# @param negate [Boolean] The negation of the matcher's result.
|
15
|
-
# @param object [#object_id] The front object which is challenged.
|
16
|
-
# @param challenges [Array] The list of challenges.
|
17
|
-
def initialize(matcher, negate, object, *challenges)
|
18
|
-
@got = negate ^ matcher.matches? do
|
19
|
-
@actual = challenges.inject(object) do |subject, challenge|
|
20
|
-
@last_challenge = challenge
|
21
|
-
@last_challenge.to(subject)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
rescue => e
|
25
|
-
@exception = e
|
26
|
-
end
|
27
|
-
|
28
|
-
# rubocop:enable Style/RescueStandardError
|
29
|
-
|
30
|
-
# @!attribute [r] last_challenge
|
31
|
-
#
|
32
|
-
# @return [Defi::Challenge] The last evaluated challenge.
|
33
|
-
attr_reader :last_challenge
|
34
|
-
|
35
|
-
# @!attribute [r] actual
|
36
|
-
#
|
37
|
-
# @return [#object_id] The value that the subject return through its
|
38
|
-
# challenge.
|
39
|
-
attr_reader :actual
|
40
|
-
|
41
|
-
# @!attribute [r] exception
|
42
|
-
#
|
43
|
-
# @return [#exception, nil] Any possible raised exception.
|
44
|
-
attr_reader :exception
|
45
|
-
|
46
|
-
# @!attribute [r] got
|
47
|
-
#
|
48
|
-
# @return [#object_id] The result of the boolean comparison between the
|
49
|
-
# actual value and the expected value.
|
50
|
-
attr_reader :got
|
51
|
-
|
52
|
-
# Report to the spec's requirement level if the test is true or false.
|
53
|
-
#
|
54
|
-
# @return [Boolean] Report if the test was true or false.
|
55
|
-
def valid?
|
56
|
-
return false if defined?(@exception)
|
57
|
-
|
58
|
-
got
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|