spectus 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7979abd1117a7e7320e221ef8723e818f7e1b3f8f7ac05e8913f65fdb2a7c615
4
- data.tar.gz: b163fee339e12eec5712802159f361558f596ffa720cc87ccb26822883c40c36
3
+ metadata.gz: 91207456a98d2640cdeb0dbf52ce04c532f72060c904aa15474f2eb86eb67481
4
+ data.tar.gz: 26e7073807fa4bb734eb8e349682c41d2b23bd83c11012818ce443b5615089e3
5
5
  SHA512:
6
- metadata.gz: d4970d21d63e784d7257472a9ccee1f3d33f31e61d79030239a620a5a2f8569d039672c35429aa42c8db4c55c184f3bd7512921fb08246ad03ceed9b48b53b71
7
- data.tar.gz: a41655c8c03ed03650677d8eae4d1fc4bb412bf4a4a66bc5076950181a6f6c9d123cd74f5a90127299d835f9249d07343463804bdbf276b8ad854c14bf0539c5
6
+ metadata.gz: '018827c15c82d74b1af062e57768809c89f6ad18e2b389b4150ae318f12fdbadd6709eff232483d67a7e9aa0234d008ade347503066b78c522f7291fa515f809'
7
+ data.tar.gz: a57c6cfaf4b7292ca768fc309e61a025d85de984cf62af8f0a88c0b37d58189732babf03e3a8a6eed208838518af088d1d53448cc5c6c71842db1e52f0c60ab7
data/README.md CHANGED
@@ -38,7 +38,7 @@ Given the "`ルビー`" object, when it receives `valid_encoding?` method, then
38
38
 
39
39
  ```ruby
40
40
  it { "ルビー".valid_encoding? }.MUST be_true
41
- # => Expresenter::Pass(actual: true, error: nil, expected: nil, got: true, matcher: :be_true, negate: false, level: :MUST, valid: true)
41
+ # => Spectus::Result::Pass(actual: true, error: nil, expected: nil, got: true, matcher: :be_true, negate: false, level: :MUST, valid: true)
42
42
  ```
43
43
 
44
44
  The result of the test shows that the spec passed.
@@ -49,7 +49,7 @@ Given the "`foo`" object, when it receives `length` method, then it **MUST NOT**
49
49
 
50
50
  ```ruby
51
51
  it { "foo".length }.MUST_NOT raise_exception NoMethodError
52
- # => Expresenter::Pass(actual: 3, error: nil, expected: NoMethodError, got: true, matcher: :raise_exception, negate: true, level: :MUST, valid: true)
52
+ # => Spectus::Result::Pass(actual: 3, error: nil, expected: NoMethodError, got: true, matcher: :raise_exception, negate: true, level: :MUST, valid: true)
53
53
  ```
54
54
 
55
55
  The result of the test shows that the spec passed.
@@ -60,7 +60,7 @@ Given the `BasicObject` object, when it receives `superclass` method, then it **
60
60
 
61
61
  ```ruby
62
62
  it { BasicObject.superclass }.SHOULD equal NilClass
63
- # => Expresenter::Pass(actual: nil, error: nil, expected: NilClass, got: false, matcher: :equal, negate: false, level: :SHOULD, valid: false)
63
+ # => Spectus::Result::Pass(actual: nil, error: nil, expected: NilClass, got: false, matcher: :equal, negate: false, level: :SHOULD, valid: false)
64
64
  ```
65
65
 
66
66
  Instead of the expected `NilClass` class, its sole instance (which is `nil`) was returned.
@@ -72,7 +72,7 @@ Given the "`1`" object, when it receives `+(1)` method, then it **SHOULD NOT** r
72
72
 
73
73
  ```ruby
74
74
  it { "1" + 1 }.SHOULD_NOT eql "11"
75
- # raise Expresenter::Fail(actual: nil, error: #<TypeError: no implicit conversion of Integer into String>, expected: "11", got: nil, matcher: :eql, negate: true, level: :SHOULD, valid: false)
75
+ # 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)
76
76
  ```
77
77
 
78
78
  There was a `TypeError` exception, the result of the test shows that the spec failed.
@@ -83,7 +83,7 @@ Given the "`foo`" object, when it receives `blank?` method, then it **MAY** be `
83
83
 
84
84
  ```ruby
85
85
  it { "foo".blank? }.MAY be_false
86
- # => Expresenter::Pass(actual: nil, error: #<NoMethodError: undefined method `blank?' for "foo":String>, expected: nil, got: nil, matcher: :be_false, negate: false, level: :MAY, valid: false)
86
+ # => 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)
87
87
  ```
88
88
 
89
89
  The optional `blank?` method is not implemented (unlike in [Ruby on Rails](https://api.rubyonrails.org/classes/Object.html#method-i-blank-3F), for instance), so the result of the test shows that the spec passed.
@@ -107,7 +107,7 @@ Example of test without isolation:
107
107
  include Spectus
108
108
  greeting = "Hello, world!"
109
109
  it { greeting.gsub!("world", "Alice") }.MUST eql "Hello, Alice!"
110
- # => Expresenter::Pass(actual: "Hello, Alice!", error: nil, expected: "Hello, Alice!", got: true, matcher: :eql, negate: false, level: :MUST, valid: true)
110
+ # => Spectus::Result::Pass(actual: "Hello, Alice!", error: nil, expected: "Hello, Alice!", got: true, matcher: :eql, negate: false, level: :MUST, valid: true)
111
111
  greeting # => "Hello, Alice!"
112
112
  ```
113
113
 
@@ -117,7 +117,7 @@ Example of test in isolation:
117
117
  include Spectus
118
118
  greeting = "Hello, world!"
119
119
  it { greeting.gsub!("world", "Alice") }.MUST! eql "Hello, Alice!"
120
- # => Expresenter::Pass(actual: "Hello, Alice!", error: nil, expected: "Hello, Alice!", got: true, matcher: :eql, negate: false, level: :MUST, valid: true)
120
+ # => Spectus::Result::Pass(actual: "Hello, Alice!", error: nil, expected: "Hello, Alice!", got: true, matcher: :eql, negate: false, level: :MUST, valid: true)
121
121
  greeting # => "Hello, world!"
122
122
  ```
123
123
 
data/lib/spectus.rb CHANGED
@@ -6,14 +6,14 @@ require "matchi/helper"
6
6
  #
7
7
  # @example It MUST equal 42.
8
8
  # require 'spectus'
9
- # it { 42 }.MUST equal 42 # => #<Expresenter::Pass...>
9
+ # it { 42 }.MUST equal 42 # => #<Spectus::Result::Pass...>
10
10
  module Spectus
11
11
  include ::Matchi::Helper
12
12
 
13
13
  # Expectations are built with this method.
14
14
  #
15
15
  # @example An _absolute requirement_ definition.
16
- # it { 42 }.MUST equal 42 # => #<Expresenter::Pass...>
16
+ # it { 42 }.MUST equal 42 # => #<Spectus::Result::Pass...>
17
17
  #
18
18
  # @param input [Proc] The code to test.
19
19
  #
@@ -19,11 +19,12 @@ module Spectus
19
19
  # definition is an absolute requirement of the specification.
20
20
  #
21
21
  # @example _Absolute requirement_ definition
22
- # it { 'foo'.upcase }.MUST eql 'FOO'
22
+ # it { "foo".upcase }.MUST eql 'FOO'
23
23
  #
24
24
  # @param matcher [#matches?] The matcher.
25
25
  #
26
- # @return [Expresenter::Fail, Expresenter::Pass] Report if the spec pass or fail.
26
+ # @return [Spectus::Result::Fail, Spectus::Result::Pass] Report if the spec
27
+ # pass or fail.
27
28
  def MUST(matcher)
28
29
  RequirementLevel::Must.new(
29
30
  callable: callable,
@@ -34,7 +35,7 @@ module Spectus
34
35
  end
35
36
 
36
37
  # @example _Absolute requirement_ definition with isolation
37
- # it { 'foo'.upcase }.MUST! eql 'FOO'
38
+ # it { "foo".upcase }.MUST! eql 'FOO'
38
39
  #
39
40
  # @see MUST
40
41
  def MUST!(matcher)
@@ -50,11 +51,12 @@ module Spectus
50
51
  # definition is an absolute prohibition of the specification.
51
52
  #
52
53
  # @example _Absolute prohibition_ definition
53
- # it { 'foo'.size }.MUST_NOT equal 42
54
+ # it { "foo".size }.MUST_NOT equal 42
54
55
  #
55
56
  # @param matcher [#matches?] The matcher.
56
57
  #
57
- # @return [Expresenter::Fail, Expresenter::Pass] Report if the spec pass or fail.
58
+ # @return [Spectus::Result::Fail, Spectus::Result::Pass] Report if the spec
59
+ # pass or fail.
58
60
  def MUST_NOT(matcher)
59
61
  RequirementLevel::Must.new(
60
62
  callable: callable,
@@ -65,7 +67,7 @@ module Spectus
65
67
  end
66
68
 
67
69
  # @example _Absolute prohibition_ definition with isolation
68
- # it { 'foo'.size }.MUST_NOT! equal 42
70
+ # it { "foo".size }.MUST_NOT! equal 42
69
71
  #
70
72
  # @see MUST_NOT
71
73
  def MUST_NOT!(matcher)
@@ -83,11 +85,12 @@ module Spectus
83
85
  # carefully weighed before choosing a different course.
84
86
  #
85
87
  # @example _Recommended_ definition
86
- # it { 'foo'.valid_encoding? }.SHOULD equal true
88
+ # it { "foo".valid_encoding? }.SHOULD equal true
87
89
  #
88
90
  # @param matcher [#matches?] The matcher.
89
91
  #
90
- # @return [Expresenter::Fail, Expresenter::Pass] Report if the spec pass or fail.
92
+ # @return [Spectus::Result::Fail, Spectus::Result::Pass] Report if the spec
93
+ # pass or fail.
91
94
  def SHOULD(matcher)
92
95
  RequirementLevel::Should.new(
93
96
  callable: callable,
@@ -98,7 +101,7 @@ module Spectus
98
101
  end
99
102
 
100
103
  # @example _Recommended_ definition with isolation
101
- # it { 'foo'.valid_encoding? }.SHOULD! equal true
104
+ # it { "foo".valid_encoding? }.SHOULD! equal true
102
105
  #
103
106
  # @see SHOULD
104
107
  def SHOULD!(matcher)
@@ -117,11 +120,12 @@ module Spectus
117
120
  # before implementing any behavior described with this label.
118
121
  #
119
122
  # @example _Not recommended_ definition
120
- # it { ''.blank? }.SHOULD_NOT raise_exception NoMethodError
123
+ # it { "".blank? }.SHOULD_NOT raise_exception NoMethodError
121
124
  #
122
125
  # @param matcher [#matches?] The matcher.
123
126
  #
124
- # @return [Expresenter::Fail, Expresenter::Pass] Report if the spec pass or fail.
127
+ # @return [Spectus::Result::Fail, Spectus::Result::Pass] Report if the spec
128
+ # pass or fail.
125
129
  def SHOULD_NOT(matcher)
126
130
  RequirementLevel::Should.new(
127
131
  callable: callable,
@@ -132,7 +136,7 @@ module Spectus
132
136
  end
133
137
 
134
138
  # @example _Not recommended_ definition with isolation
135
- # it { ''.blank? }.SHOULD_NOT! raise_exception NoMethodError
139
+ # it { "".blank? }.SHOULD_NOT! raise_exception NoMethodError
136
140
  #
137
141
  # @see SHOULD_NOT
138
142
  def SHOULD_NOT!(matcher)
@@ -157,11 +161,11 @@ module Spectus
157
161
  # option provides.)
158
162
  #
159
163
  # @example _Optional_ definition
160
- # it { 'foo'.bar }.MAY match /^foo$/
164
+ # it { "foo".bar }.MAY match /^foo$/
161
165
  #
162
166
  # @param matcher [#matches?] The matcher.
163
167
  #
164
- # @return [Expresenter::Fail, Expresenter::Pass] Report if the spec pass or fail.
168
+ # @return [Spectus::Result::Fail, Spectus::Result::Pass] Report if the spec pass or fail.
165
169
  def MAY(matcher)
166
170
  RequirementLevel::May.new(
167
171
  callable: callable,
@@ -172,7 +176,7 @@ module Spectus
172
176
  end
173
177
 
174
178
  # @example _Optional_ definition with isolation
175
- # it { 'foo'.bar }.MAY! match /^foo$/
179
+ # it { "foo".bar }.MAY! match /^foo$/
176
180
  #
177
181
  # @see MAY
178
182
  def MAY!(matcher)
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "expresenter"
4
-
5
3
  module Spectus
6
4
  # Namespace for the requirement levels.
7
5
  module RequirementLevel
@@ -34,10 +32,10 @@ module Spectus
34
32
 
35
33
  # The result of the expectation.
36
34
  #
37
- # @raise [Expresenter::Fail] The expectation is `false`.
38
- # @return [Expresenter::Pass] The expectation is `true`.
35
+ # @raise [Spectus::Result::Fail] The expectation is `false`.
36
+ # @return [Spectus::Result::Pass] The expectation is `true`.
39
37
  def call
40
- ::Expresenter.call(pass?).with(
38
+ Result.call(pass?).with(
41
39
  actual: exam.actual,
42
40
  error: exam.exception,
43
41
  expected: matcher.expected,
@@ -68,3 +66,4 @@ module Spectus
68
66
  end
69
67
 
70
68
  require_relative File.join("..", "exam")
69
+ require_relative File.join("..", "result")
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spectus
4
+ # Namespace for the results.
5
+ module Result
6
+ # @param is_passed [Boolean] The value of an assertion.
7
+ # @return [Class<Spectus::Result::Pass>, Class<Spectus::Result::Fail>] The
8
+ # class of the result.
9
+ # @example Get the pass class result.
10
+ # call(true) # => Pass
11
+ def self.call(is_passed)
12
+ is_passed ? Pass : Fail
13
+ end
14
+ end
15
+ end
16
+
17
+ require_relative File.join("result", "fail")
18
+ require_relative File.join("result", "pass")
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "expresenter/fail"
4
+
5
+ module Spectus
6
+ module Result
7
+ # The class that is responsible for reporting that the expectation is false.
8
+ class Fail < ::Expresenter::Fail
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "expresenter/pass"
4
+
5
+ module Spectus
6
+ module Result
7
+ # The class that is responsible for reporting that the expectation is true.
8
+ class Pass < ::Expresenter::Pass
9
+ end
10
+ end
11
+ 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.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Kato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-11 00:00:00.000000000 Z
11
+ date: 2021-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: defi
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.1
33
+ version: 1.1.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.0.1
40
+ version: 1.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: matchi
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -193,6 +193,9 @@ files:
193
193
  - lib/spectus/requirement_level/may.rb
194
194
  - lib/spectus/requirement_level/must.rb
195
195
  - lib/spectus/requirement_level/should.rb
196
+ - lib/spectus/result.rb
197
+ - lib/spectus/result/fail.rb
198
+ - lib/spectus/result/pass.rb
196
199
  homepage: https://github.com/fixrb/spectus
197
200
  licenses:
198
201
  - MIT