spectus 1.1.1 → 2.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 +0 -0
- data.tar.gz.sig +0 -0
- data/.gitignore +0 -5
- data/.travis.yml +12 -3
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +3 -0
- data/LICENSE.md +17 -18
- data/README.md +18 -199
- data/VERSION.semver +1 -1
- data/bin/console +7 -0
- data/bin/setup +5 -0
- data/lib/spectus.rb +12 -2
- data/lib/spectus/expectation_target.rb +86 -12
- data/lib/spectus/requirement_level/high.rb +36 -0
- data/lib/spectus/requirement_level/low.rb +22 -0
- data/lib/spectus/requirement_level/medium.rb +22 -0
- data/lib/spectus/sandbox.rb +31 -0
- data/{spectus.pem → spectus-gem-public_cert.pem} +0 -0
- data/spectus.gemspec +14 -10
- metadata +50 -72
- metadata.gz.sig +0 -0
- data/.coveralls.yml +0 -1
- data/example/duck/README.md +0 -6
- data/example/duck/app.rb +0 -3
- data/example/duck/lib.rb +0 -13
- data/example/duck/test.rb +0 -43
- data/lib/spectus/dsl.rb +0 -20
- data/lib/spectus/matcher.rb +0 -34
- data/lib/spectus/matcher/eql.rb +0 -16
- data/lib/spectus/matcher/equal.rb +0 -16
- data/lib/spectus/matcher/match.rb +0 -16
- data/lib/spectus/matcher/raise_exception.rb +0 -22
- data/lib/spectus/version.rb +0 -9
- data/test/helper_test.rb +0 -4
- data/test/spectus/helper_test.rb +0 -1
- data/test/spectus/matcher/built_in/helper_test.rb +0 -1
- data/test/spectus/matcher/built_in/test_eql.rb +0 -21
- data/test/spectus/matcher/built_in/test_equal.rb +0 -21
- data/test/spectus/matcher/built_in/test_match.rb +0 -21
- data/test/spectus/matcher/built_in/test_raise_exception.rb +0 -21
- data/test/spectus/matcher/custom/be_prime/helper_test.rb +0 -13
- data/test/spectus/matcher/custom/be_prime/test_be_prime.rb +0 -21
- data/test/spectus/matcher/custom/be_the_answer/helper_test.rb +0 -11
- data/test/spectus/matcher/custom/be_the_answer/test_be_the_answer.rb +0 -21
- data/test/spectus/matcher/custom/helper_test.rb +0 -1
- data/test/spectus/matcher/custom/start_with/helper_test.rb +0 -15
- data/test/spectus/matcher/custom/start_with/test_start_with.rb +0 -21
- data/test/spectus/matcher/helper_test.rb +0 -1
- data/test/spectus/test_dsl.rb +0 -9
- data/test/spectus/test_matcher.rb +0 -38
- data/test/spectus/test_version.rb +0 -11
- data/test/support.rb +0 -3
- data/test/support/coverage.rb +0 -11
- data/test/support/env.rb +0 -1
- data/test/support/immutable.rb +0 -12
- data/test/support/presenter.rb +0 -13
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative File.join '..', 'sandbox'
|
2
|
+
|
3
|
+
module Spectus
|
4
|
+
# Contains requirement levels.
|
5
|
+
#
|
6
|
+
module RequirementLevel
|
7
|
+
# _High_ requirement level.
|
8
|
+
#
|
9
|
+
class High < BasicObject
|
10
|
+
# Initialize the requirement level class.
|
11
|
+
#
|
12
|
+
# @param [Hash] definition
|
13
|
+
# @param [Boolean] negate
|
14
|
+
def initialize(definition, negate = false)
|
15
|
+
@definition = definition
|
16
|
+
@negate = negate
|
17
|
+
end
|
18
|
+
|
19
|
+
# Evaluate the expectation with the passed block.
|
20
|
+
#
|
21
|
+
# @return [Boolean] report if the expectation is true or false.
|
22
|
+
def pass?(&actual)
|
23
|
+
sandbox(&actual).pass?(@negate)
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
# Run the actual block against the definition.
|
29
|
+
#
|
30
|
+
# @return [Boolean] report if the expectation is true or false.
|
31
|
+
def sandbox(&actual)
|
32
|
+
Sandbox.new(@definition, &actual)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative 'medium'
|
2
|
+
|
3
|
+
module Spectus
|
4
|
+
# Contains requirement levels.
|
5
|
+
#
|
6
|
+
module RequirementLevel
|
7
|
+
# _Low_ requirement level.
|
8
|
+
#
|
9
|
+
class Low < Medium
|
10
|
+
# Evaluate the expectation with the passed block.
|
11
|
+
#
|
12
|
+
# @return [Boolean] report if the expectation is true or false.
|
13
|
+
def pass?(&actual)
|
14
|
+
if sandbox(&actual).exception.class.equal?(::NoMethodError)
|
15
|
+
true
|
16
|
+
else
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative 'high'
|
2
|
+
|
3
|
+
module Spectus
|
4
|
+
# Contains requirement levels.
|
5
|
+
#
|
6
|
+
module RequirementLevel
|
7
|
+
# _Medium_ requirement level.
|
8
|
+
#
|
9
|
+
class Medium < High
|
10
|
+
# Evaluate the expectation with the passed block.
|
11
|
+
#
|
12
|
+
# @return [Boolean] report if the expectation is true or false.
|
13
|
+
def pass?(&actual)
|
14
|
+
if super
|
15
|
+
true
|
16
|
+
else
|
17
|
+
sandbox(&actual).exception.nil?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'expect'
|
2
|
+
|
3
|
+
module Spectus
|
4
|
+
# This class evaluate the expectation with the passed block.
|
5
|
+
#
|
6
|
+
class Sandbox < BasicObject
|
7
|
+
attr_reader :exception, :got
|
8
|
+
|
9
|
+
# Execute the untested code from the passed block against the definition.
|
10
|
+
#
|
11
|
+
# @param [Hash] definition
|
12
|
+
def initialize(definition, &actual)
|
13
|
+
@got = ::Expect.this(&actual).to(definition)
|
14
|
+
rescue => e
|
15
|
+
@exception = e
|
16
|
+
end
|
17
|
+
|
18
|
+
# Return the result as a positive or a negative assertion.
|
19
|
+
#
|
20
|
+
# @param [Boolean] negate
|
21
|
+
#
|
22
|
+
# @return [Boolean] Report if the test was true or false.
|
23
|
+
def pass?(negate)
|
24
|
+
if defined?(@exception)
|
25
|
+
false
|
26
|
+
else
|
27
|
+
negate ^ @got
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
File without changes
|
data/spectus.gemspec
CHANGED
@@ -2,25 +2,29 @@ Gem::Specification.new do |spec|
|
|
2
2
|
spec.name = 'spectus'
|
3
3
|
spec.version = File.read('VERSION.semver')
|
4
4
|
spec.authors = ['Cyril Wack']
|
5
|
-
spec.email = ['cyril
|
6
|
-
|
7
|
-
spec.
|
5
|
+
spec.email = ['contact@cyril.email']
|
6
|
+
|
7
|
+
spec.summary = 'Expectation library with requirement levels.'
|
8
|
+
spec.description = 'Expectation library with RFC 2119\'s requirement ' \
|
9
|
+
'levels, and some matchers for Ruby.'
|
8
10
|
spec.homepage = 'https://github.com/fixrb/spectus'
|
9
11
|
spec.license = 'MIT'
|
10
12
|
|
11
|
-
spec.files
|
12
|
-
spec.
|
13
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(/^test\//) }
|
14
|
+
spec.executables = spec.files.grep(/^exe\//) { |f| File.basename(f) }
|
13
15
|
spec.require_paths = ['lib']
|
14
|
-
spec.required_ruby_version = '>= 2.0.0'
|
15
16
|
|
16
|
-
spec.
|
17
|
+
spec.add_dependency 'expect', '~> 0.0.4'
|
18
|
+
|
19
|
+
spec.add_development_dependency 'bundler', '~> 1.8'
|
17
20
|
spec.add_development_dependency 'rake', '~> 10.0'
|
18
21
|
spec.add_development_dependency 'yard', '~> 0.8'
|
19
|
-
spec.add_development_dependency '
|
22
|
+
spec.add_development_dependency 'simplecov', '~> 0.9.1'
|
23
|
+
spec.add_development_dependency 'rubocop', '~> 0.29'
|
20
24
|
|
21
|
-
private_key = File.expand_path '~/.
|
25
|
+
private_key = File.expand_path '~/.gem/spectus-gem-private_key.pem'
|
22
26
|
if File.exist? private_key
|
23
27
|
spec.signing_key = private_key
|
24
|
-
spec.cert_chain = ['spectus.pem']
|
28
|
+
spec.cert_chain = ['spectus-gem-public_cert.pem']
|
25
29
|
end
|
26
30
|
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:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Wack
|
@@ -30,22 +30,36 @@ cert_chain:
|
|
30
30
|
zeYBFLJQAl0AQPaGujsG5tssIabiNy1ryydKAjWkNDxqLgvtwST3L0Qr9UQFQgoA
|
31
31
|
O2Rl8PjSD+2P9XE7T2x1xQ==
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date:
|
33
|
+
date: 2015-02-14 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: expect
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.0.4
|
42
|
+
type: :runtime
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.0.4
|
35
49
|
- !ruby/object:Gem::Dependency
|
36
50
|
name: bundler
|
37
51
|
requirement: !ruby/object:Gem::Requirement
|
38
52
|
requirements:
|
39
53
|
- - "~>"
|
40
54
|
- !ruby/object:Gem::Version
|
41
|
-
version: '1.
|
55
|
+
version: '1.8'
|
42
56
|
type: :development
|
43
57
|
prerelease: false
|
44
58
|
version_requirements: !ruby/object:Gem::Requirement
|
45
59
|
requirements:
|
46
60
|
- - "~>"
|
47
61
|
- !ruby/object:Gem::Version
|
48
|
-
version: '1.
|
62
|
+
version: '1.8'
|
49
63
|
- !ruby/object:Gem::Dependency
|
50
64
|
name: rake
|
51
65
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,73 +89,60 @@ dependencies:
|
|
75
89
|
- !ruby/object:Gem::Version
|
76
90
|
version: '0.8'
|
77
91
|
- !ruby/object:Gem::Dependency
|
78
|
-
name:
|
92
|
+
name: simplecov
|
93
|
+
requirement: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 0.9.1
|
98
|
+
type: :development
|
99
|
+
prerelease: false
|
100
|
+
version_requirements: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 0.9.1
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: rubocop
|
79
107
|
requirement: !ruby/object:Gem::Requirement
|
80
108
|
requirements:
|
81
109
|
- - "~>"
|
82
110
|
- !ruby/object:Gem::Version
|
83
|
-
version: '0.
|
111
|
+
version: '0.29'
|
84
112
|
type: :development
|
85
113
|
prerelease: false
|
86
114
|
version_requirements: !ruby/object:Gem::Requirement
|
87
115
|
requirements:
|
88
116
|
- - "~>"
|
89
117
|
- !ruby/object:Gem::Version
|
90
|
-
version: '0.
|
91
|
-
description: Expectation library with some matchers
|
118
|
+
version: '0.29'
|
119
|
+
description: Expectation library with RFC 2119's requirement levels, and some matchers
|
120
|
+
for Ruby.
|
92
121
|
email:
|
93
|
-
- cyril
|
122
|
+
- contact@cyril.email
|
94
123
|
executables: []
|
95
124
|
extensions: []
|
96
125
|
extra_rdoc_files: []
|
97
126
|
files:
|
98
|
-
- ".coveralls.yml"
|
99
127
|
- ".gitignore"
|
100
128
|
- ".travis.yml"
|
101
129
|
- ".yardopts"
|
130
|
+
- CODE_OF_CONDUCT.md
|
102
131
|
- Gemfile
|
103
132
|
- LICENSE.md
|
104
133
|
- README.md
|
105
134
|
- Rakefile
|
106
135
|
- VERSION.semver
|
107
|
-
-
|
108
|
-
-
|
109
|
-
- example/duck/lib.rb
|
110
|
-
- example/duck/test.rb
|
136
|
+
- bin/console
|
137
|
+
- bin/setup
|
111
138
|
- lib/spectus.rb
|
112
|
-
- lib/spectus/dsl.rb
|
113
139
|
- lib/spectus/expectation_target.rb
|
114
|
-
- lib/spectus/
|
115
|
-
- lib/spectus/
|
116
|
-
- lib/spectus/
|
117
|
-
- lib/spectus/
|
118
|
-
-
|
119
|
-
- lib/spectus/version.rb
|
140
|
+
- lib/spectus/requirement_level/high.rb
|
141
|
+
- lib/spectus/requirement_level/low.rb
|
142
|
+
- lib/spectus/requirement_level/medium.rb
|
143
|
+
- lib/spectus/sandbox.rb
|
144
|
+
- spectus-gem-public_cert.pem
|
120
145
|
- spectus.gemspec
|
121
|
-
- spectus.pem
|
122
|
-
- test/helper_test.rb
|
123
|
-
- test/spectus/helper_test.rb
|
124
|
-
- test/spectus/matcher/built_in/helper_test.rb
|
125
|
-
- test/spectus/matcher/built_in/test_eql.rb
|
126
|
-
- test/spectus/matcher/built_in/test_equal.rb
|
127
|
-
- test/spectus/matcher/built_in/test_match.rb
|
128
|
-
- test/spectus/matcher/built_in/test_raise_exception.rb
|
129
|
-
- test/spectus/matcher/custom/be_prime/helper_test.rb
|
130
|
-
- test/spectus/matcher/custom/be_prime/test_be_prime.rb
|
131
|
-
- test/spectus/matcher/custom/be_the_answer/helper_test.rb
|
132
|
-
- test/spectus/matcher/custom/be_the_answer/test_be_the_answer.rb
|
133
|
-
- test/spectus/matcher/custom/helper_test.rb
|
134
|
-
- test/spectus/matcher/custom/start_with/helper_test.rb
|
135
|
-
- test/spectus/matcher/custom/start_with/test_start_with.rb
|
136
|
-
- test/spectus/matcher/helper_test.rb
|
137
|
-
- test/spectus/test_dsl.rb
|
138
|
-
- test/spectus/test_matcher.rb
|
139
|
-
- test/spectus/test_version.rb
|
140
|
-
- test/support.rb
|
141
|
-
- test/support/coverage.rb
|
142
|
-
- test/support/env.rb
|
143
|
-
- test/support/immutable.rb
|
144
|
-
- test/support/presenter.rb
|
145
146
|
homepage: https://github.com/fixrb/spectus
|
146
147
|
licenses:
|
147
148
|
- MIT
|
@@ -154,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
155
|
requirements:
|
155
156
|
- - ">="
|
156
157
|
- !ruby/object:Gem::Version
|
157
|
-
version:
|
158
|
+
version: '0'
|
158
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
160
|
requirements:
|
160
161
|
- - ">="
|
@@ -162,32 +163,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
163
|
version: '0'
|
163
164
|
requirements: []
|
164
165
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.
|
166
|
+
rubygems_version: 2.4.5
|
166
167
|
signing_key:
|
167
168
|
specification_version: 4
|
168
|
-
summary: Expectation library.
|
169
|
-
test_files:
|
170
|
-
- test/helper_test.rb
|
171
|
-
- test/spectus/helper_test.rb
|
172
|
-
- test/spectus/matcher/built_in/helper_test.rb
|
173
|
-
- test/spectus/matcher/built_in/test_eql.rb
|
174
|
-
- test/spectus/matcher/built_in/test_equal.rb
|
175
|
-
- test/spectus/matcher/built_in/test_match.rb
|
176
|
-
- test/spectus/matcher/built_in/test_raise_exception.rb
|
177
|
-
- test/spectus/matcher/custom/be_prime/helper_test.rb
|
178
|
-
- test/spectus/matcher/custom/be_prime/test_be_prime.rb
|
179
|
-
- test/spectus/matcher/custom/be_the_answer/helper_test.rb
|
180
|
-
- test/spectus/matcher/custom/be_the_answer/test_be_the_answer.rb
|
181
|
-
- test/spectus/matcher/custom/helper_test.rb
|
182
|
-
- test/spectus/matcher/custom/start_with/helper_test.rb
|
183
|
-
- test/spectus/matcher/custom/start_with/test_start_with.rb
|
184
|
-
- test/spectus/matcher/helper_test.rb
|
185
|
-
- test/spectus/test_dsl.rb
|
186
|
-
- test/spectus/test_matcher.rb
|
187
|
-
- test/spectus/test_version.rb
|
188
|
-
- test/support.rb
|
189
|
-
- test/support/coverage.rb
|
190
|
-
- test/support/env.rb
|
191
|
-
- test/support/immutable.rb
|
192
|
-
- test/support/presenter.rb
|
169
|
+
summary: Expectation library with requirement levels.
|
170
|
+
test_files: []
|
193
171
|
has_rdoc:
|
metadata.gz.sig
CHANGED
Binary file
|
data/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
service_name: travis-ci
|
data/example/duck/README.md
DELETED
data/example/duck/app.rb
DELETED
data/example/duck/lib.rb
DELETED
data/example/duck/test.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby -w
|
2
|
-
|
3
|
-
require_relative 'app'
|
4
|
-
|
5
|
-
require_relative '../../lib/spectus'
|
6
|
-
|
7
|
-
extend Spectus::DSL
|
8
|
-
|
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
|
36
|
-
|
37
|
-
case (expectation_1 == true &&
|
38
|
-
expectation_2 == true &&
|
39
|
-
expectation_3 == true &&
|
40
|
-
expectation_4 == true)
|
41
|
-
when true then puts "I call that #{@bird} a duck."
|
42
|
-
else abort 'WAT?'
|
43
|
-
end
|
data/lib/spectus/dsl.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require_relative 'expectation_target'
|
2
|
-
|
3
|
-
module Spectus
|
4
|
-
|
5
|
-
# Expectation's domain-specific language.
|
6
|
-
module DSL
|
7
|
-
|
8
|
-
# Expectations are built with this method.
|
9
|
-
#
|
10
|
-
# @api public
|
11
|
-
#
|
12
|
-
# @example Duck example
|
13
|
-
# expect { 42 }.to equal: 42 # => true
|
14
|
-
#
|
15
|
-
# @return [ExpectationTarget] the expectation target.
|
16
|
-
def expect &input
|
17
|
-
ExpectationTarget.new(&input)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|