spectus 3.0.10 → 3.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,56 +1,81 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'base'
3
+ require_relative "common"
4
4
 
5
5
  module Spectus
6
6
  module Result
7
7
  # The class that is responsible for reporting that the expectation is true.
8
8
  class Pass
9
- include Base
9
+ include Common
10
10
 
11
- # @!attribute [r] message
12
- #
13
- # @return [String] The message that describe the state.
14
- attr_reader :message
11
+ # @return [Pass] A passed spec result.
12
+ def self.call(**details)
13
+ new(**details)
14
+ end
15
15
 
16
- # The value of the expectation of the spec.
16
+ alias message to_s
17
+
18
+ # Did the test fail?
17
19
  #
18
- # @return [Boolean] The spec was true.
19
- def result?
20
- true
20
+ # @return [Boolean] The spec passed or failed?
21
+ def failed?
22
+ false
21
23
  end
22
24
 
23
- # The state of success.
25
+ # The state of failure.
24
26
  #
25
- # @return [Boolean] The test was a success.
26
- def success?
27
- got.equal?(true)
27
+ # @return [Boolean] The test was a failure?
28
+ def failure?
29
+ false
28
30
  end
29
31
 
30
32
  # The state of info.
31
33
  #
32
- # @return [Boolean] The test was an info.
34
+ # @return [Boolean] The test was an info?
33
35
  def info?
34
- !success?
36
+ !error.nil?
37
+ end
38
+
39
+ # The state of warning.
40
+ #
41
+ # @return [Boolean] The test was a warning?
42
+ def warning?
43
+ got.equal?(false)
35
44
  end
36
45
 
37
46
  # Identify the state of the result.
38
47
  #
39
48
  # @return [Symbol] The identifier of the state.
40
49
  def to_sym
41
- success? ? :success : :info
50
+ return :success if success?
51
+ return :warning if warning?
52
+
53
+ :info
42
54
  end
43
55
 
44
56
  # Express the result with one char.
45
57
  #
46
- # @param color [Boolean] Enable the color.
47
- #
48
58
  # @return [String] The char that identify the result.
49
- def to_char(color = false)
59
+ def char
60
+ if success?
61
+ "."
62
+ elsif warning?
63
+ "W"
64
+ else
65
+ "I"
66
+ end
67
+ end
68
+
69
+ # Express the result with one emoji.
70
+ #
71
+ # @return [String] The emoji that identify the result.
72
+ def emoji
50
73
  if success?
51
- color ? "\e[32m.\e[0m" : '.'
74
+ ""
75
+ elsif warning?
76
+ "⚠️"
52
77
  else
53
- color ? "\e[33mI\e[0m" : 'I'
78
+ "💡"
54
79
  end
55
80
  end
56
81
  end
metadata CHANGED
@@ -1,87 +1,87 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spectus
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.10
4
+ version: 3.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Kato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-08 00:00:00.000000000 Z
11
+ date: 2021-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: aw
14
+ name: defi
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.6
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: 0.1.6
26
+ version: 2.0.4
27
27
  - !ruby/object:Gem::Dependency
28
- name: defi
28
+ name: matchi
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.1.5
33
+ version: 2.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.1.5
40
+ version: 2.0.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: matchi
42
+ name: brutal
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.0.4
48
- type: :runtime
47
+ version: '0'
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: 1.0.4
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: '2.0'
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: '2.0'
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: '13.0'
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: '13.0'
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,35 +108,63 @@ 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.17'
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.17'
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.9'
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.9'
139
- description: Expectation library with RFC 2119's requirement levels.
166
+ version: '0'
167
+ description: "Expectation library with RFC 2119's requirement levels \U0001F6A5"
140
168
  email: contact@cyril.email
141
169
  executables: []
142
170
  extensions: []
@@ -145,17 +173,16 @@ files:
145
173
  - LICENSE.md
146
174
  - README.md
147
175
  - lib/spectus.rb
176
+ - lib/spectus/exam.rb
148
177
  - lib/spectus/expectation_target.rb
149
- - lib/spectus/matchers.rb
150
- - lib/spectus/report.rb
151
178
  - lib/spectus/requirement_level/base.rb
152
- - lib/spectus/requirement_level/high.rb
153
- - lib/spectus/requirement_level/low.rb
154
- - lib/spectus/requirement_level/medium.rb
155
- - lib/spectus/result/base.rb
179
+ - lib/spectus/requirement_level/may.rb
180
+ - lib/spectus/requirement_level/must.rb
181
+ - lib/spectus/requirement_level/should.rb
182
+ - lib/spectus/result.rb
183
+ - lib/spectus/result/common.rb
156
184
  - lib/spectus/result/fail.rb
157
185
  - lib/spectus/result/pass.rb
158
- - lib/spectus/sandbox.rb
159
186
  homepage: https://github.com/fixrb/spectus
160
187
  licenses:
161
188
  - MIT
@@ -168,15 +195,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
195
  requirements:
169
196
  - - ">="
170
197
  - !ruby/object:Gem::Version
171
- version: '0'
198
+ version: 2.7.0
172
199
  required_rubygems_version: !ruby/object:Gem::Requirement
173
200
  requirements:
174
201
  - - ">="
175
202
  - !ruby/object:Gem::Version
176
203
  version: '0'
177
204
  requirements: []
178
- rubygems_version: 3.0.6
205
+ rubygems_version: 3.1.4
179
206
  signing_key:
180
207
  specification_version: 4
181
- summary: Expectation library with RFC 2119's requirement levels.
208
+ summary: "Expectation library with RFC 2119's requirement levels \U0001F6A5"
182
209
  test_files: []
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'matchi'
4
-
5
- module Spectus
6
- # The module includes the list of matcher methods.
7
- #
8
- # @api public
9
- #
10
- module Matchers
11
- ::Matchi::Matchers.constants.each do |const|
12
- name = const.to_s
13
- .gsub(/::/, '/')
14
- .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
15
- .gsub(/([a-z\d])([A-Z])/, '\1_\2')
16
- .downcase
17
-
18
- # Define a method for the given matcher.
19
- #
20
- # @example Given the `Matchi::Matchers::Equal::Matcher` matcher, its
21
- # method would be:
22
- #
23
- # def equal(expected)
24
- # Matchi::Matchers::Equal::Matcher.new(expected)
25
- # end
26
- #
27
- # @return [#matches?] The matcher.
28
- define_method name do |*args|
29
- ::Matchi::Matchers.const_get(const)::Matcher.new(*args)
30
- end
31
- end
32
- end
33
- end
@@ -1,92 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Spectus
4
- # The class that is responsible for reporting the result of the test.
5
- #
6
- # @api private
7
- #
8
- class Report
9
- # Initialize the report class.
10
- #
11
- # @param matcher [#matches?] The matcher.
12
- # @param negate [Boolean] Evaluate to a negative assertion.
13
- # @param state [Sandbox] The sandbox that tested the code.
14
- # @param result [Boolean] The result of the test.
15
- def initialize(matcher, negate, state, result)
16
- @matcher = matcher
17
- @negate = negate
18
- @state = state
19
- @result = result
20
- end
21
-
22
- # @!attribute [r] matcher
23
- #
24
- # @return [#matches?] The matcher.
25
- attr_reader :matcher
26
-
27
- # The value of the negate instance variable.
28
- #
29
- # @return [Boolean] Evaluated to a negative assertion or not.
30
- def negate?
31
- @negate
32
- end
33
-
34
- # @!attribute [r] state
35
- #
36
- # @return [Sandbox] The sandbox that tested the code.
37
- attr_reader :state
38
-
39
- # @!attribute [r] result
40
- #
41
- # @return [Boolean] The result of the test.
42
- attr_reader :result
43
-
44
- # The message.
45
- #
46
- # @return [String] The message that describe the state.
47
- def to_s
48
- "#{title}: #{summary}#{maybe_exception}."
49
- end
50
-
51
- # The title of the state.
52
- #
53
- # @return [String] The title of the state.
54
- def title
55
- if result
56
- state.got ? 'Pass' : 'Info'
57
- else
58
- state.exception.nil? ? 'Failure' : 'Error'
59
- end
60
- end
61
-
62
- # The summary of the state.
63
- #
64
- # @return [String] The summary of the state.
65
- def summary
66
- return state.exception.message unless state.valid? || state.exception.nil?
67
-
68
- "Expected #{state.actual.inspect}#{maybe_negate} to #{definition}"
69
- end
70
-
71
- # The negation, if any.
72
- #
73
- # @return [String] The negation, or an empty string.
74
- def maybe_negate
75
- negate? ? ' not' : ''
76
- end
77
-
78
- # The type of exception, if any.
79
- #
80
- # @return [String] The type of exception, or an empty string.
81
- def maybe_exception
82
- state.exception.nil? ? '' : " (#{state.exception.class})"
83
- end
84
-
85
- # The readable definition.
86
- #
87
- # @return [String] The readable definition string.
88
- def definition
89
- matcher.to_s
90
- end
91
- end
92
- end