spectus 2.7.1 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -2
- data/.rubocop.yml +1 -12
- data/.rubocop_todo.yml +29 -0
- data/VERSION.semver +1 -1
- data/checksum/spectus-2.7.1.gem.sha512 +1 -0
- data/lib/spectus.rb +2 -2
- data/lib/spectus/expectation_target.rb +6 -3
- data/lib/spectus/level/base.rb +41 -67
- data/lib/spectus/report.rb +110 -0
- data/lib/spectus/result/base.rb +2 -2
- data/lib/spectus/sandbox.rb +1 -1
- data/spectus.gemspec +1 -1
- metadata +8 -5
- metadata.gz.sig +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9c5f017cdf442b8b5b030ba4a89faec996d46d0
|
4
|
+
data.tar.gz: e92e7bce6997f75a1932d8593cf21e0150e95d08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ccc7b4ab0aea3ee90b6a9cb28fe62e7d4458118df8cb34ccdbf3fdd530cf1fce8f0c1aab2a9884df30f99a1586708bc071ce5056fb8277d4d94b6e7f7c3ee0e
|
7
|
+
data.tar.gz: 62c3f9dd0ab650be6226c5564f4df238876683175b9cd20694467674dc6533afcae2f07aef42f4908390a2a56244349dabbf719a9c243af7798b896881df2b94
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
�
|
2
|
-
/x��7��F����=){QЇ��%����{�����=�~�=^��ȹ�2��
|
1
|
+
H���{Û8�A�X��E 5J�T4�p�x1�Bx?+Z�Qs�aZ�0+��G8�:�\�|@��W��'�7����dD�AR;� j�x%�@D�#vU�XX;Cy�:��Lu͚�]��Eۏ��$�T<����O�Qm(1Jl_��?7Ѫ���Y�ēLJD�~�1 M7S���ѭ4�KX��g�ͨl }��J��g���TP�� C�O<�ٷ��j�5d���Ls{��t�6T����Qw���%$W+F��r�����X_�
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2015-10-10 17:44:08 +0200 using RuboCop version 0.34.2.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Max: 18
|
12
|
+
|
13
|
+
# Offense count: 4
|
14
|
+
# Configuration parameters: CountComments.
|
15
|
+
Metrics/MethodLength:
|
16
|
+
Max: 12
|
17
|
+
|
18
|
+
# Offense count: 1
|
19
|
+
# Configuration parameters: CountKeywordArgs.
|
20
|
+
Metrics/ParameterLists:
|
21
|
+
Max: 10
|
22
|
+
|
23
|
+
# Offense count: 2
|
24
|
+
# Cop supports --auto-correct.
|
25
|
+
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist.
|
26
|
+
Style/TrivialAccessors:
|
27
|
+
Exclude:
|
28
|
+
- 'lib/spectus/level/base.rb'
|
29
|
+
- 'lib/spectus/report.rb'
|
data/VERSION.semver
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.8.0
|
@@ -0,0 +1 @@
|
|
1
|
+
7d429237e89c48a3f04e6299578fb5663b977b4191bbe99c6d0db155a06b85bd8a1985e06b18794f36e9320f05743d145ae16bf8e34beef341e7a0c56491fc93
|
data/lib/spectus.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require_relative File.join 'spectus', 'expectation_target'
|
2
|
-
|
3
1
|
# Namespace for the Spectus library.
|
4
2
|
#
|
5
3
|
# @api public
|
@@ -19,3 +17,5 @@ module Spectus
|
|
19
17
|
ExpectationTarget.new(&input)
|
20
18
|
end
|
21
19
|
end
|
20
|
+
|
21
|
+
require_relative File.join 'spectus', 'expectation_target'
|
@@ -1,6 +1,3 @@
|
|
1
|
-
require_relative File.join 'level', 'high'
|
2
|
-
require_relative File.join 'level', 'medium'
|
3
|
-
require_relative File.join 'level', 'low'
|
4
1
|
require 'defi'
|
5
2
|
|
6
3
|
module Spectus
|
@@ -27,6 +24,8 @@ module Spectus
|
|
27
24
|
# @return [Array] The challenges to call on the subject.
|
28
25
|
attr_reader :challenges
|
29
26
|
|
27
|
+
# rubocop:disable Style/MethodName
|
28
|
+
|
30
29
|
# This word, or the terms "REQUIRED" or "SHALL", mean that the
|
31
30
|
# definition is an absolute requirement of the specification.
|
32
31
|
#
|
@@ -107,3 +106,7 @@ module Spectus
|
|
107
106
|
end
|
108
107
|
end
|
109
108
|
end
|
109
|
+
|
110
|
+
require_relative File.join 'level', 'high'
|
111
|
+
require_relative File.join 'level', 'medium'
|
112
|
+
require_relative File.join 'level', 'low'
|
data/lib/spectus/level/base.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
require_relative File.join '..', 'sandbox'
|
2
|
-
require_relative File.join '..', 'result', 'fail'
|
3
|
-
require_relative File.join '..', 'result', 'pass'
|
4
|
-
|
5
1
|
module Spectus
|
6
2
|
# Namespace for the requirement levels.
|
7
3
|
#
|
@@ -24,21 +20,46 @@ module Spectus
|
|
24
20
|
@challenges = challenges
|
25
21
|
end
|
26
22
|
|
23
|
+
# @!attribute [r] req
|
24
|
+
#
|
25
|
+
# @return [Hash, Symbol] The definition of the expected value.
|
26
|
+
attr_reader :req
|
27
|
+
|
28
|
+
# The value of the negate instance variable.
|
29
|
+
#
|
30
|
+
# @return [Boolean] Evaluated to a negative assertion or not.
|
31
|
+
def negate?
|
32
|
+
@negate
|
33
|
+
end
|
34
|
+
|
35
|
+
# @!attribute [r] subject
|
36
|
+
#
|
37
|
+
# @return [#object_id] The front object to test.
|
38
|
+
attr_reader :subject
|
39
|
+
|
40
|
+
# @!attribute [r] challenges
|
41
|
+
#
|
42
|
+
# @return [Array] A list of challenges.
|
43
|
+
attr_reader :challenges
|
44
|
+
|
27
45
|
protected
|
28
46
|
|
29
47
|
# @param state [Sandbox] The sandbox that tested the code.
|
30
48
|
#
|
31
49
|
# @return [Result::Pass] Pass the spec.
|
32
50
|
def pass!(state)
|
33
|
-
|
51
|
+
msg = Report.new(req, negate?, state, true)
|
52
|
+
|
53
|
+
Result::Pass.new(msg, *result_signature(state))
|
34
54
|
end
|
35
55
|
|
36
56
|
# @param state [Sandbox] The sandbox that tested the code.
|
37
57
|
#
|
38
58
|
# @raise [Result::Fail] Fail the spec.
|
39
59
|
def fail!(state)
|
40
|
-
|
41
|
-
|
60
|
+
msg = Report.new(req, negate?, state, false)
|
61
|
+
|
62
|
+
fail Result::Fail.new(msg, *result_signature(state)), msg, caller[2..-1]
|
42
63
|
end
|
43
64
|
|
44
65
|
# @param state [Sandbox] The sandbox that tested the code.
|
@@ -46,14 +67,14 @@ module Spectus
|
|
46
67
|
# @return [Array] List of parameters.
|
47
68
|
def result_signature(state)
|
48
69
|
[
|
49
|
-
|
70
|
+
subject,
|
50
71
|
state.last_challenge,
|
51
72
|
state.actual,
|
52
|
-
|
73
|
+
req,
|
53
74
|
state.got,
|
54
75
|
state.exception,
|
55
76
|
level,
|
56
|
-
|
77
|
+
negate?,
|
57
78
|
state.valid?
|
58
79
|
]
|
59
80
|
end
|
@@ -65,69 +86,17 @@ module Spectus
|
|
65
86
|
|
66
87
|
# @return [Sandbox] The sandbox.
|
67
88
|
def sandbox
|
68
|
-
|
69
|
-
fork_and_return { Sandbox.new(@req, @negate, @subject, *@challenges) }
|
70
|
-
else
|
71
|
-
Sandbox.new(@req, @negate, @subject, *@challenges)
|
72
|
-
end
|
89
|
+
Process.respond_to?(:fork) ? fork_and_return { execute } : execute
|
73
90
|
end
|
74
91
|
|
75
|
-
# @
|
76
|
-
|
77
|
-
|
78
|
-
# @return [String] The message that describe the state.
|
79
|
-
def message(state, result)
|
80
|
-
"#{title(state, result)}: #{summary(state)}."
|
81
|
-
end
|
82
|
-
|
83
|
-
# The title of the state.
|
84
|
-
#
|
85
|
-
# @param state [Sandbox] The sandbox that tested the code.
|
86
|
-
# @param result [Boolean] The result of the test.
|
87
|
-
#
|
88
|
-
# @return [String] The title of the state.
|
89
|
-
def title(state, result)
|
90
|
-
if result
|
91
|
-
state.got ? 'Pass' : 'Info'
|
92
|
-
else
|
93
|
-
state.exception.nil? ? 'Failure' : 'Error'
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
# The summary of the state.
|
98
|
-
#
|
99
|
-
# @param state [Sandbox] The sandbox that tested the code.
|
100
|
-
#
|
101
|
-
# @return [String] The summary of the state.
|
102
|
-
def summary(state)
|
103
|
-
if state.valid? || state.exception.nil?
|
104
|
-
'Expected ' + state.actual.inspect + (@negate ? ' not ' : ' ') +
|
105
|
-
'to ' + if @req.is_a?(Hash)
|
106
|
-
readable(@req.keys.first) + ' ' +
|
107
|
-
@req.values.first.inspect
|
108
|
-
else
|
109
|
-
readable(@req)
|
110
|
-
end
|
111
|
-
else
|
112
|
-
state.exception.message
|
113
|
-
end + (state.exception.nil? ? '' : " (#{state.exception.class})")
|
114
|
-
end
|
115
|
-
|
116
|
-
# @param st [#to_s] A UpperCamelCase string.
|
117
|
-
#
|
118
|
-
# @return [String] The snake_case string.
|
119
|
-
def readable(st)
|
120
|
-
st.to_s
|
121
|
-
.gsub(/::/, '/')
|
122
|
-
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
123
|
-
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
124
|
-
.tr('-_', ' ')
|
125
|
-
.downcase
|
92
|
+
# @return [Sandbox] The sandbox.
|
93
|
+
def execute
|
94
|
+
Sandbox.new(req, negate?, subject, *challenges)
|
126
95
|
end
|
127
96
|
|
128
97
|
# Run the code in a separate process.
|
129
98
|
#
|
130
|
-
# @
|
99
|
+
# @yieldreturn [Sandbox] Execute the untested code in the sandbox.
|
131
100
|
def fork_and_return
|
132
101
|
read, write = IO.pipe
|
133
102
|
|
@@ -146,3 +115,8 @@ module Spectus
|
|
146
115
|
end
|
147
116
|
end
|
148
117
|
end
|
118
|
+
|
119
|
+
require_relative File.join '..', 'report'
|
120
|
+
require_relative File.join '..', 'result', 'fail'
|
121
|
+
require_relative File.join '..', 'result', 'pass'
|
122
|
+
require_relative File.join '..', 'sandbox'
|
@@ -0,0 +1,110 @@
|
|
1
|
+
module Spectus
|
2
|
+
# The class that is responsible for reporting the result of the test.
|
3
|
+
#
|
4
|
+
# @api private
|
5
|
+
#
|
6
|
+
class Report
|
7
|
+
# Initialize the report class.
|
8
|
+
#
|
9
|
+
# @param req [Hash, Symbol] The definition of the expected value.
|
10
|
+
# @param negate [Boolean] Evaluate to a negative assertion.
|
11
|
+
# @param state [Sandbox] The sandbox that tested the code.
|
12
|
+
# @param result [Boolean] The result of the test.
|
13
|
+
def initialize(req, negate, state, result)
|
14
|
+
@req = req
|
15
|
+
@negate = negate
|
16
|
+
@state = state
|
17
|
+
@result = result
|
18
|
+
end
|
19
|
+
|
20
|
+
# @!attribute [r] req
|
21
|
+
#
|
22
|
+
# @return [Hash, Symbol] The definition of the expected value.
|
23
|
+
attr_reader :req
|
24
|
+
|
25
|
+
# The value of the negate instance variable.
|
26
|
+
#
|
27
|
+
# @return [Boolean] Evaluated to a negative assertion or not.
|
28
|
+
def negate?
|
29
|
+
@negate
|
30
|
+
end
|
31
|
+
|
32
|
+
# @!attribute [r] state
|
33
|
+
#
|
34
|
+
# @return [Sandbox] The sandbox that tested the code.
|
35
|
+
attr_reader :state
|
36
|
+
|
37
|
+
# @!attribute [r] result
|
38
|
+
#
|
39
|
+
# @return [Boolean] The result of the test.
|
40
|
+
attr_reader :result
|
41
|
+
|
42
|
+
# The message.
|
43
|
+
#
|
44
|
+
# @return [String] The message that describe the state.
|
45
|
+
def to_s
|
46
|
+
"#{title}: #{summary}#{maybe_exception}."
|
47
|
+
end
|
48
|
+
|
49
|
+
# The title of the state.
|
50
|
+
#
|
51
|
+
# @return [String] The title of the state.
|
52
|
+
def title
|
53
|
+
if result
|
54
|
+
state.got ? 'Pass' : 'Info'
|
55
|
+
else
|
56
|
+
state.exception.nil? ? 'Failure' : 'Error'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# The summary of the state.
|
61
|
+
#
|
62
|
+
# @return [String] The summary of the state.
|
63
|
+
def summary
|
64
|
+
return state.exception.message unless state.valid? || state.exception.nil?
|
65
|
+
|
66
|
+
'Expected ' + state.actual.inspect + maybe_negate + ' to ' + definition
|
67
|
+
end
|
68
|
+
|
69
|
+
# The negation, if any.
|
70
|
+
#
|
71
|
+
# @return [String] The negation, or an empty string.
|
72
|
+
def maybe_negate
|
73
|
+
negate? ? ' not' : ''
|
74
|
+
end
|
75
|
+
|
76
|
+
# The type of exception, if any.
|
77
|
+
#
|
78
|
+
# @return [String] The type of exception, or an empty string.
|
79
|
+
def maybe_exception
|
80
|
+
state.exception.nil? ? '' : " (#{state.exception.class})"
|
81
|
+
end
|
82
|
+
|
83
|
+
# The readable definition.
|
84
|
+
#
|
85
|
+
# @return [String] The readable definition string.
|
86
|
+
def definition
|
87
|
+
if req.is_a?(Hash)
|
88
|
+
snake_case(req.keys.first) + ' ' + req.values.first.inspect
|
89
|
+
else
|
90
|
+
snake_case(req)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
# @api private
|
97
|
+
#
|
98
|
+
# @param st [#to_s] An UpperCamelCase string.
|
99
|
+
#
|
100
|
+
# @return [String] The snake_case string.
|
101
|
+
def snake_case(st)
|
102
|
+
st.to_s
|
103
|
+
.gsub(/::/, '/')
|
104
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
105
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
106
|
+
.tr('-_', ' ')
|
107
|
+
.downcase
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
data/lib/spectus/result/base.rb
CHANGED
@@ -9,7 +9,7 @@ module Spectus
|
|
9
9
|
module Base
|
10
10
|
# Initialize the result class.
|
11
11
|
#
|
12
|
-
# @param message [
|
12
|
+
# @param message [#to_s] It is describing the actual/error value.
|
13
13
|
# @param subject [#object_id] The untrusted object to be tested.
|
14
14
|
# @param challenge [Defi::Challenge] The challenge for the subject.
|
15
15
|
# @param actual [#object_id] The value that the subject return through
|
@@ -24,7 +24,7 @@ module Spectus
|
|
24
24
|
def initialize(message, subject, challenge, actual, expected, got, error,
|
25
25
|
level, negate, valid)
|
26
26
|
|
27
|
-
@message = message
|
27
|
+
@message = message.to_s
|
28
28
|
@subject = subject
|
29
29
|
@challenge = challenge
|
30
30
|
@actual = actual
|
data/lib/spectus/sandbox.rb
CHANGED
data/spectus.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency 'rake', '~> 10.4'
|
22
22
|
spec.add_development_dependency 'yard', '~> 0.8'
|
23
23
|
spec.add_development_dependency 'simplecov', '~> 0.10'
|
24
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
24
|
+
spec.add_development_dependency 'rubocop', '~> 0.34'
|
25
25
|
|
26
26
|
spec.cert_chain = ['certs/gem-fixrb-public_cert.pem']
|
27
27
|
private_key = File.expand_path('~/.ssh/gem-fixrb-private_key.pem')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spectus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Wack
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
dzJvWzQ1+dJU6WQv75E9ddSkaQrK3nhdgQVu+/wgvGSrsMvOGNz+LXaSDxQqZuwX
|
31
31
|
0KNQFuIukfrdk8URwRnHoAnvx4U93iUw
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2015-10-
|
33
|
+
date: 2015-10-10 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: defi
|
@@ -122,14 +122,14 @@ dependencies:
|
|
122
122
|
requirements:
|
123
123
|
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: '0.
|
125
|
+
version: '0.34'
|
126
126
|
type: :development
|
127
127
|
prerelease: false
|
128
128
|
version_requirements: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
130
|
- - "~>"
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: '0.
|
132
|
+
version: '0.34'
|
133
133
|
description: Expectation library with RFC 2119's requirement levels.
|
134
134
|
email:
|
135
135
|
- contact@cyril.email
|
@@ -139,6 +139,7 @@ extra_rdoc_files: []
|
|
139
139
|
files:
|
140
140
|
- ".gitignore"
|
141
141
|
- ".rubocop.yml"
|
142
|
+
- ".rubocop_todo.yml"
|
142
143
|
- ".travis.yml"
|
143
144
|
- ".yardopts"
|
144
145
|
- CODE_OF_CONDUCT.md
|
@@ -166,12 +167,14 @@ files:
|
|
166
167
|
- checksum/spectus-2.5.0.gem.sha512
|
167
168
|
- checksum/spectus-2.6.0.gem.sha512
|
168
169
|
- checksum/spectus-2.7.0.gem.sha512
|
170
|
+
- checksum/spectus-2.7.1.gem.sha512
|
169
171
|
- lib/spectus.rb
|
170
172
|
- lib/spectus/expectation_target.rb
|
171
173
|
- lib/spectus/level/base.rb
|
172
174
|
- lib/spectus/level/high.rb
|
173
175
|
- lib/spectus/level/low.rb
|
174
176
|
- lib/spectus/level/medium.rb
|
177
|
+
- lib/spectus/report.rb
|
175
178
|
- lib/spectus/result/base.rb
|
176
179
|
- lib/spectus/result/fail.rb
|
177
180
|
- lib/spectus/result/pass.rb
|
@@ -198,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
201
|
version: '0'
|
199
202
|
requirements: []
|
200
203
|
rubyforge_project:
|
201
|
-
rubygems_version: 2.4.5
|
204
|
+
rubygems_version: 2.4.5.1
|
202
205
|
signing_key:
|
203
206
|
specification_version: 4
|
204
207
|
summary: Expectation library with RFC 2119 keywords.
|
metadata.gz.sig
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
��'A!H���?r
|
2
|
+
�����>�n�O���.e�����ė銗 �.�:��X �
|
3
|
+
����TuZ)O�ۊ�����ʍ���s����w��N:ɤ�뜗��`D�l���/�b���>P�{{�ctn������,ю�\�����"3��W�kD��~��!%�N�e��h�ӫ�tMb�l��~�6�.㌔>�<Q��*,���:��C\�wzw��>^��5���W���b�qj��h�}iv�S"�q��4@
|