spectus 3.1.2 → 3.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.md +1 -1
- data/README.md +9 -9
- data/lib/spectus.rb +2 -2
- data/lib/spectus/exam.rb +1 -1
- data/lib/spectus/expectation_target.rb +3 -3
- data/lib/spectus/requirement_level/base.rb +4 -4
- data/lib/spectus/requirement_level/may.rb +1 -1
- data/lib/spectus/requirement_level/must.rb +1 -1
- data/lib/spectus/requirement_level/should.rb +1 -1
- data/lib/spectus/result/common.rb +2 -2
- data/lib/spectus/result/fail.rb +5 -5
- data/lib/spectus/result/pass.rb +7 -7
- metadata +55 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee7d9fda32871f2db5571569f0b85a63edb9cdd4abb7149059bca0e218383a07
|
4
|
+
data.tar.gz: 530aefebbfedcea834fec61c14e79b79a4e71930a059c51de314c85c8264a299
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42d8f625fd2f0057416a41e3c46decefee155a24679443851882c36513fc8765c1ca437800ee94a031a11edf30ff81758f36e87e08959dbbefd64cc8d94ffbd9
|
7
|
+
data.tar.gz: b6607f0a2309f8dae7ceac5e8dc82bd2733b6289610a5b67ae258889395c15e496de38a13978726670a371bb9668eaf3a4f83e576d94e102f5b3b603d2ae558a
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
Add this line to your application's Gemfile:
|
14
14
|
|
15
15
|
```ruby
|
16
|
-
gem
|
16
|
+
gem "spectus"
|
17
17
|
```
|
18
18
|
|
19
19
|
And then execute:
|
@@ -59,8 +59,8 @@ Example of test without isolation:
|
|
59
59
|
|
60
60
|
```ruby
|
61
61
|
include Spectus
|
62
|
-
greeting =
|
63
|
-
it { greeting.gsub!(
|
62
|
+
greeting = "Hello, world!"
|
63
|
+
it { greeting.gsub!("world", "Alice") }.MUST eql "Hello, Alice!"
|
64
64
|
# => Spectus::Result::Pass(actual: "Hello, Alice!", error: nil, expected: "Hello, Alice!", got: true, matcher: :eql, negate: false, level: :MUST, valid: true)
|
65
65
|
greeting # => "Hello, Alice!"
|
66
66
|
```
|
@@ -69,8 +69,8 @@ Example of test in isolation:
|
|
69
69
|
|
70
70
|
```ruby
|
71
71
|
include Spectus
|
72
|
-
greeting =
|
73
|
-
it { greeting.gsub!(
|
72
|
+
greeting = "Hello, world!"
|
73
|
+
it { greeting.gsub!("world", "Alice") }.MUST! eql "Hello, Alice!"
|
74
74
|
# => Spectus::Result::Pass(actual: "Hello, Alice!", error: nil, expected: "Hello, Alice!", got: true, matcher: :eql, negate: false, level: :MUST, valid: true)
|
75
75
|
greeting # => "Hello, world!"
|
76
76
|
```
|
@@ -88,7 +88,7 @@ include Spectus
|
|
88
88
|
Given the "`ルビー`" object, when it receives `valid_encoding?` method, then it **MUST** be `true`:
|
89
89
|
|
90
90
|
```ruby
|
91
|
-
it {
|
91
|
+
it { "ルビー".valid_encoding? }.MUST be_true
|
92
92
|
# => Spectus::Result::Pass(actual: true, error: nil, expected: nil, got: true, matcher: :be_true, negate: false, level: :MUST, valid: true)
|
93
93
|
```
|
94
94
|
|
@@ -99,7 +99,7 @@ The result of the test shows that the spec passed.
|
|
99
99
|
Given the "`foo`" object, when it receives `length` method, then it **MUST NOT** raise the `NoMethodError` exception:
|
100
100
|
|
101
101
|
```ruby
|
102
|
-
it {
|
102
|
+
it { "foo".length }.MUST_NOT raise_exception NoMethodError
|
103
103
|
# => Spectus::Result::Pass(actual: 3, error: nil, expected: NoMethodError, got: true, matcher: :raise_exception, negate: true, level: :MUST, valid: true)
|
104
104
|
```
|
105
105
|
|
@@ -122,7 +122,7 @@ However, because there isn't any exception, the result of the test shows that th
|
|
122
122
|
Given the "`1`" object, when it receives `+(1)` method, then it **SHOULD NOT** return the "`11`" value:
|
123
123
|
|
124
124
|
```ruby
|
125
|
-
it {
|
125
|
+
it { "1" + 1 }.SHOULD_NOT eql "11"
|
126
126
|
# raise Spectus::Result::Fail(actual: nil, error: #<TypeError: no implicit conversion of Integer into String>, expected: "11", got: nil, matcher: :eql, negate: true, level: :SHOULD, valid: false)
|
127
127
|
```
|
128
128
|
|
@@ -133,7 +133,7 @@ There was a `TypeError` exception, the result of the test shows that the spec fa
|
|
133
133
|
Given the "`foo`" object, when it receives `blank?` method, then it **MAY** be `false`:
|
134
134
|
|
135
135
|
```ruby
|
136
|
-
it {
|
136
|
+
it { "foo".blank? }.MAY be_false
|
137
137
|
# => Spectus::Result::Pass(actual: nil, error: #<NoMethodError: undefined method `blank?' for "foo":String>, expected: nil, got: nil, matcher: :be_false, negate: false, level: :MAY, valid: false)
|
138
138
|
```
|
139
139
|
|
data/lib/spectus.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "matchi/helper"
|
4
4
|
|
5
5
|
# Namespace for the Spectus library.
|
6
6
|
#
|
@@ -23,4 +23,4 @@ module Spectus
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
require_relative File.join(
|
26
|
+
require_relative File.join("spectus", "expectation_target")
|
data/lib/spectus/exam.rb
CHANGED
@@ -193,6 +193,6 @@ module Spectus
|
|
193
193
|
end
|
194
194
|
end
|
195
195
|
|
196
|
-
require_relative File.join(
|
197
|
-
require_relative File.join(
|
198
|
-
require_relative File.join(
|
196
|
+
require_relative File.join("requirement_level", "must")
|
197
|
+
require_relative File.join("requirement_level", "should")
|
198
|
+
require_relative File.join("requirement_level", "may")
|
@@ -65,7 +65,7 @@ module Spectus
|
|
65
65
|
|
66
66
|
# @return [Symbol] The requirement level.
|
67
67
|
def level
|
68
|
-
self.class.name.split(
|
68
|
+
self.class.name.split("::").fetch(-1).upcase.to_sym
|
69
69
|
end
|
70
70
|
|
71
71
|
# @note The boolean comparison between the actual value and the expected
|
@@ -79,6 +79,6 @@ module Spectus
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
require_relative File.join(
|
83
|
-
require_relative File.join(
|
84
|
-
require_relative File.join(
|
82
|
+
require_relative File.join("..", "exam")
|
83
|
+
require_relative File.join("..", "result", "fail")
|
84
|
+
require_relative File.join("..", "result", "pass")
|
@@ -97,14 +97,14 @@ module Spectus
|
|
97
97
|
#
|
98
98
|
# @return [String] A readable string of the definition.
|
99
99
|
def definition
|
100
|
-
[matcher, expected&.inspect].compact.join(
|
100
|
+
[matcher, expected&.inspect].compact.join(" ")
|
101
101
|
end
|
102
102
|
|
103
103
|
# The negation, if any.
|
104
104
|
#
|
105
105
|
# @return [String] The negation, or an empty string.
|
106
106
|
def maybe_negate
|
107
|
-
negate? ?
|
107
|
+
negate? ? " not" : ""
|
108
108
|
end
|
109
109
|
|
110
110
|
# The summary of the result.
|
data/lib/spectus/result/fail.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "common"
|
4
4
|
|
5
5
|
module Spectus
|
6
6
|
module Result
|
@@ -55,9 +55,9 @@ module Spectus
|
|
55
55
|
# @return [String] The char that identify the result.
|
56
56
|
def char
|
57
57
|
if failure?
|
58
|
-
|
58
|
+
"F"
|
59
59
|
else
|
60
|
-
|
60
|
+
"E"
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -66,9 +66,9 @@ module Spectus
|
|
66
66
|
# @return [String] The emoji that identify the result.
|
67
67
|
def emoji
|
68
68
|
if failure?
|
69
|
-
|
69
|
+
"❌"
|
70
70
|
else
|
71
|
-
|
71
|
+
"💥"
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
data/lib/spectus/result/pass.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "common"
|
4
4
|
|
5
5
|
module Spectus
|
6
6
|
module Result
|
@@ -60,11 +60,11 @@ module Spectus
|
|
60
60
|
# @return [String] The char that identify the result.
|
61
61
|
def char
|
62
62
|
if success?
|
63
|
-
|
63
|
+
"."
|
64
64
|
elsif warning?
|
65
|
-
|
65
|
+
"W"
|
66
66
|
else
|
67
|
-
|
67
|
+
"I"
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -73,11 +73,11 @@ module Spectus
|
|
73
73
|
# @return [String] The emoji that identify the result.
|
74
74
|
def emoji
|
75
75
|
if success?
|
76
|
-
|
76
|
+
"✅"
|
77
77
|
elsif warning?
|
78
|
-
|
78
|
+
"⚠️"
|
79
79
|
else
|
80
|
-
|
80
|
+
"💡"
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spectus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Kato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: defi
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0.
|
19
|
+
version: 2.0.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.0.
|
26
|
+
version: 2.0.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: matchi
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,46 +42,46 @@ dependencies:
|
|
42
42
|
name: brutal
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop
|
84
|
+
name: rubocop-md
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -108,34 +108,62 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop-thread_safety
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
140
|
name: simplecov
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
114
142
|
requirements:
|
115
|
-
- - "
|
143
|
+
- - ">="
|
116
144
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0
|
145
|
+
version: '0'
|
118
146
|
type: :development
|
119
147
|
prerelease: false
|
120
148
|
version_requirements: !ruby/object:Gem::Requirement
|
121
149
|
requirements:
|
122
|
-
- - "
|
150
|
+
- - ">="
|
123
151
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0
|
152
|
+
version: '0'
|
125
153
|
- !ruby/object:Gem::Dependency
|
126
154
|
name: yard
|
127
155
|
requirement: !ruby/object:Gem::Requirement
|
128
156
|
requirements:
|
129
|
-
- - "
|
157
|
+
- - ">="
|
130
158
|
- !ruby/object:Gem::Version
|
131
|
-
version: '0
|
159
|
+
version: '0'
|
132
160
|
type: :development
|
133
161
|
prerelease: false
|
134
162
|
version_requirements: !ruby/object:Gem::Requirement
|
135
163
|
requirements:
|
136
|
-
- - "
|
164
|
+
- - ">="
|
137
165
|
- !ruby/object:Gem::Version
|
138
|
-
version: '0
|
166
|
+
version: '0'
|
139
167
|
description: "Expectation library with RFC 2119's requirement levels \U0001F6A5"
|
140
168
|
email: contact@cyril.email
|
141
169
|
executables: []
|
@@ -166,14 +194,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
166
194
|
requirements:
|
167
195
|
- - ">="
|
168
196
|
- !ruby/object:Gem::Version
|
169
|
-
version: 2.
|
197
|
+
version: 2.7.0
|
170
198
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
199
|
requirements:
|
172
200
|
- - ">="
|
173
201
|
- !ruby/object:Gem::Version
|
174
202
|
version: '0'
|
175
203
|
requirements: []
|
176
|
-
rubygems_version: 3.1.
|
204
|
+
rubygems_version: 3.1.4
|
177
205
|
signing_key:
|
178
206
|
specification_version: 4
|
179
207
|
summary: "Expectation library with RFC 2119's requirement levels \U0001F6A5"
|