minitest-bonus-assertions 3.0 → 3.1.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 +5 -5
- data/CHANGELOG.md +61 -0
- data/CONTRIBUTING.md +124 -0
- data/CONTRIBUTORS.md +10 -0
- data/LICENCE.md +51 -0
- data/Manifest.txt +10 -12
- data/README.md +77 -0
- data/Rakefile +66 -58
- data/SECURITY.md +30 -0
- data/lib/minitest/assertion_tests.rb +4 -4
- data/lib/minitest/bonus_assertions/version.rb +5 -0
- data/lib/minitest/bonus_assertions.rb +233 -0
- data/lib/minitest-bonus-assertions.rb +2 -229
- data/licences/dco.txt +34 -0
- data/test/minitest_config.rb +4 -8
- data/test/test_minitest-bonus-assertions.rb +176 -123
- metadata +84 -166
- data/.autotest +0 -5
- data/.document +0 -5
- data/.gemtest +0 -1
- data/.minitest.rb +0 -2
- data/.travis.yml +0 -30
- data/.workenv +0 -5
- data/Contributing.rdoc +0 -67
- data/Gemfile +0 -9
- data/History.rdoc +0 -48
- data/Licence.rdoc +0 -28
- data/README.rdoc +0 -77
- /data/{Code-of-Conduct.rdoc → CODE_OF_CONDUCT.md} +0 -0
|
@@ -1,98 +1,96 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
require 'minitest_config'
|
|
1
|
+
require "minitest_config"
|
|
4
2
|
|
|
5
3
|
describe Minitest::BonusAssertions do
|
|
6
4
|
include Minitest::AssertionTests
|
|
7
5
|
|
|
8
|
-
describe
|
|
9
|
-
it
|
|
6
|
+
describe ".assert_true" do
|
|
7
|
+
it "returns true for true" do
|
|
10
8
|
assert_expected_assertions do
|
|
11
|
-
assert_equal true, tc.assert_true(true),
|
|
9
|
+
assert_equal true, tc.assert_true(true), "returns true for true"
|
|
12
10
|
end
|
|
13
11
|
end
|
|
14
12
|
|
|
15
|
-
it
|
|
13
|
+
it "be triggered for false or nil" do
|
|
16
14
|
assert_expected_assertions 2 do
|
|
17
|
-
assert_assertion_triggered
|
|
15
|
+
assert_assertion_triggered "<true> expected but was false." do
|
|
18
16
|
tc.assert_true false
|
|
19
17
|
end
|
|
20
18
|
|
|
21
|
-
assert_assertion_triggered
|
|
19
|
+
assert_assertion_triggered "<true> expected but was nil." do
|
|
22
20
|
tc.assert_true nil
|
|
23
21
|
end
|
|
24
22
|
end
|
|
25
23
|
end
|
|
26
24
|
|
|
27
|
-
it
|
|
25
|
+
it "be triggered for things that aren't true but evaluate to true" do
|
|
28
26
|
assert_expected_assertions do
|
|
29
|
-
assert_assertion_triggered
|
|
27
|
+
assert_assertion_triggered "<true> expected but was Object." do
|
|
30
28
|
tc.assert_true Object
|
|
31
29
|
end
|
|
32
30
|
end
|
|
33
31
|
end
|
|
34
32
|
end
|
|
35
33
|
|
|
36
|
-
describe
|
|
37
|
-
it
|
|
34
|
+
describe ".assert_false" do
|
|
35
|
+
it "returns true for false" do
|
|
38
36
|
assert_expected_assertions do
|
|
39
|
-
assert_equal true, tc.assert_false(false),
|
|
37
|
+
assert_equal true, tc.assert_false(false), "returns true for false"
|
|
40
38
|
end
|
|
41
39
|
end
|
|
42
40
|
|
|
43
|
-
it
|
|
41
|
+
it "be triggered for nil" do
|
|
44
42
|
assert_expected_assertions do
|
|
45
|
-
assert_assertion_triggered
|
|
43
|
+
assert_assertion_triggered "<false> expected but was nil." do
|
|
46
44
|
tc.assert_false nil
|
|
47
45
|
end
|
|
48
46
|
end
|
|
49
47
|
end
|
|
50
48
|
|
|
51
|
-
it
|
|
49
|
+
it "be triggered for things that evaluate to true" do
|
|
52
50
|
assert_expected_assertions do
|
|
53
|
-
assert_assertion_triggered
|
|
51
|
+
assert_assertion_triggered "<false> expected but was Object." do
|
|
54
52
|
tc.assert_false Object
|
|
55
53
|
end
|
|
56
54
|
end
|
|
57
55
|
end
|
|
58
56
|
end
|
|
59
57
|
|
|
60
|
-
describe
|
|
61
|
-
it
|
|
58
|
+
describe ".assert_between" do
|
|
59
|
+
it "returns true for basic integers" do
|
|
62
60
|
assert_expected_assertions do
|
|
63
|
-
assert_equal true, tc.assert_between(1, 10, 5),
|
|
61
|
+
assert_equal true, tc.assert_between(1, 10, 5), "returns true for 1 to 10 and 5"
|
|
64
62
|
end
|
|
65
63
|
end
|
|
66
64
|
|
|
67
|
-
it
|
|
65
|
+
it "returns true for the range case" do
|
|
68
66
|
assert_expected_assertions do
|
|
69
|
-
assert_equal true, tc.assert_between(
|
|
67
|
+
assert_equal true, tc.assert_between(1..10, 5), "returns true for 1..10 with 5"
|
|
70
68
|
end
|
|
71
69
|
end
|
|
72
70
|
|
|
73
|
-
it
|
|
71
|
+
it "handle the case where the hi part is first" do
|
|
74
72
|
assert_expected_assertions do
|
|
75
|
-
assert_equal true, tc.assert_between(10, 1, 5),
|
|
73
|
+
assert_equal true, tc.assert_between(10, 1, 5), "returns true for 10 to 1, with 5"
|
|
76
74
|
end
|
|
77
75
|
end
|
|
78
76
|
|
|
79
|
-
it
|
|
77
|
+
it "returns false for values outside the bounds" do
|
|
80
78
|
assert_expected_assertions do
|
|
81
|
-
assert_assertion_triggered
|
|
79
|
+
assert_assertion_triggered "Expected 100 to be between 1 and 10." do
|
|
82
80
|
tc.assert_between(1, 10, 100)
|
|
83
81
|
end
|
|
84
82
|
end
|
|
85
83
|
end
|
|
86
84
|
|
|
87
|
-
it
|
|
85
|
+
it "returns false for values strictly on the bounds" do
|
|
88
86
|
assert_expected_assertions do
|
|
89
|
-
assert_assertion_triggered
|
|
87
|
+
assert_assertion_triggered "Expected 1 to be between 1 and 10." do
|
|
90
88
|
tc.assert_between(1, 10, 1)
|
|
91
89
|
end
|
|
92
90
|
end
|
|
93
91
|
end
|
|
94
92
|
|
|
95
|
-
it
|
|
93
|
+
it "raise error for incompatible values" do
|
|
96
94
|
assert_expected_assertions 0 do
|
|
97
95
|
assert_raises ArgumentError do
|
|
98
96
|
tc.assert_between(1, 10, Time.now)
|
|
@@ -100,254 +98,309 @@ describe Minitest::BonusAssertions do
|
|
|
100
98
|
end
|
|
101
99
|
end
|
|
102
100
|
|
|
103
|
-
it
|
|
101
|
+
it "works correctly with the new expectation format" do
|
|
104
102
|
assert_expected_assertions do
|
|
105
103
|
assert_equal true, spec._(5).must_be_between(1, 10)
|
|
106
104
|
end
|
|
107
105
|
end
|
|
108
106
|
end
|
|
109
107
|
|
|
110
|
-
describe
|
|
111
|
-
it
|
|
108
|
+
describe ".assert_has_keys" do
|
|
109
|
+
it "returns true if the keys are present" do
|
|
112
110
|
assert_expected_assertions do
|
|
113
|
-
assert_equal true, tc.assert_has_keys({
|
|
114
|
-
|
|
111
|
+
assert_equal true, tc.assert_has_keys({"a" => 1}, "a"),
|
|
112
|
+
"returns true for key 'a' in { 'a' => 1 }"
|
|
115
113
|
end
|
|
116
114
|
end
|
|
117
115
|
|
|
118
|
-
it
|
|
119
|
-
hash = {
|
|
120
|
-
keys = %w
|
|
116
|
+
it "be triggered for a missing value" do
|
|
117
|
+
hash = {"a" => 1}
|
|
118
|
+
keys = %w[a b]
|
|
121
119
|
assert_expected_assertions 2 do
|
|
122
|
-
assert_assertion_triggered %
|
|
120
|
+
assert_assertion_triggered %(Expected #{mu_pp(hash)} to include all keys #{mu_pp(keys)}.) do
|
|
123
121
|
tc.assert_has_keys(hash, keys)
|
|
124
122
|
end
|
|
125
123
|
end
|
|
126
124
|
end
|
|
127
125
|
|
|
128
|
-
it
|
|
126
|
+
it "raise error for incompatible values" do
|
|
129
127
|
assert_expected_assertions 0 do
|
|
130
128
|
assert_raises NoMethodError do
|
|
131
|
-
tc.assert_has_keys([],
|
|
129
|
+
tc.assert_has_keys([], "a")
|
|
132
130
|
end
|
|
133
131
|
end
|
|
134
132
|
end
|
|
135
133
|
end
|
|
136
134
|
|
|
137
|
-
describe
|
|
138
|
-
it
|
|
135
|
+
describe ".assert_missing_keys" do
|
|
136
|
+
it "returns true if the keys are missing" do
|
|
139
137
|
assert_expected_assertions do
|
|
140
|
-
assert_equal true, tc.assert_missing_keys({
|
|
141
|
-
|
|
138
|
+
assert_equal true, tc.assert_missing_keys({"a" => 1}, "b"),
|
|
139
|
+
"returns true for key 'b' missing from { 'a' => 1 }"
|
|
142
140
|
end
|
|
143
141
|
end
|
|
144
142
|
|
|
145
|
-
it
|
|
146
|
-
hash = {
|
|
147
|
-
keys = %w
|
|
143
|
+
it "be triggered for a present value" do
|
|
144
|
+
hash = {"a" => 1}
|
|
145
|
+
keys = %w[a b]
|
|
148
146
|
assert_expected_assertions do
|
|
149
|
-
assert_assertion_triggered %
|
|
147
|
+
assert_assertion_triggered %(Expected #{mu_pp(hash)} not to include any of these keys #{mu_pp(keys)}.) do
|
|
150
148
|
tc.assert_missing_keys(hash, keys)
|
|
151
149
|
end
|
|
152
150
|
end
|
|
153
151
|
end
|
|
154
152
|
|
|
155
|
-
it
|
|
153
|
+
it "raise error for incompatible values" do
|
|
156
154
|
assert_expected_assertions 0 do
|
|
157
155
|
assert_raises NoMethodError do
|
|
158
|
-
tc.assert_missing_keys([],
|
|
156
|
+
tc.assert_missing_keys([], "a")
|
|
159
157
|
end
|
|
160
158
|
end
|
|
161
159
|
end
|
|
162
160
|
end
|
|
163
161
|
|
|
164
|
-
describe
|
|
165
|
-
it
|
|
162
|
+
describe ".assert_raises_with_message" do
|
|
163
|
+
it "returns the matched exception if the exception and message match" do
|
|
166
164
|
assert_expected_assertions 2 do
|
|
167
|
-
res = tc.assert_raises_with_message(ArgumentError,
|
|
168
|
-
raise ArgumentError,
|
|
165
|
+
res = tc.assert_raises_with_message(ArgumentError, "Don't have a cow, man!") do
|
|
166
|
+
raise ArgumentError, "Don't have a cow, man!"
|
|
169
167
|
end
|
|
170
168
|
|
|
171
169
|
assert_kind_of ArgumentError, res
|
|
172
170
|
end
|
|
173
171
|
end
|
|
174
172
|
|
|
175
|
-
it
|
|
173
|
+
it "is triggered with a different exception" do
|
|
176
174
|
assert_expected_assertions do
|
|
177
|
-
assert_assertion_triggered %
|
|
178
|
-
tc.assert_raises_with_message(ArgumentError,
|
|
175
|
+
assert_assertion_triggered %(#{mu_pp([ArgumentError])} exception expected, not\nClass: <NoMethodError>\nMessage: <"NoMethodError">\n---Backtrace---) do
|
|
176
|
+
tc.assert_raises_with_message(ArgumentError, "Don’t have a cow, man!") do
|
|
179
177
|
raise NoMethodError
|
|
180
178
|
end
|
|
181
179
|
end
|
|
182
180
|
end
|
|
183
181
|
end
|
|
184
182
|
|
|
185
|
-
it
|
|
183
|
+
it "be triggered with a different message" do
|
|
186
184
|
assert_expected_assertions 2 do
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
185
|
+
expectation = expectation(
|
|
186
|
+
%(ArgumentError exception expected with message "Don’t have a cow, man!".),
|
|
187
|
+
%(Expected: "Don’t have a cow, man!"\n Actual: "Have a cow, man!")
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
assert_assertion_triggered expectation do
|
|
191
|
+
tc.assert_raises_with_message(ArgumentError, "Don’t have a cow, man!") do
|
|
192
|
+
raise ArgumentError, "Have a cow, man!"
|
|
190
193
|
end
|
|
191
194
|
end
|
|
192
195
|
end
|
|
193
196
|
end
|
|
194
197
|
end
|
|
195
198
|
|
|
196
|
-
describe
|
|
197
|
-
it
|
|
199
|
+
describe ".assert_set_equal" do
|
|
200
|
+
it "returns true if the sets are equal" do
|
|
198
201
|
assert_expected_assertions do
|
|
199
|
-
assert_equal true, tc.assert_set_equal(%w
|
|
200
|
-
|
|
202
|
+
assert_equal true, tc.assert_set_equal(%w[a b c], %w[c b a]),
|
|
203
|
+
"returns true for sets %w(a b c) and %w(c b a)"
|
|
201
204
|
end
|
|
202
205
|
end
|
|
203
206
|
|
|
204
|
-
it
|
|
207
|
+
it "is triggered if they are not equal" do
|
|
205
208
|
assert_expected_assertions do
|
|
206
|
-
|
|
207
|
-
|
|
209
|
+
expectation = expectation(
|
|
210
|
+
%(Expected ["c", "b"] to be set equivalent to ["a", "b", "c"].),
|
|
211
|
+
%(Expected: #<Set: {"a", "b", "c"}>\n Actual: #<Set: {"c", "b"}>)
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
assert_assertion_triggered expectation do
|
|
215
|
+
tc.assert_set_equal %w[a b c], %w[c b]
|
|
208
216
|
end
|
|
209
217
|
end
|
|
210
218
|
end
|
|
211
219
|
end
|
|
212
220
|
|
|
213
|
-
describe
|
|
214
|
-
it
|
|
221
|
+
describe ".refute_set_equal" do
|
|
222
|
+
it "returns true if the sets are not equal" do
|
|
215
223
|
assert_expected_assertions do
|
|
216
|
-
assert_equal
|
|
217
|
-
|
|
224
|
+
assert_equal true, tc.refute_set_equal(%w[a b c], %w[c b]),
|
|
225
|
+
"returns true for sets %w(a b c) and %w(c b)"
|
|
218
226
|
end
|
|
219
227
|
end
|
|
220
228
|
|
|
221
|
-
it
|
|
229
|
+
it "is triggered if they are not equal" do
|
|
230
|
+
expectation = expectation(
|
|
231
|
+
%(Expected ["c", "b", "a"] not to be set equivalent to ["a", "b", "c"].),
|
|
232
|
+
%(Expected #<Set: {"c", "b", "a"}> to not be equal to #<Set: {"a", "b", "c"}>.)
|
|
233
|
+
)
|
|
234
|
+
|
|
222
235
|
assert_expected_assertions do
|
|
223
|
-
assert_assertion_triggered
|
|
224
|
-
tc.refute_set_equal %w
|
|
236
|
+
assert_assertion_triggered expectation do
|
|
237
|
+
tc.refute_set_equal %w[a b c], %w[c b a]
|
|
225
238
|
end
|
|
226
239
|
end
|
|
227
240
|
end
|
|
228
241
|
end
|
|
229
242
|
|
|
230
|
-
describe
|
|
231
|
-
describe
|
|
232
|
-
let(:expr) {
|
|
243
|
+
describe ".assert_result_equal" do
|
|
244
|
+
describe "when expr is a string" do
|
|
245
|
+
let(:expr) { "expected" }
|
|
233
246
|
|
|
234
|
-
describe
|
|
247
|
+
describe "when expr yields nil" do
|
|
235
248
|
before do
|
|
236
249
|
tc.define_singleton_method(:expected) { nil }
|
|
237
250
|
spec.define_singleton_method(:expected) { nil }
|
|
238
251
|
end
|
|
239
252
|
|
|
240
|
-
it
|
|
253
|
+
it "returns true if the actual is nil" do
|
|
241
254
|
assert_expected_assertions do
|
|
242
|
-
assert_equal true, tc.assert_result_equal(
|
|
243
|
-
|
|
255
|
+
assert_equal true, tc.assert_result_equal("expected", nil),
|
|
256
|
+
"returns true for expr-string result nil and nil"
|
|
244
257
|
end
|
|
245
258
|
end
|
|
246
259
|
|
|
247
|
-
it
|
|
260
|
+
it "returns true if the actual is nil" do
|
|
248
261
|
assert_expected_assertions do
|
|
249
|
-
assert_equal true, tc.assert_result_equal(
|
|
250
|
-
|
|
262
|
+
assert_equal true, tc.assert_result_equal("expected", nil),
|
|
263
|
+
"returns true for expr-string result nil and nil"
|
|
251
264
|
end
|
|
252
265
|
end
|
|
253
266
|
|
|
254
|
-
it
|
|
267
|
+
it "is triggered if the actual is not nil" do
|
|
255
268
|
assert_expected_assertions do
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
269
|
+
expectation = expectation(
|
|
270
|
+
%(nil expected (expr "expected") but was 3.),
|
|
271
|
+
%(Expected 3 to be nil.)
|
|
272
|
+
)
|
|
273
|
+
assert_assertion_triggered expectation do
|
|
274
|
+
assert_equal true, tc.assert_result_equal("expected", 3),
|
|
275
|
+
"returns true for expr-string result nil and nil"
|
|
259
276
|
end
|
|
260
277
|
end
|
|
261
278
|
end
|
|
262
279
|
end
|
|
263
280
|
|
|
264
|
-
describe
|
|
281
|
+
describe "when expr yields a non-nil value" do
|
|
265
282
|
before do
|
|
266
283
|
tc.define_singleton_method(:expected) { 3 }
|
|
267
284
|
end
|
|
268
285
|
|
|
269
|
-
it
|
|
286
|
+
it "returns true if the actual is equal" do
|
|
270
287
|
assert_expected_assertions do
|
|
271
|
-
assert_equal true, tc.assert_result_equal(
|
|
272
|
-
|
|
288
|
+
assert_equal true, tc.assert_result_equal("expected", 3),
|
|
289
|
+
"returns true for expr-string result 3 and 3"
|
|
273
290
|
end
|
|
274
291
|
end
|
|
275
292
|
|
|
276
|
-
it
|
|
293
|
+
it "is triggered if the actual is nil" do
|
|
277
294
|
assert_expected_assertions do
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
295
|
+
expectation = expectation(
|
|
296
|
+
%(3 expected (expr "expected") but was nil.),
|
|
297
|
+
%(Expected: 3\n Actual: nil)
|
|
298
|
+
)
|
|
299
|
+
assert_assertion_triggered expectation do
|
|
300
|
+
assert_equal true, tc.assert_result_equal("expected", nil),
|
|
301
|
+
"returns true for expr-string result 3 and 3"
|
|
281
302
|
end
|
|
282
303
|
end
|
|
283
304
|
end
|
|
284
305
|
|
|
285
|
-
it
|
|
306
|
+
it "is triggered if the actual is not equal" do
|
|
286
307
|
assert_expected_assertions do
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
308
|
+
expectation = expectation(
|
|
309
|
+
%(3 expected (expr "expected") but was 5.),
|
|
310
|
+
%(Expected: 3\n Actual: 5)
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
assert_assertion_triggered expectation do
|
|
314
|
+
assert_equal true, tc.assert_result_equal("expected", 5),
|
|
315
|
+
"returns true for expr-string result 3 and 3"
|
|
290
316
|
end
|
|
291
317
|
end
|
|
292
318
|
end
|
|
293
319
|
end
|
|
294
320
|
end
|
|
295
321
|
|
|
296
|
-
describe
|
|
322
|
+
describe "when expr is a proc" do
|
|
297
323
|
let(:expr) { -> { expected } }
|
|
298
324
|
|
|
299
|
-
describe
|
|
325
|
+
describe "when expr yields nil" do
|
|
300
326
|
before do
|
|
301
327
|
tc.define_singleton_method(:expected) { nil }
|
|
302
328
|
end
|
|
303
329
|
|
|
304
|
-
it
|
|
330
|
+
it "returns true if the actual is nil" do
|
|
305
331
|
assert_expected_assertions do
|
|
306
|
-
assert_equal true, tc.assert_result_equal(
|
|
307
|
-
|
|
332
|
+
assert_equal true, tc.assert_result_equal("expected", nil),
|
|
333
|
+
"returns true for expr-proc result nil and nil"
|
|
308
334
|
end
|
|
309
335
|
end
|
|
310
336
|
|
|
311
|
-
it
|
|
337
|
+
it "is triggered if the actual is not nil" do
|
|
312
338
|
assert_expected_assertions do
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
339
|
+
expectation = expectation(
|
|
340
|
+
%(nil expected (expr "expected") but was 3.),
|
|
341
|
+
%(Expected 3 to be nil.)
|
|
342
|
+
)
|
|
343
|
+
|
|
344
|
+
assert_assertion_triggered expectation do
|
|
345
|
+
assert_equal true, tc.assert_result_equal("expected", 3),
|
|
346
|
+
"returns true for expr-proc result nil and nil"
|
|
316
347
|
end
|
|
317
348
|
end
|
|
318
349
|
end
|
|
319
350
|
end
|
|
320
351
|
|
|
321
|
-
describe
|
|
352
|
+
describe "when expr yields a non-nil value" do
|
|
322
353
|
before do
|
|
323
354
|
tc.define_singleton_method(:expected) { 3 }
|
|
324
355
|
end
|
|
325
356
|
|
|
326
|
-
it
|
|
357
|
+
it "returns true if the actual is equal" do
|
|
327
358
|
assert_expected_assertions do
|
|
328
|
-
assert_equal true, tc.assert_result_equal(
|
|
329
|
-
|
|
359
|
+
assert_equal true, tc.assert_result_equal("expected", 3),
|
|
360
|
+
"returns true for expr-proc result 3 and 3"
|
|
330
361
|
end
|
|
331
362
|
end
|
|
332
363
|
|
|
333
|
-
it
|
|
364
|
+
it "is triggered if the actual is nil" do
|
|
334
365
|
assert_expected_assertions do
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
366
|
+
expectation = expectation(
|
|
367
|
+
%(3 expected (expr "expected") but was nil.),
|
|
368
|
+
%(Expected: 3\n Actual: nil)
|
|
369
|
+
)
|
|
370
|
+
|
|
371
|
+
assert_assertion_triggered expectation do
|
|
372
|
+
assert_equal true, tc.assert_result_equal("expected", nil),
|
|
373
|
+
"returns true for expr-proc result 3 and 3"
|
|
338
374
|
end
|
|
339
375
|
end
|
|
340
376
|
end
|
|
341
377
|
|
|
342
|
-
it
|
|
378
|
+
it "is triggered if the actual is not equal" do
|
|
343
379
|
assert_expected_assertions do
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
380
|
+
expectation = expectation(
|
|
381
|
+
%(3 expected (expr "expected") but was 5.),
|
|
382
|
+
%(Expected: 3\n Actual: 5)
|
|
383
|
+
)
|
|
384
|
+
|
|
385
|
+
assert_assertion_triggered expectation do
|
|
386
|
+
assert_equal true, tc.assert_result_equal("expected", 5),
|
|
387
|
+
"returns true for expr-proc result 3 and 3"
|
|
347
388
|
end
|
|
348
389
|
end
|
|
349
390
|
end
|
|
350
391
|
end
|
|
351
392
|
end
|
|
352
393
|
end
|
|
394
|
+
|
|
395
|
+
def expectation(*args)
|
|
396
|
+
if RUBY_VERSION >= "4.0"
|
|
397
|
+
args.map! { |arg| arg.gsub(/#<Set: \{([^}]+)\}>/) { "Set[#{$1}]" } }
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
if Minitest::VERSION >= "6.0"
|
|
401
|
+
args.first
|
|
402
|
+
else
|
|
403
|
+
args.join("\n")
|
|
404
|
+
end
|
|
405
|
+
end
|
|
353
406
|
end
|