test_bench-fixture 1.3.1.1 → 1.4.0.2
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
- data/lib/test_bench/fixture/fixture.rb +25 -2
- data/lib/test_bench/fixture/session.rb +36 -31
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc001b82ac9ea1f454084cb5eae8d7d1d6a210e394da970c90ca1867aa0720da
|
4
|
+
data.tar.gz: 6e6b9d88655aac2b360a89e08325b07ea2837ec3a55acc0aa145e6700cd1d615
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e9b30ca2c58bc2a113ad378111addff10e348a76115ce467479942c37a46fecad65571e6fff52d1392fbc64bb6173cf57da6e073a52e337a04af0a4df91a2a7
|
7
|
+
data.tar.gz: 51e9b333a51d131d5419bad17105e6b3cd71e660ae35823f627748a06f21a52416db220e14954d6ed7c87ef0a9cd5fab0163eee403789c16de2de802cb6ba413
|
@@ -62,6 +62,18 @@ module TestBench
|
|
62
62
|
alias_method :session, :test_session
|
63
63
|
alias_method :session=, :test_session=
|
64
64
|
|
65
|
+
def inspect
|
66
|
+
original_test_session = test_session
|
67
|
+
|
68
|
+
self.test_session = "(not inspected; class is #{original_test_session.class})"
|
69
|
+
|
70
|
+
begin
|
71
|
+
super
|
72
|
+
ensure
|
73
|
+
self.test_session = original_test_session
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
65
77
|
def comment(text, *additional_lines)
|
66
78
|
test_session.comment(text)
|
67
79
|
|
@@ -107,8 +119,6 @@ module TestBench
|
|
107
119
|
|
108
120
|
detail "(No error was raised)"
|
109
121
|
|
110
|
-
assert(false, caller_location: caller_location)
|
111
|
-
|
112
122
|
rescue error_class => error
|
113
123
|
|
114
124
|
detail "Raised error: #{error.inspect}#{" (subclass of #{error_class})" if error.class < error_class}"
|
@@ -124,6 +134,9 @@ module TestBench
|
|
124
134
|
end
|
125
135
|
|
126
136
|
assert(result, caller_location: caller_location)
|
137
|
+
|
138
|
+
else
|
139
|
+
assert(false, caller_location: caller_location)
|
127
140
|
end
|
128
141
|
|
129
142
|
def refute_raises(error_class=nil, strict: nil, caller_location: nil, &block)
|
@@ -168,6 +181,16 @@ module TestBench
|
|
168
181
|
test_session.test(text, &block)
|
169
182
|
end
|
170
183
|
|
184
|
+
def test!(text=nil, &block)
|
185
|
+
result = test(text, &block)
|
186
|
+
|
187
|
+
unless result
|
188
|
+
raise Session::Abort.new, "Context aborted"
|
189
|
+
end
|
190
|
+
|
191
|
+
result
|
192
|
+
end
|
193
|
+
|
171
194
|
def fixture(cls, *args, **kwargs, &block)
|
172
195
|
Fixture.(cls, *args, session: test_session, **kwargs, &block)
|
173
196
|
end
|
@@ -2,22 +2,22 @@ module TestBench
|
|
2
2
|
module Fixture
|
3
3
|
class Session
|
4
4
|
Error = Class.new(RuntimeError)
|
5
|
+
Abort = Class.new(RuntimeError)
|
5
6
|
|
6
7
|
def assertion_counter
|
7
8
|
@assertion_counter ||= 0
|
8
9
|
end
|
9
10
|
attr_writer :assertion_counter
|
10
11
|
|
11
|
-
def
|
12
|
-
@
|
12
|
+
def failure_counter
|
13
|
+
@failure_counter ||= 0
|
13
14
|
end
|
14
|
-
attr_writer :
|
15
|
+
attr_writer :failure_counter
|
15
16
|
|
16
|
-
def
|
17
|
-
@
|
17
|
+
def skip_counter
|
18
|
+
@skip_counter ||= 0
|
18
19
|
end
|
19
|
-
attr_writer :
|
20
|
-
alias_method :skip?, :skip
|
20
|
+
attr_writer :skip_counter
|
21
21
|
|
22
22
|
def started
|
23
23
|
instance_variable_defined?(:@started) ?
|
@@ -36,7 +36,7 @@ module TestBench
|
|
36
36
|
alias_method :finished?, :finished
|
37
37
|
|
38
38
|
def error_policy
|
39
|
-
@error_policy ||= ErrorPolicy::
|
39
|
+
@error_policy ||= ErrorPolicy::RescueAssert.new
|
40
40
|
end
|
41
41
|
attr_writer :error_policy
|
42
42
|
|
@@ -105,14 +105,6 @@ module TestBench
|
|
105
105
|
output.detail(text)
|
106
106
|
end
|
107
107
|
|
108
|
-
def error(error)
|
109
|
-
fail!
|
110
|
-
|
111
|
-
output.error(error)
|
112
|
-
|
113
|
-
error_policy.(error)
|
114
|
-
end
|
115
|
-
|
116
108
|
def assert(value, caller_location: nil)
|
117
109
|
caller_location ||= caller[0]
|
118
110
|
|
@@ -123,8 +115,6 @@ module TestBench
|
|
123
115
|
output.assert(result, caller_location)
|
124
116
|
|
125
117
|
unless result
|
126
|
-
self.error_counter += 1
|
127
|
-
|
128
118
|
assertion_failure = AssertionFailure.build(caller_location)
|
129
119
|
raise assertion_failure
|
130
120
|
end
|
@@ -137,7 +127,8 @@ module TestBench
|
|
137
127
|
|
138
128
|
result = false
|
139
129
|
|
140
|
-
|
130
|
+
source = File.read(path)
|
131
|
+
TOPLEVEL_BINDING.eval(source, path)
|
141
132
|
|
142
133
|
result = true
|
143
134
|
|
@@ -148,19 +139,23 @@ module TestBench
|
|
148
139
|
|
149
140
|
def test(title=nil, &block)
|
150
141
|
if block.nil?
|
142
|
+
record_skip
|
151
143
|
output.skip_test(title)
|
152
144
|
return
|
153
145
|
end
|
154
146
|
|
155
147
|
output.start_test(title)
|
156
148
|
|
149
|
+
previous_failure_counter = self.failure_counter
|
157
150
|
previous_assertion_counter = self.assertion_counter
|
158
151
|
|
159
|
-
action =
|
152
|
+
action = ->{
|
160
153
|
block.()
|
161
154
|
|
162
|
-
|
163
|
-
|
155
|
+
if failure_counter == previous_failure_counter
|
156
|
+
if assertion_counter == previous_assertion_counter
|
157
|
+
raise Error, "Test did not perform an assertion"
|
158
|
+
end
|
164
159
|
end
|
165
160
|
}
|
166
161
|
|
@@ -171,6 +166,7 @@ module TestBench
|
|
171
166
|
|
172
167
|
def context(title=nil, &block)
|
173
168
|
if block.nil?
|
169
|
+
record_skip
|
174
170
|
output.skip_context(title)
|
175
171
|
return
|
176
172
|
end
|
@@ -209,18 +205,23 @@ module TestBench
|
|
209
205
|
end
|
210
206
|
|
211
207
|
def evaluate(action, &block)
|
212
|
-
|
208
|
+
previous_failure_counter = self.failure_counter
|
213
209
|
|
214
210
|
begin
|
215
211
|
action.()
|
216
212
|
|
213
|
+
rescue Abort
|
214
|
+
|
217
215
|
rescue => error
|
218
|
-
|
216
|
+
record_failure
|
217
|
+
|
218
|
+
output.error(error)
|
219
219
|
|
220
|
+
error_policy.(error)
|
220
221
|
error = nil
|
221
222
|
|
222
223
|
ensure
|
223
|
-
result =
|
224
|
+
result = failure_counter == previous_failure_counter
|
224
225
|
|
225
226
|
block.(result, error) unless block.nil?
|
226
227
|
end
|
@@ -228,17 +229,21 @@ module TestBench
|
|
228
229
|
result
|
229
230
|
end
|
230
231
|
|
231
|
-
def
|
232
|
-
self.
|
233
|
-
self.error_counter += 1
|
232
|
+
def record_failure
|
233
|
+
self.failure_counter += 1
|
234
234
|
end
|
235
|
+
alias_method :fail!, :record_failure
|
235
236
|
|
236
237
|
def failed?
|
237
|
-
|
238
|
+
failure_counter.nonzero? ? true : false
|
239
|
+
end
|
240
|
+
|
241
|
+
def record_skip
|
242
|
+
self.skip_counter += 1
|
238
243
|
end
|
239
244
|
|
240
|
-
def
|
241
|
-
|
245
|
+
def skipped?
|
246
|
+
skip_counter.nonzero? ? true : false
|
242
247
|
end
|
243
248
|
end
|
244
249
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_bench-fixture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Ladd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test_bench-bootstrap
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '0'
|
73
73
|
requirements: []
|
74
|
-
rubygems_version: 3.
|
74
|
+
rubygems_version: 3.3.4
|
75
75
|
signing_key:
|
76
76
|
specification_version: 4
|
77
77
|
summary: Test object framework for Ruby and MRuby
|