stable_match 0.1.1 → 0.2.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.
@@ -1,51 +0,0 @@
1
- module MiniTest
2
- class Unit
3
- class TestCase
4
- alias_method '__assert__' , 'assert'
5
-
6
- ## TestCase#assert
7
- #
8
- # See: https://github.com/ahoward/testing.rb/blob/08dd643239a23543409ecb5fee100181f1621794/lib/testing.rb#L82-107
9
- #
10
- # Override assert to take a few different kinds of options
11
- # Most notable argument type is a block that:
12
- # -> asserts no exceptions were raised
13
- # -> asserts the result of the block is truthy
14
- # -> returns the result of the block
15
- #
16
- def assert( *args , &block )
17
- if args.size == 1 and args.first.is_a?(Hash)
18
- options = args.first
19
- expected = getopt(:expected, options){ missing }
20
- actual = getopt(:actual, options){ missing }
21
- if expected == missing and actual == missing
22
- actual , expected , *_ = options.to_a.flatten
23
- end
24
- expected = expected.call() if expected.respond_to?(:call)
25
- actual = actual.call() if actual.respond_to?(:call)
26
- assert_equal expected , actual
27
- end
28
-
29
- if block
30
- label = "assert(#{ args.join(' ') })"
31
- result = nil
32
- raised = false
33
- result = begin
34
- block.call
35
- rescue Object => e
36
- raised = e
37
- false
38
- end
39
- __assert__ !raised , ( raised.message rescue label )
40
- __assert__ result , label
41
- result
42
- else
43
- result = args.shift
44
- label = "assert(#{ args.join(' ') })"
45
- __assert__ result , label
46
- result
47
- end
48
- end
49
- end
50
- end
51
- end