spectus 1.0.0.pre → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +1 -0
- data/README.md +31 -22
- data/VERSION.semver +1 -1
- data/example/duck/README.md +6 -0
- data/example/duck/app.rb +3 -0
- data/example/duck/lib.rb +14 -0
- data/example/duck/test.rb +21 -0
- data/lib/spectus/dsl.rb +8 -2
- data/lib/spectus/expectation_target.rb +10 -3
- data/lib/spectus/matcher/capture_stderr.rb +0 -3
- data/lib/spectus/matcher/capture_stdout.rb +0 -3
- data/lib/spectus/matcher/eql.rb +0 -3
- data/lib/spectus/matcher/equal.rb +0 -3
- data/lib/spectus/matcher/match.rb +0 -3
- data/lib/spectus/matcher/raise_exception.rb +0 -3
- data/lib/spectus/matcher.rb +7 -4
- data/lib/spectus.rb +2 -0
- data/spectus.gemspec +6 -0
- data/spectus.pem +21 -0
- data/test/spectus/test_matcher.rb +10 -4
- data/test/support/presenter.rb +6 -6
- data.tar.gz.sig +2 -0
- metadata +32 -8
- metadata.gz.sig +0 -0
- data/lib/spectus/reporter.rb +0 -45
- data/test/spectus/test_reporter.rb +0 -97
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c7d6a54210e4660c8e760d20e5f85d594df0e83
|
4
|
+
data.tar.gz: e8292c282c979c5aa30ef8c12dd98e254765a192
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08b9482f29b8451ad63da9342ebdc1079a929073d2dd0f9235642b92d40b220710af57489e4ba30758a94ffd4c8f9f96dae177ea5cc3314540aa92246182bf6d
|
7
|
+
data.tar.gz: 177c223f8ed17fb2face0c67b1ca106780e6a947d1f35a3069bc698b1e7f11d8f682690d9d45b8b008702cd5e3a372814cf7abf127da20f80218c84083c00ef9
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
�j�T�z=p���_S�l����{����(��y�!�=�G�1%�!z����S��Y|�0��}�S�zlѮu���G`x��)L|,!��@JQ��5X@��ЋNz��B9�0�K�U�����?J�7!G�i������dct�� V��&��D�Xv g��F� ����3�Pw�捐����I����#�3
|
data/README.md
CHANGED
@@ -2,10 +2,9 @@
|
|
2
2
|
|
3
3
|
[](https://travis-ci.org/cyril/spectus.rb)
|
4
4
|
[](https://coveralls.io/r/cyril/spectus.rb)
|
5
|
-
[](https://codeclimate.com/github/cyril/spectus.rb)
|
6
5
|
[](https://gemnasium.com/cyril/spectus.rb)
|
7
6
|
[](https://rubygems.org/gems/spectus)
|
8
|
-
[](http://inch-ci.org/github/cyril/spectus.rb)
|
7
|
+
[](http://inch-ci.org/github/cyril/spectus.rb)
|
9
8
|
[](http://rubydoc.info/gems/spectus/frames)
|
10
9
|
[](http://cyril.mit-license.org/)
|
11
10
|
|
@@ -45,7 +44,17 @@ $ gem install spectus
|
|
45
44
|
|
46
45
|
* It's ~200 lines of fast and KISS code.
|
47
46
|
* Atomic state transitions, immutable objects, thread-safe.
|
48
|
-
*
|
47
|
+
* Generic and consistent DSL for assertions.
|
48
|
+
|
49
|
+
## API
|
50
|
+
|
51
|
+
The [Spectus DSL](lib/spectus/dsl.rb) provides the `expect` method.
|
52
|
+
It takes a block parameter and responds to:
|
53
|
+
|
54
|
+
* `to(definition)`
|
55
|
+
* `not_to(definition)`
|
56
|
+
|
57
|
+
Then it returns `true`, `false`, or a cached exception.
|
49
58
|
|
50
59
|
## Usage
|
51
60
|
|
@@ -67,7 +76,7 @@ end
|
|
67
76
|
@bird = Duck.new
|
68
77
|
```
|
69
78
|
|
70
|
-
> When I see a
|
79
|
+
> When I see a `#<Duck:0x007f96b285d6d0>` that ...
|
71
80
|
|
72
81
|
```ruby
|
73
82
|
require 'spectus'
|
@@ -78,53 +87,53 @@ expectation_2 = expect { @bird.swims }.to eql: "Swoosh..."
|
|
78
87
|
expectation_3 = expect { @bird.quacks }.to capture_stdout: "Quaaaaaack!\n"
|
79
88
|
expectation_4 = expect { @bird.speaks }.to raise_exception: NoMethodError
|
80
89
|
|
81
|
-
case (expectation_1
|
82
|
-
expectation_2
|
83
|
-
expectation_3
|
84
|
-
expectation_4
|
90
|
+
case (expectation_1 == true &&
|
91
|
+
expectation_2 == true &&
|
92
|
+
expectation_3 == true &&
|
93
|
+
expectation_4 == true)
|
85
94
|
when true then puts "I call that #{@bird} a duck."
|
86
95
|
else warn 'WAT?'
|
87
96
|
end
|
88
97
|
```
|
89
98
|
|
90
|
-
> I call that
|
99
|
+
> I call that `#<Duck:0x007f96b285d6d0>` a duck.
|
91
100
|
|
92
101
|
## Built-in matchers
|
93
102
|
|
94
103
|
### Standard error
|
95
104
|
|
96
105
|
```ruby
|
97
|
-
expect { warn 'foo' }.to capture_stderr: "foo\n"
|
106
|
+
expect { warn 'foo' }.to capture_stderr: "foo\n" # => true
|
98
107
|
```
|
99
108
|
|
100
109
|
### Standard output
|
101
110
|
|
102
111
|
```ruby
|
103
|
-
expect { puts 'foo' }.to capture_stdout: "foo\n"
|
112
|
+
expect { puts 'foo' }.to capture_stdout: "foo\n" # => true
|
104
113
|
```
|
105
114
|
|
106
115
|
### Equivalence
|
107
116
|
|
108
117
|
```ruby
|
109
|
-
expect { 'foo' }.to eql: 'foo'
|
118
|
+
expect { 'foo' }.to eql: 'foo' # => true
|
110
119
|
```
|
111
120
|
|
112
121
|
### Identity
|
113
122
|
|
114
123
|
```ruby
|
115
|
-
expect { :foo }.to equal: :foo
|
124
|
+
expect { :foo }.to equal: :foo # => true
|
116
125
|
```
|
117
126
|
|
118
127
|
### Regular expressions
|
119
128
|
|
120
129
|
```ruby
|
121
|
-
expect { 'foo' }.to({match: /^foo$/})
|
130
|
+
expect { 'foo' }.to({match: /^foo$/}) # => true
|
122
131
|
```
|
123
132
|
|
124
133
|
### Expecting errors
|
125
134
|
|
126
135
|
```ruby
|
127
|
-
expect { Foo }.to raise_exception: NameError
|
136
|
+
expect { Foo }.to raise_exception: NameError # => true
|
128
137
|
```
|
129
138
|
|
130
139
|
## Custom matchers
|
@@ -137,13 +146,13 @@ The following expression...
|
|
137
146
|
|
138
147
|
```ruby
|
139
148
|
require 'prime'
|
140
|
-
expect { Prime.prime? 42 }.to equal: false
|
149
|
+
expect { Prime.prime? 42 }.to equal: false # => true
|
141
150
|
```
|
142
151
|
|
143
152
|
...could be refactored into:
|
144
153
|
|
145
154
|
```ruby
|
146
|
-
expect { 42 }.not_to :be_prime
|
155
|
+
expect { 42 }.not_to :be_prime # => true
|
147
156
|
```
|
148
157
|
|
149
158
|
It can be done with this custom matcher:
|
@@ -167,13 +176,13 @@ end
|
|
167
176
|
The following expression...
|
168
177
|
|
169
178
|
```ruby
|
170
|
-
expect { 42 }.to equal: 42
|
179
|
+
expect { 42 }.to equal: 42 # => true
|
171
180
|
```
|
172
181
|
|
173
182
|
...could be refactored into:
|
174
183
|
|
175
184
|
```ruby
|
176
|
-
expect { 42 }.to :be_the_answer
|
185
|
+
expect { 42 }.to :be_the_answer # => true
|
177
186
|
```
|
178
187
|
|
179
188
|
It can be done with this custom matcher:
|
@@ -195,13 +204,13 @@ end
|
|
195
204
|
The following expression...
|
196
205
|
|
197
206
|
```ruby
|
198
|
-
expect { 'foobar' }.to match: /^foo/
|
207
|
+
expect { 'foobar' }.to match: /^foo/ # => true
|
199
208
|
```
|
200
209
|
|
201
210
|
...could be refactored into:
|
202
211
|
|
203
212
|
```ruby
|
204
|
-
expect { 'foobar' }.to start_with: 'foo'
|
213
|
+
expect { 'foobar' }.to start_with: 'foo' # => true
|
205
214
|
```
|
206
215
|
|
207
216
|
It can be done with this custom matcher:
|
@@ -236,4 +245,4 @@ __Spectus__ follows [Semantic Versioning 2.0](http://semver.org/)
|
|
236
245
|
|
237
246
|
## Copyright
|
238
247
|
|
239
|
-
© [Cyril Wack](https://plus.google.com/+CyrilWack?rel=author)
|
248
|
+
© 2014 [Cyril Wack](https://plus.google.com/+CyrilWack?rel=author)
|
data/VERSION.semver
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0
|
1
|
+
1.0.0
|
data/example/duck/app.rb
ADDED
data/example/duck/lib.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby -w
|
2
|
+
|
3
|
+
require_relative 'app'
|
4
|
+
|
5
|
+
# require 'spectus'
|
6
|
+
require_relative '../../lib/spectus'
|
7
|
+
|
8
|
+
extend Spectus::DSL
|
9
|
+
|
10
|
+
expectation_1 = expect { @app.swims }.to capture_stderr: " ...\n"
|
11
|
+
expectation_2 = expect { @app.quacks }.to capture_stdout: "Quaaaaaack!\n"
|
12
|
+
expectation_3 = expect { @app.speaks }.to raise_exception: NoMethodError
|
13
|
+
expectation_4 = expect { @app.walks }.to eql: "Quaaa... Klop klop!"
|
14
|
+
|
15
|
+
case (expectation_1 == true &&
|
16
|
+
expectation_2 == true &&
|
17
|
+
expectation_3 == true &&
|
18
|
+
expectation_4 == true)
|
19
|
+
when true then puts "I call that #{@app} a duck."
|
20
|
+
else warn 'WAT?'
|
21
|
+
end
|
data/lib/spectus/dsl.rb
CHANGED
@@ -5,8 +5,14 @@ module Spectus
|
|
5
5
|
# Expectation's domain-specific language.
|
6
6
|
module DSL
|
7
7
|
|
8
|
-
# Expectations are built with this method
|
9
|
-
#
|
8
|
+
# Expectations are built with this method.
|
9
|
+
#
|
10
|
+
# @api public
|
11
|
+
#
|
12
|
+
# @example Duck example
|
13
|
+
# YARD.parse('example/duck/*.rb')
|
14
|
+
#
|
15
|
+
# @return [ExpectationTarget] the expectation target.
|
10
16
|
def expect &input
|
11
17
|
ExpectationTarget.new(&input)
|
12
18
|
end
|
@@ -7,19 +7,26 @@ module Spectus
|
|
7
7
|
# @example
|
8
8
|
# expect { do_something } # => ExpectationTarget wrapping the block
|
9
9
|
class ExpectationTarget
|
10
|
-
# @api private
|
11
10
|
def initialize &actual
|
12
11
|
@actual = actual
|
13
12
|
|
14
13
|
freeze
|
15
14
|
end
|
16
15
|
|
17
|
-
#
|
16
|
+
# Evaluate to a positive assertion.
|
17
|
+
#
|
18
|
+
# @api public
|
19
|
+
#
|
20
|
+
# @see Matcher#eval
|
18
21
|
def to definition
|
19
22
|
Matcher.eval false, definition, &@actual
|
20
23
|
end
|
21
24
|
|
22
|
-
#
|
25
|
+
# Evaluate to a negative assertion.
|
26
|
+
#
|
27
|
+
# @api public
|
28
|
+
#
|
29
|
+
# @see Matcher#eval
|
23
30
|
def not_to definition
|
24
31
|
Matcher.eval true, definition, &@actual
|
25
32
|
end
|
data/lib/spectus/matcher/eql.rb
CHANGED
data/lib/spectus/matcher.rb
CHANGED
@@ -1,18 +1,21 @@
|
|
1
|
-
require_relative 'reporter'
|
2
|
-
|
3
1
|
module Spectus
|
4
2
|
|
5
3
|
# This module provides matchers to define expectations.
|
6
4
|
module Matcher
|
7
5
|
|
8
|
-
# Evaluate the expectation
|
6
|
+
# Evaluate the expectation with the passed block.
|
7
|
+
#
|
8
|
+
# @param [Boolean] negated
|
9
|
+
# @param [Hash] definition
|
10
|
+
#
|
11
|
+
# @return [ExceptionClass, false, true] true, false, or a cached exception.
|
9
12
|
def self.eval negated, definition, &actual
|
10
13
|
params = Array(definition).flatten(1)
|
11
14
|
name = params.first
|
12
15
|
expected_args = params[1..-1]
|
13
16
|
matcher = Matcher.get(name).new(*expected_args)
|
14
17
|
|
15
|
-
|
18
|
+
begin
|
16
19
|
negated ^ matcher.matches?(&actual)
|
17
20
|
rescue => e
|
18
21
|
e
|
data/lib/spectus.rb
CHANGED
data/spectus.gemspec
CHANGED
@@ -17,4 +17,10 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.add_development_dependency 'rake', '~> 10.0'
|
18
18
|
spec.add_development_dependency 'yard', '~> 0.8'
|
19
19
|
spec.add_development_dependency 'coveralls', '~> 0.7'
|
20
|
+
|
21
|
+
private_key = File.expand_path '~/.gemcert/spectus-gem-private_key.pem'
|
22
|
+
if File.exist? private_key
|
23
|
+
spec.signing_key = private_key
|
24
|
+
spec.cert_chain = ['spectus.pem']
|
25
|
+
end
|
20
26
|
end
|
data/spectus.pem
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDbDCCAlSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA+MQ4wDAYDVQQDDAVjeXJp
|
3
|
+
bDEXMBUGCgmSJomT8ixkARkWB3Nhc2hpdGUxEzARBgoJkiaJk/IsZAEZFgNjb20w
|
4
|
+
HhcNMTQwOTI0MTUyOTE0WhcNMTUwOTI0MTUyOTE0WjA+MQ4wDAYDVQQDDAVjeXJp
|
5
|
+
bDEXMBUGCgmSJomT8ixkARkWB3Nhc2hpdGUxEzARBgoJkiaJk/IsZAEZFgNjb20w
|
6
|
+
ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDpolrc0SLpDakbnGS/hPqX
|
7
|
+
DBsM9WKIrIiDmpmdM0PBR5tW1Jad0/17xGCTGwxKjul3zqjfh9wQK+NnS4NUtxQj
|
8
|
+
brxQroYotsVwaUXOKuruDsL8lfx8+dqYvWBE6mt4Ggx3lnausO5IWQ1bSpdcYpyr
|
9
|
+
mxuR6ch1E5yS3+AdTFNp19iwFv6EOL/O0iE7Jb4RCcfp4Ua/9RAo3GHz+/iVkLjx
|
10
|
+
HxVZf/4F8lvpCBadg8TsHZTqQgr8EW6THeHi5YXVFth3LH7eAY7Q+vCKhQoIOPmj
|
11
|
+
C4AylJ7zT5tD9BJMwSenrtF0oZntmlKLgygyntxbZUExMjesdPXXzpZZ6v8Vco6N
|
12
|
+
AgMBAAGjdTBzMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBRq64f9
|
13
|
+
CZGW/N6a/4Q/glHHiA05VDAcBgNVHREEFTATgRFjeXJpbEBzYXNoaXRlLmNvbTAc
|
14
|
+
BgNVHRIEFTATgRFjeXJpbEBzYXNoaXRlLmNvbTANBgkqhkiG9w0BAQUFAAOCAQEA
|
15
|
+
OMD+bOYidquEGI87612sDP2QJXmIhDbbUFmvm8dGTABtyYdrdl77dEsaL8gEDSOC
|
16
|
+
nABh6/LOnLYlvAQE8bGMKdy/V4qwndS5i2j4ZfZTKEUUQ+FCcOfbHE1LrzYvuCyD
|
17
|
+
etFGUmqF5UtCBzDlwCiupv1m5f4yp/3IVARf3jwMVzlCLcTw7WVCrXL4ZgnStiBI
|
18
|
+
wRdxjXHZe3W/Ux7Irtd+JPd8pwuObE8i7h1tepcMWNQWFFmYOmYwmkB46WUTqa3Y
|
19
|
+
zeYBFLJQAl0AQPaGujsG5tssIabiNy1ryydKAjWkNDxqLgvtwST3L0Qr9UQFQgoA
|
20
|
+
O2Rl8PjSD+2P9XE7T2x1xQ==
|
21
|
+
-----END CERTIFICATE-----
|
@@ -4,10 +4,16 @@ subject "matcher module" do
|
|
4
4
|
Spectus::Matcher
|
5
5
|
end
|
6
6
|
|
7
|
-
it 'must
|
8
|
-
expect
|
9
|
-
|
10
|
-
|
7
|
+
it 'must return true after the evaluation' do
|
8
|
+
expect { subject.eval(false, eql: 'foo') { 'foo' } }.to equal: true
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'must return false after the evaluation' do
|
12
|
+
expect { subject.eval(false, eql: 'foo') { 'bar' } }.to equal: false
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'must return an exception after the evaluation' do
|
16
|
+
expect { subject.eval(false, eql: 'foo') { BOOM }.class }.to equal: NameError
|
11
17
|
end
|
12
18
|
|
13
19
|
it 'must return the class of a matcher from its symbol' do
|
data/test/support/presenter.rb
CHANGED
@@ -12,12 +12,12 @@ def it describe, &expectation
|
|
12
12
|
|
13
13
|
result = expectation.call
|
14
14
|
|
15
|
-
case result
|
16
|
-
when
|
17
|
-
puts "\e[32m
|
18
|
-
when
|
19
|
-
warn "\e[
|
15
|
+
case result
|
16
|
+
when true
|
17
|
+
puts "\e[32m.\e[0m"
|
18
|
+
when false
|
19
|
+
warn "\e[31mF\e[0m"
|
20
20
|
else
|
21
|
-
fail result
|
21
|
+
fail result
|
22
22
|
end
|
23
23
|
end
|
data.tar.gz.sig
ADDED
metadata
CHANGED
@@ -1,14 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spectus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Wack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDbDCCAlSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA+MQ4wDAYDVQQDDAVjeXJp
|
14
|
+
bDEXMBUGCgmSJomT8ixkARkWB3Nhc2hpdGUxEzARBgoJkiaJk/IsZAEZFgNjb20w
|
15
|
+
HhcNMTQwOTI0MTUyOTE0WhcNMTUwOTI0MTUyOTE0WjA+MQ4wDAYDVQQDDAVjeXJp
|
16
|
+
bDEXMBUGCgmSJomT8ixkARkWB3Nhc2hpdGUxEzARBgoJkiaJk/IsZAEZFgNjb20w
|
17
|
+
ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDpolrc0SLpDakbnGS/hPqX
|
18
|
+
DBsM9WKIrIiDmpmdM0PBR5tW1Jad0/17xGCTGwxKjul3zqjfh9wQK+NnS4NUtxQj
|
19
|
+
brxQroYotsVwaUXOKuruDsL8lfx8+dqYvWBE6mt4Ggx3lnausO5IWQ1bSpdcYpyr
|
20
|
+
mxuR6ch1E5yS3+AdTFNp19iwFv6EOL/O0iE7Jb4RCcfp4Ua/9RAo3GHz+/iVkLjx
|
21
|
+
HxVZf/4F8lvpCBadg8TsHZTqQgr8EW6THeHi5YXVFth3LH7eAY7Q+vCKhQoIOPmj
|
22
|
+
C4AylJ7zT5tD9BJMwSenrtF0oZntmlKLgygyntxbZUExMjesdPXXzpZZ6v8Vco6N
|
23
|
+
AgMBAAGjdTBzMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBRq64f9
|
24
|
+
CZGW/N6a/4Q/glHHiA05VDAcBgNVHREEFTATgRFjeXJpbEBzYXNoaXRlLmNvbTAc
|
25
|
+
BgNVHRIEFTATgRFjeXJpbEBzYXNoaXRlLmNvbTANBgkqhkiG9w0BAQUFAAOCAQEA
|
26
|
+
OMD+bOYidquEGI87612sDP2QJXmIhDbbUFmvm8dGTABtyYdrdl77dEsaL8gEDSOC
|
27
|
+
nABh6/LOnLYlvAQE8bGMKdy/V4qwndS5i2j4ZfZTKEUUQ+FCcOfbHE1LrzYvuCyD
|
28
|
+
etFGUmqF5UtCBzDlwCiupv1m5f4yp/3IVARf3jwMVzlCLcTw7WVCrXL4ZgnStiBI
|
29
|
+
wRdxjXHZe3W/Ux7Irtd+JPd8pwuObE8i7h1tepcMWNQWFFmYOmYwmkB46WUTqa3Y
|
30
|
+
zeYBFLJQAl0AQPaGujsG5tssIabiNy1ryydKAjWkNDxqLgvtwST3L0Qr9UQFQgoA
|
31
|
+
O2Rl8PjSD+2P9XE7T2x1xQ==
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2014-09-25 00:00:00.000000000 Z
|
12
34
|
dependencies:
|
13
35
|
- !ruby/object:Gem::Dependency
|
14
36
|
name: bundler
|
@@ -82,6 +104,10 @@ files:
|
|
82
104
|
- README.md
|
83
105
|
- Rakefile
|
84
106
|
- VERSION.semver
|
107
|
+
- example/duck/README.md
|
108
|
+
- example/duck/app.rb
|
109
|
+
- example/duck/lib.rb
|
110
|
+
- example/duck/test.rb
|
85
111
|
- lib/spectus.rb
|
86
112
|
- lib/spectus/dsl.rb
|
87
113
|
- lib/spectus/expectation_target.rb
|
@@ -92,9 +118,9 @@ files:
|
|
92
118
|
- lib/spectus/matcher/equal.rb
|
93
119
|
- lib/spectus/matcher/match.rb
|
94
120
|
- lib/spectus/matcher/raise_exception.rb
|
95
|
-
- lib/spectus/reporter.rb
|
96
121
|
- lib/spectus/version.rb
|
97
122
|
- spectus.gemspec
|
123
|
+
- spectus.pem
|
98
124
|
- test/helper_test.rb
|
99
125
|
- test/spectus/helper_test.rb
|
100
126
|
- test/spectus/matcher/built_in/helper_test.rb
|
@@ -115,7 +141,6 @@ files:
|
|
115
141
|
- test/spectus/test_dsl.rb
|
116
142
|
- test/spectus/test_expectation_target.rb
|
117
143
|
- test/spectus/test_matcher.rb
|
118
|
-
- test/spectus/test_reporter.rb
|
119
144
|
- test/spectus/test_version.rb
|
120
145
|
- test/support.rb
|
121
146
|
- test/support/coverage.rb
|
@@ -136,9 +161,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
136
161
|
version: 2.0.0
|
137
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
163
|
requirements:
|
139
|
-
- - "
|
164
|
+
- - ">="
|
140
165
|
- !ruby/object:Gem::Version
|
141
|
-
version:
|
166
|
+
version: '0'
|
142
167
|
requirements: []
|
143
168
|
rubyforge_project:
|
144
169
|
rubygems_version: 2.2.2
|
@@ -166,7 +191,6 @@ test_files:
|
|
166
191
|
- test/spectus/test_dsl.rb
|
167
192
|
- test/spectus/test_expectation_target.rb
|
168
193
|
- test/spectus/test_matcher.rb
|
169
|
-
- test/spectus/test_reporter.rb
|
170
194
|
- test/spectus/test_version.rb
|
171
195
|
- test/support.rb
|
172
196
|
- test/support/coverage.rb
|
metadata.gz.sig
ADDED
Binary file
|
data/lib/spectus/reporter.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
module Spectus
|
2
|
-
|
3
|
-
# This class is responsible for reporting the result of the expectation.
|
4
|
-
class Reporter
|
5
|
-
attr_reader :negated, :matcher, :expected, :exception
|
6
|
-
|
7
|
-
# @api private
|
8
|
-
def initialize negated, matcher, expected, result
|
9
|
-
@negated = negated
|
10
|
-
@matcher = matcher
|
11
|
-
@expected = expected
|
12
|
-
@pass = result.equal? true
|
13
|
-
@exception = ([ true, false ].include?(result) ? nil : result)
|
14
|
-
|
15
|
-
freeze
|
16
|
-
end
|
17
|
-
|
18
|
-
# Returns true if the expectation is true. False otherwise.
|
19
|
-
def pass?
|
20
|
-
@pass
|
21
|
-
end
|
22
|
-
|
23
|
-
# Returns the state of the expectation.
|
24
|
-
def state
|
25
|
-
if pass?
|
26
|
-
:success
|
27
|
-
elsif @exception.nil?
|
28
|
-
:failure
|
29
|
-
else
|
30
|
-
:error
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# Returns a char as the result of the expectation.
|
35
|
-
def to_s
|
36
|
-
if pass?
|
37
|
-
'.'
|
38
|
-
elsif @exception.nil?
|
39
|
-
'F'
|
40
|
-
else
|
41
|
-
'E'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require_relative 'helper_test'
|
2
|
-
|
3
|
-
subject "reported success" do
|
4
|
-
Spectus::Reporter.new true, :foo, 42, true
|
5
|
-
end
|
6
|
-
|
7
|
-
it 'must return nil as the is no exceptions' do
|
8
|
-
expect { subject.exception }.to equal: nil
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'must pass' do
|
12
|
-
expect { subject.pass? }.to equal: true
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'must be a negative assertion' do
|
16
|
-
expect { subject.negated }.to equal: true
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'must be foo matcher' do
|
20
|
-
expect { subject.matcher }.to equal: :foo
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'must expect 42' do
|
24
|
-
expect { subject.expected }.to equal: 42
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'must return a state' do
|
28
|
-
expect { subject.state }.to equal: :success
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'must return a char' do
|
32
|
-
expect { subject.to_s }.to eql: '.'
|
33
|
-
end
|
34
|
-
|
35
|
-
subject "reported error" do
|
36
|
-
Spectus::Reporter.new false, :foo, 4, :BOOM
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'must return the cached exception' do
|
40
|
-
expect { subject.exception }.to equal: :BOOM
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'wont pass' do
|
44
|
-
expect { subject.pass? }.to equal: false
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'must be a positive assertion' do
|
48
|
-
expect { subject.negated }.to equal: false
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'must be foo matcher' do
|
52
|
-
expect { subject.matcher }.to equal: :foo
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'must expect 4' do
|
56
|
-
expect { subject.expected }.to equal: 4
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'must return a state' do
|
60
|
-
expect { subject.state }.to equal: :error
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'must return a char' do
|
64
|
-
expect { subject.to_s }.to eql: 'E'
|
65
|
-
end
|
66
|
-
|
67
|
-
subject "reported failure" do
|
68
|
-
Spectus::Reporter.new false, :foo, 9, false
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'must return nil as the is no exceptions' do
|
72
|
-
expect { subject.exception }.to equal: nil
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'wont pass' do
|
76
|
-
expect { subject.pass? }.to equal: false
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'must be a positive assertion' do
|
80
|
-
expect { subject.negated }.to equal: false
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'must be foo matcher' do
|
84
|
-
expect { subject.matcher }.to equal: :foo
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'must expect 9' do
|
88
|
-
expect { subject.expected }.to equal: 9
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'must return a state' do
|
92
|
-
expect { subject.state }.to equal: :failure
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'must return a char' do
|
96
|
-
expect { subject.to_s }.to eql: 'F'
|
97
|
-
end
|