spectus 1.0.1 → 1.1.1
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 +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +26 -15
- data/VERSION.semver +1 -1
- data/example/duck/app.rb +1 -1
- data/example/duck/lib.rb +2 -3
- data/example/duck/test.rb +29 -6
- data/lib/spectus/expectation_target.rb +5 -7
- data/lib/spectus/matcher.rb +4 -8
- data/lib/spectus/matcher/eql.rb +1 -3
- data/lib/spectus/matcher/equal.rb +1 -3
- data/lib/spectus/matcher/match.rb +1 -3
- data/lib/spectus/matcher/raise_exception.rb +1 -3
- data/test/spectus/matcher/built_in/test_eql.rb +4 -4
- data/test/spectus/matcher/built_in/test_equal.rb +4 -4
- data/test/spectus/matcher/built_in/test_match.rb +4 -4
- data/test/spectus/matcher/built_in/test_raise_exception.rb +4 -4
- data/test/spectus/matcher/custom/be_prime/test_be_prime.rb +4 -4
- data/test/spectus/matcher/custom/be_the_answer/test_be_the_answer.rb +4 -4
- data/test/spectus/matcher/custom/start_with/test_start_with.rb +4 -4
- data/test/spectus/test_matcher.rb +6 -8
- data/test/support/coverage.rb +9 -1
- data/test/support/env.rb +1 -4
- data/test/support/immutable.rb +12 -0
- data/test/support/presenter.rb +1 -19
- metadata +4 -10
- metadata.gz.sig +0 -0
- data/lib/spectus/matcher/capture_stderr.rb +0 -28
- data/lib/spectus/matcher/capture_stdout.rb +0 -28
- data/test/spectus/matcher/built_in/test_capture_stderr.rb +0 -21
- data/test/spectus/matcher/built_in/test_capture_stdout.rb +0 -21
- data/test/spectus/test_expectation_target.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b29a968ab4babf3a903050203e7deb144040793
|
4
|
+
data.tar.gz: 88bceace4526d5b32086d8cffc4b0bafe0a63eea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33c4154ad5a8df2a17a18c150f8f08415cde517314b3b108ae25eb5e2150016d88653ff7a20e0bb0f6dd90e4daa4cdf4d443ec6e96da003cc8d0b5a3874ad506
|
7
|
+
data.tar.gz: 044277ab6398d8d44b2566b858cb394f22e75c6f8dcd09eae299e3beb3245c7c1304f2fb6966d925feb20f0f119e480b3d1635d5011688fc046c6142176ad660
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -41,8 +41,8 @@ $ gem install spectus
|
|
41
41
|
|
42
42
|
## Why would I want this library?
|
43
43
|
|
44
|
-
* It's
|
45
|
-
* Atomic state transitions,
|
44
|
+
* It's 143 lines of fast and KISS code.
|
45
|
+
* Atomic state transitions, unmutated objects, thread-safe.
|
46
46
|
* Provides a generic and consistent DSL for assertions.
|
47
47
|
|
48
48
|
## API
|
@@ -53,7 +53,7 @@ It takes a block parameter and responds to:
|
|
53
53
|
* `to(definition)`
|
54
54
|
* `not_to(definition)`
|
55
55
|
|
56
|
-
Then it returns `true
|
56
|
+
Then, it returns `true` or `false`; or it raises an exception.
|
57
57
|
|
58
58
|
## Usage
|
59
59
|
|
@@ -81,6 +81,29 @@ end
|
|
81
81
|
require 'spectus'
|
82
82
|
extend Spectus::DSL
|
83
83
|
|
84
|
+
# Let's define the custom matcher `capture_stdout`.
|
85
|
+
require 'stringio'
|
86
|
+
module Spectus
|
87
|
+
module Matcher
|
88
|
+
class CaptureStdout
|
89
|
+
def initialize expected
|
90
|
+
@expected = expected
|
91
|
+
end
|
92
|
+
|
93
|
+
def matches?
|
94
|
+
begin
|
95
|
+
orig_std = $stdout
|
96
|
+
$stdout = StringIO.new
|
97
|
+
yield
|
98
|
+
$stdout.string.eql? @expected
|
99
|
+
ensure
|
100
|
+
$stdout = orig_std
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
84
107
|
expectation_1 = expect { @bird.walks }.to eql: "Klop klop!"
|
85
108
|
expectation_2 = expect { @bird.swims }.to eql: "Swoosh..."
|
86
109
|
expectation_3 = expect { @bird.quacks }.to capture_stdout: "Quaaaaaack!\n"
|
@@ -99,18 +122,6 @@ end
|
|
99
122
|
|
100
123
|
## Built-in matchers
|
101
124
|
|
102
|
-
### Standard error
|
103
|
-
|
104
|
-
```ruby
|
105
|
-
expect { warn 'foo' }.to capture_stderr: "foo\n" # => true
|
106
|
-
```
|
107
|
-
|
108
|
-
### Standard output
|
109
|
-
|
110
|
-
```ruby
|
111
|
-
expect { puts 'foo' }.to capture_stdout: "foo\n" # => true
|
112
|
-
```
|
113
|
-
|
114
125
|
### Equivalence
|
115
126
|
|
116
127
|
```ruby
|
data/VERSION.semver
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.1
|
data/example/duck/app.rb
CHANGED
data/example/duck/lib.rb
CHANGED
data/example/duck/test.rb
CHANGED
@@ -2,19 +2,42 @@
|
|
2
2
|
|
3
3
|
require_relative 'app'
|
4
4
|
|
5
|
-
|
5
|
+
require_relative '../../lib/spectus'
|
6
6
|
|
7
7
|
extend Spectus::DSL
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
# Let's define the custom matcher `capture_stdout`.
|
10
|
+
require 'stringio'
|
11
|
+
module Spectus
|
12
|
+
module Matcher
|
13
|
+
class CaptureStdout
|
14
|
+
def initialize expected
|
15
|
+
@expected = expected
|
16
|
+
end
|
17
|
+
|
18
|
+
def matches?
|
19
|
+
begin
|
20
|
+
orig_std = $stdout
|
21
|
+
$stdout = StringIO.new
|
22
|
+
yield
|
23
|
+
$stdout.string.eql? @expected
|
24
|
+
ensure
|
25
|
+
$stdout = orig_std
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
expectation_1 = expect { @bird.walks }.to eql: "Klop klop!"
|
33
|
+
expectation_2 = expect { @bird.swims }.to eql: "Swoosh..."
|
34
|
+
expectation_3 = expect { @bird.quacks }.to capture_stdout: "Quaaaaaack!\n"
|
35
|
+
expectation_4 = expect { @bird.speaks }.to raise_exception: NoMethodError
|
13
36
|
|
14
37
|
case (expectation_1 == true &&
|
15
38
|
expectation_2 == true &&
|
16
39
|
expectation_3 == true &&
|
17
40
|
expectation_4 == true)
|
18
|
-
when true then puts "I call that #{@
|
41
|
+
when true then puts "I call that #{@bird} a duck."
|
19
42
|
else abort 'WAT?'
|
20
43
|
end
|
@@ -6,29 +6,27 @@ module Spectus
|
|
6
6
|
#
|
7
7
|
# @example
|
8
8
|
# expect { do_something } # => ExpectationTarget wrapping the block
|
9
|
-
class ExpectationTarget
|
9
|
+
class ExpectationTarget < BasicObject
|
10
10
|
def initialize &actual
|
11
11
|
@actual = actual
|
12
|
-
|
13
|
-
freeze
|
14
12
|
end
|
15
13
|
|
16
14
|
# Evaluate to a positive assertion.
|
17
15
|
#
|
18
16
|
# @api public
|
19
17
|
#
|
20
|
-
# @see Matcher#
|
18
|
+
# @see Matcher#pass?
|
21
19
|
def to definition
|
22
|
-
Matcher.
|
20
|
+
Matcher.pass? false, definition, &@actual
|
23
21
|
end
|
24
22
|
|
25
23
|
# Evaluate to a negative assertion.
|
26
24
|
#
|
27
25
|
# @api public
|
28
26
|
#
|
29
|
-
# @see Matcher#
|
27
|
+
# @see Matcher#pass?
|
30
28
|
def not_to definition
|
31
|
-
Matcher.
|
29
|
+
Matcher.pass? true, definition, &@actual
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
data/lib/spectus/matcher.rb
CHANGED
@@ -8,18 +8,14 @@ module Spectus
|
|
8
8
|
# @param [Boolean] negated
|
9
9
|
# @param [Hash] definition
|
10
10
|
#
|
11
|
-
# @return [
|
12
|
-
def self.
|
13
|
-
params = Array(definition).flatten
|
11
|
+
# @return [Boolean] Report if the expectation is true or false.
|
12
|
+
def self.pass? negated, definition, &actual
|
13
|
+
params = Array(definition).flatten 1
|
14
14
|
name = params.first
|
15
15
|
expected_args = params[1..-1]
|
16
16
|
matcher = Matcher.get(name).new(*expected_args)
|
17
17
|
|
18
|
-
|
19
|
-
negated ^ matcher.matches?(&actual)
|
20
|
-
rescue => e
|
21
|
-
e
|
22
|
-
end
|
18
|
+
negated ^ matcher.matches?(&actual)
|
23
19
|
end
|
24
20
|
|
25
21
|
# Get the class of a matcher from its symbol.
|
data/lib/spectus/matcher/eql.rb
CHANGED
@@ -2,11 +2,9 @@ module Spectus
|
|
2
2
|
module Matcher
|
3
3
|
|
4
4
|
# Provides the implementation for `equal`.
|
5
|
-
class Equal
|
5
|
+
class Equal < BasicObject
|
6
6
|
def initialize expected
|
7
7
|
@expected = expected
|
8
|
-
|
9
|
-
freeze
|
10
8
|
end
|
11
9
|
|
12
10
|
# @return [Boolean] Comparison between actual and expected values.
|
@@ -2,11 +2,9 @@ module Spectus
|
|
2
2
|
module Matcher
|
3
3
|
|
4
4
|
# Provides the implementation for `match`.
|
5
|
-
class Match
|
5
|
+
class Match < BasicObject
|
6
6
|
def initialize expected
|
7
7
|
@expected = expected
|
8
|
-
|
9
|
-
freeze
|
10
8
|
end
|
11
9
|
|
12
10
|
# @return [Boolean] Comparison between actual and expected values.
|
@@ -2,11 +2,9 @@ module Spectus
|
|
2
2
|
module Matcher
|
3
3
|
|
4
4
|
# Provides the implementation for `raise_exception`.
|
5
|
-
class RaiseException
|
5
|
+
class RaiseException < BasicObject
|
6
6
|
def initialize expected
|
7
7
|
@expected = expected
|
8
|
-
|
9
|
-
freeze
|
10
8
|
end
|
11
9
|
|
12
10
|
# @return [Boolean] Comparison between actual and expected values.
|
@@ -4,15 +4,15 @@ subject 'eql built-in matcher' do
|
|
4
4
|
Spectus::Matcher::Eql.new 'foo'
|
5
5
|
end
|
6
6
|
|
7
|
-
it 'must return the expected value' do
|
8
|
-
expect { subject.instance_variable_get(:@expected) }.to eql: 'foo'
|
9
|
-
end
|
10
|
-
|
11
7
|
it 'must be eql' do
|
12
8
|
expect { subject.matches? { 'foo' } }.to equal: true
|
13
9
|
end
|
14
10
|
|
15
11
|
it 'must not be eql' do
|
12
|
+
expect { subject.matches? { 'bar' } }.not_to equal: true
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'must return false' do
|
16
16
|
expect { subject.matches? { 'bar' } }.to equal: false
|
17
17
|
end
|
18
18
|
|
@@ -4,15 +4,15 @@ subject 'equal built-in matcher' do
|
|
4
4
|
Spectus::Matcher::Equal.new :foo
|
5
5
|
end
|
6
6
|
|
7
|
-
it 'must return the expected value' do
|
8
|
-
expect { subject.instance_variable_get(:@expected) }.to equal: :foo
|
9
|
-
end
|
10
|
-
|
11
7
|
it 'must be equal' do
|
12
8
|
expect { subject.matches? { :foo } }.to equal: true
|
13
9
|
end
|
14
10
|
|
15
11
|
it 'must not be equal' do
|
12
|
+
expect { subject.matches? { :bar } }.not_to equal: true
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'must return false' do
|
16
16
|
expect { subject.matches? { :bar } }.to equal: false
|
17
17
|
end
|
18
18
|
|
@@ -4,15 +4,15 @@ subject 'match built-in matcher' do
|
|
4
4
|
Spectus::Matcher::Match.new(/^foo/)
|
5
5
|
end
|
6
6
|
|
7
|
-
it 'must return the expected value' do
|
8
|
-
expect { subject.instance_variable_get(:@expected) }.to({eql: /^foo/})
|
9
|
-
end
|
10
|
-
|
11
7
|
it 'must match the string' do
|
12
8
|
expect { subject.matches? { 'foobar' } }.to equal: true
|
13
9
|
end
|
14
10
|
|
15
11
|
it 'must not match the string' do
|
12
|
+
expect { subject.matches? { 'bar' } }.not_to equal: true
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'must return false' do
|
16
16
|
expect { subject.matches? { 'bar' } }.to equal: false
|
17
17
|
end
|
18
18
|
|
@@ -4,15 +4,15 @@ subject 'raise exception built-in matcher' do
|
|
4
4
|
Spectus::Matcher::RaiseException.new ZeroDivisionError
|
5
5
|
end
|
6
6
|
|
7
|
-
it 'must return the expected value' do
|
8
|
-
expect { subject.instance_variable_get(:@expected) }.to equal: ZeroDivisionError
|
9
|
-
end
|
10
|
-
|
11
7
|
it 'must raise the expected exception' do
|
12
8
|
expect { subject.matches? { 0 / 0 } }.to equal: true
|
13
9
|
end
|
14
10
|
|
15
11
|
it 'must not raise any exceptions' do
|
12
|
+
expect { subject.matches? { :foo } }.not_to equal: true
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'must return false' do
|
16
16
|
expect { subject.matches? { :foo } }.to equal: false
|
17
17
|
end
|
18
18
|
|
@@ -4,15 +4,15 @@ subject 'be prime custom matcher' do
|
|
4
4
|
Spectus::Matcher::BePrime.new
|
5
5
|
end
|
6
6
|
|
7
|
-
it 'must confirm that the instance variable is undefined' do
|
8
|
-
expect { subject.instance_variable_defined?(:@expected) }.to equal: false
|
9
|
-
end
|
10
|
-
|
11
7
|
it 'must be prime' do
|
12
8
|
expect { subject.matches? { 3 } }.to equal: true
|
13
9
|
end
|
14
10
|
|
15
11
|
it 'must not match the string' do
|
12
|
+
expect { subject.matches? { 4 } }.not_to equal: true
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'must return false' do
|
16
16
|
expect { subject.matches? { 4 } }.to equal: false
|
17
17
|
end
|
18
18
|
|
@@ -4,15 +4,15 @@ subject 'be the answer custom matcher' do
|
|
4
4
|
Spectus::Matcher::BeTheAnswer.new
|
5
5
|
end
|
6
6
|
|
7
|
-
it 'must confirm that the instance variable is undefined' do
|
8
|
-
expect { subject.instance_variable_defined?(:@expected) }.to equal: false
|
9
|
-
end
|
10
|
-
|
11
7
|
it 'must be the answer' do
|
12
8
|
expect { subject.matches? { 42 } }.to equal: true
|
13
9
|
end
|
14
10
|
|
15
11
|
it 'must not match the string' do
|
12
|
+
expect { subject.matches? { 'foo' } }.not_to equal: true
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'must return false' do
|
16
16
|
expect { subject.matches? { 'foo' } }.to equal: false
|
17
17
|
end
|
18
18
|
|
@@ -4,15 +4,15 @@ subject 'start with custom matcher' do
|
|
4
4
|
Spectus::Matcher::StartWith.new('foo')
|
5
5
|
end
|
6
6
|
|
7
|
-
it 'must return the expected value' do
|
8
|
-
expect { subject.instance_variable_get(:@expected) }.to eql: 'foo'
|
9
|
-
end
|
10
|
-
|
11
7
|
it 'must match the string' do
|
12
8
|
expect { subject.matches? { 'foobar' } }.to equal: true
|
13
9
|
end
|
14
10
|
|
15
11
|
it 'must not match the string' do
|
12
|
+
expect { subject.matches? { 'bar' } }.not_to equal: true
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'must return false' do
|
16
16
|
expect { subject.matches? { 'bar' } }.to equal: false
|
17
17
|
end
|
18
18
|
|
@@ -5,22 +5,23 @@ subject "matcher module" do
|
|
5
5
|
end
|
6
6
|
|
7
7
|
it 'must return true after the evaluation' do
|
8
|
-
expect { subject.
|
8
|
+
expect { subject.pass?(false, eql: 'foo') { 'foo' } }.to equal: true
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'must return false after the evaluation' do
|
12
|
-
expect { subject.
|
12
|
+
expect { subject.pass?(false, eql: 'foo') { 'bar' } }.to equal: false
|
13
13
|
end
|
14
14
|
|
15
|
-
it 'must
|
16
|
-
expect { subject.
|
15
|
+
it 'must raise a name error exception' do
|
16
|
+
expect { subject.pass?(false, eql: 'foo') { BOOM } }.
|
17
|
+
to raise_exception: NameError
|
17
18
|
end
|
18
19
|
|
19
20
|
it 'must return the class of a matcher from its symbol' do
|
20
21
|
expect { subject.get(:eql).equal? subject.const_get(:Eql) }.to equal: true
|
21
22
|
end
|
22
23
|
|
23
|
-
it 'must raise
|
24
|
+
it 'must raise a name error exception' do
|
24
25
|
expect { subject.get(:foo).equal? subject.const_get(:Foo) }.
|
25
26
|
to raise_exception: NameError
|
26
27
|
end
|
@@ -29,9 +30,6 @@ it 'must no longer raise' do
|
|
29
30
|
module Spectus
|
30
31
|
module Matcher
|
31
32
|
class Foo
|
32
|
-
def matches?
|
33
|
-
true
|
34
|
-
end
|
35
33
|
end
|
36
34
|
end
|
37
35
|
end
|
data/test/support/coverage.rb
CHANGED
data/test/support/env.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
class Object
|
2
|
+
alias_method :overridden_initialize, :initialize
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
overridden_initialize
|
6
|
+
|
7
|
+
if !self.class.ancestors.include?(SimpleCov::Formatter::MultiFormatter) &&
|
8
|
+
!self.class.ancestors.include?(SimpleCov::Formatter::HTMLFormatter)
|
9
|
+
freeze
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/test/support/presenter.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
@failures = 0
|
2
|
-
|
3
1
|
def subject title = nil, &block
|
4
2
|
if block
|
5
3
|
@subject = block.call
|
@@ -11,21 +9,5 @@ end
|
|
11
9
|
|
12
10
|
def it describe, &expectation
|
13
11
|
print " * #{describe}: ".ljust 79
|
14
|
-
|
15
|
-
result = expectation.call
|
16
|
-
|
17
|
-
case result
|
18
|
-
when true
|
19
|
-
puts "\e[32m.\e[0m"
|
20
|
-
when false
|
21
|
-
@failures += 1
|
22
|
-
warn "\e[31mF\e[0m"
|
23
|
-
else
|
24
|
-
@failures += 1
|
25
|
-
fail result
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
at_exit do
|
30
|
-
abort("\e[31mFailure.\e[0m") unless @failures.zero?
|
12
|
+
expectation.call.equal?(true) ? puts('.') : abort('F')
|
31
13
|
end
|
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: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Wack
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
zeYBFLJQAl0AQPaGujsG5tssIabiNy1ryydKAjWkNDxqLgvtwST3L0Qr9UQFQgoA
|
31
31
|
O2Rl8PjSD+2P9XE7T2x1xQ==
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2014-10-
|
33
|
+
date: 2014-10-19 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: bundler
|
@@ -112,8 +112,6 @@ files:
|
|
112
112
|
- lib/spectus/dsl.rb
|
113
113
|
- lib/spectus/expectation_target.rb
|
114
114
|
- lib/spectus/matcher.rb
|
115
|
-
- lib/spectus/matcher/capture_stderr.rb
|
116
|
-
- lib/spectus/matcher/capture_stdout.rb
|
117
115
|
- lib/spectus/matcher/eql.rb
|
118
116
|
- lib/spectus/matcher/equal.rb
|
119
117
|
- lib/spectus/matcher/match.rb
|
@@ -124,8 +122,6 @@ files:
|
|
124
122
|
- test/helper_test.rb
|
125
123
|
- test/spectus/helper_test.rb
|
126
124
|
- test/spectus/matcher/built_in/helper_test.rb
|
127
|
-
- test/spectus/matcher/built_in/test_capture_stderr.rb
|
128
|
-
- test/spectus/matcher/built_in/test_capture_stdout.rb
|
129
125
|
- test/spectus/matcher/built_in/test_eql.rb
|
130
126
|
- test/spectus/matcher/built_in/test_equal.rb
|
131
127
|
- test/spectus/matcher/built_in/test_match.rb
|
@@ -139,12 +135,12 @@ files:
|
|
139
135
|
- test/spectus/matcher/custom/start_with/test_start_with.rb
|
140
136
|
- test/spectus/matcher/helper_test.rb
|
141
137
|
- test/spectus/test_dsl.rb
|
142
|
-
- test/spectus/test_expectation_target.rb
|
143
138
|
- test/spectus/test_matcher.rb
|
144
139
|
- test/spectus/test_version.rb
|
145
140
|
- test/support.rb
|
146
141
|
- test/support/coverage.rb
|
147
142
|
- test/support/env.rb
|
143
|
+
- test/support/immutable.rb
|
148
144
|
- test/support/presenter.rb
|
149
145
|
homepage: https://github.com/fixrb/spectus
|
150
146
|
licenses:
|
@@ -174,8 +170,6 @@ test_files:
|
|
174
170
|
- test/helper_test.rb
|
175
171
|
- test/spectus/helper_test.rb
|
176
172
|
- test/spectus/matcher/built_in/helper_test.rb
|
177
|
-
- test/spectus/matcher/built_in/test_capture_stderr.rb
|
178
|
-
- test/spectus/matcher/built_in/test_capture_stdout.rb
|
179
173
|
- test/spectus/matcher/built_in/test_eql.rb
|
180
174
|
- test/spectus/matcher/built_in/test_equal.rb
|
181
175
|
- test/spectus/matcher/built_in/test_match.rb
|
@@ -189,11 +183,11 @@ test_files:
|
|
189
183
|
- test/spectus/matcher/custom/start_with/test_start_with.rb
|
190
184
|
- test/spectus/matcher/helper_test.rb
|
191
185
|
- test/spectus/test_dsl.rb
|
192
|
-
- test/spectus/test_expectation_target.rb
|
193
186
|
- test/spectus/test_matcher.rb
|
194
187
|
- test/spectus/test_version.rb
|
195
188
|
- test/support.rb
|
196
189
|
- test/support/coverage.rb
|
197
190
|
- test/support/env.rb
|
191
|
+
- test/support/immutable.rb
|
198
192
|
- test/support/presenter.rb
|
199
193
|
has_rdoc:
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'stringio'
|
2
|
-
|
3
|
-
module Spectus
|
4
|
-
module Matcher
|
5
|
-
|
6
|
-
# Provides the implementation for `capture_stderr`.
|
7
|
-
class CaptureStderr
|
8
|
-
def initialize expected
|
9
|
-
@expected = expected
|
10
|
-
|
11
|
-
freeze
|
12
|
-
end
|
13
|
-
|
14
|
-
# @return [Boolean] Comparison between actual and expected values.
|
15
|
-
def matches?
|
16
|
-
begin
|
17
|
-
orig_std = $stderr
|
18
|
-
$stderr = StringIO.new
|
19
|
-
|
20
|
-
yield
|
21
|
-
$stderr.string.eql? @expected
|
22
|
-
ensure
|
23
|
-
$stderr = orig_std
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'stringio'
|
2
|
-
|
3
|
-
module Spectus
|
4
|
-
module Matcher
|
5
|
-
|
6
|
-
# Provides the implementation for `capture_stdout`.
|
7
|
-
class CaptureStdout
|
8
|
-
def initialize expected
|
9
|
-
@expected = expected
|
10
|
-
|
11
|
-
freeze
|
12
|
-
end
|
13
|
-
|
14
|
-
# @return [Boolean] Comparison between actual and expected values.
|
15
|
-
def matches?
|
16
|
-
begin
|
17
|
-
orig_std = $stdout
|
18
|
-
$stdout = StringIO.new
|
19
|
-
|
20
|
-
yield
|
21
|
-
$stdout.string.eql? @expected
|
22
|
-
ensure
|
23
|
-
$stdout = orig_std
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require_relative 'helper_test'
|
2
|
-
|
3
|
-
subject 'capture standard error built-in matcher' do
|
4
|
-
Spectus::Matcher::CaptureStderr.new "foo\n"
|
5
|
-
end
|
6
|
-
|
7
|
-
it 'must return the expected value' do
|
8
|
-
expect { subject.instance_variable_get(:@expected) }.to eql: "foo\n"
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'must match the captured standard error' do
|
12
|
-
expect { subject.matches? { warn 'foo' } }.to equal: true
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'must not match the captured standard error' do
|
16
|
-
expect { subject.matches? { warn 'bar' } }.to equal: false
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'must return the raised exception' do
|
20
|
-
expect { raise subject.matches? { BOOM } }.to raise_exception: NameError
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require_relative 'helper_test'
|
2
|
-
|
3
|
-
subject 'capture standard output built-in matcher' do
|
4
|
-
Spectus::Matcher::CaptureStdout.new "foo\n"
|
5
|
-
end
|
6
|
-
|
7
|
-
it 'must return the expected value' do
|
8
|
-
expect { subject.instance_variable_get(:@expected) }.to eql: "foo\n"
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'must match the captured standard output' do
|
12
|
-
expect { subject.matches? { puts 'foo' } }.to equal: true
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'must not match the captured standard output' do
|
16
|
-
expect { subject.matches? { puts 'bar' } }.to equal: false
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'must return the raised exception' do
|
20
|
-
expect { raise subject.matches? { BOOM } }.to raise_exception: NameError
|
21
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require_relative 'helper_test'
|
2
|
-
|
3
|
-
subject "expectation target" do
|
4
|
-
Spectus::ExpectationTarget.new { 42 }
|
5
|
-
end
|
6
|
-
|
7
|
-
it 'must confirm that the block is defined' do
|
8
|
-
expect { subject.instance_variable_defined?(:@actual) }.to equal: true
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'must responds to :to' do
|
12
|
-
expect { subject.respond_to? :to }.to equal: true
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'must responds to :not_to' do
|
16
|
-
expect { subject.respond_to? :not_to }.to equal: true
|
17
|
-
end
|