assert2 0.1.0 → 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.
- data/lib/assert2.rb +22 -4
- metadata +2 -2
data/lib/assert2.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/ruby_reflector'
|
2
2
|
|
3
|
+
# FIXME evaluate parts[3]
|
4
|
+
# FIXME if the primary evaluation fails, rescue and rethrow the error and reflect anyway!
|
3
5
|
|
4
6
|
module Assert_2_0
|
5
7
|
include RubyNodeReflector
|
@@ -46,9 +48,17 @@ module Assert_2_0
|
|
46
48
|
#
|
47
49
|
def assert_(diagnostic = nil, twizzler = '_', &block)
|
48
50
|
# puts reflect(&block) # activate this line and test to see all your successes!
|
49
|
-
|
50
|
-
|
51
|
-
|
51
|
+
result = nil
|
52
|
+
|
53
|
+
begin
|
54
|
+
result = block.call
|
55
|
+
rescue => e
|
56
|
+
diagnostic = [diagnostic, e.inspect, *e.backtrace].compact.join("\n\t")
|
57
|
+
_flunk_2_0("\nassert#{ twizzler }{ ", diagnostic, block, result)
|
58
|
+
end
|
59
|
+
|
60
|
+
return if result
|
61
|
+
_flunk_2_0("assert#{ twizzler }{ ", diagnostic, block, result)
|
52
62
|
end
|
53
63
|
|
54
64
|
# This assertion replaces:
|
@@ -63,7 +73,15 @@ module Assert_2_0
|
|
63
73
|
def deny(diagnostic = nil, &block)
|
64
74
|
# "None shall pass!" --the Black Knight
|
65
75
|
# puts reflect(&block) # activate this line and test to see all your denials!
|
66
|
-
result =
|
76
|
+
result = nil
|
77
|
+
|
78
|
+
begin
|
79
|
+
result = block.call
|
80
|
+
rescue => e
|
81
|
+
diagnostic = [diagnostic, e.inspect, *e.backtrace].compact.join("\n\t")
|
82
|
+
_flunk_2_0("\ndeny{ ", diagnostic, block, result)
|
83
|
+
end
|
84
|
+
|
67
85
|
return unless result
|
68
86
|
_flunk_2_0('deny{ ', diagnostic, block, result)
|
69
87
|
end # "You're a looney!" -- King Arthur
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assert2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phlip
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-02-
|
12
|
+
date: 2008-02-13 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|