assert2 0.2.0 → 0.3.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.
Files changed (3) hide show
  1. data/lib/assert2.rb +41 -3
  2. data/lib/ruby_reflector.rb +1 -1
  3. metadata +2 -2
@@ -1,7 +1,9 @@
1
+ require 'test/unit'
1
2
  require File.dirname(__FILE__) + '/ruby_reflector'
2
3
 
3
4
  # FIXME evaluate parts[3]
4
- # FIXME if the primary evaluation fails, rescue and rethrow the error and reflect anyway!
5
+ # ERGO if the block is a block, decorate with do-end
6
+ # ERGO decorate assert_latest's block at fault time
5
7
 
6
8
  module Assert_2_0
7
9
  include RubyNodeReflector
@@ -104,9 +106,45 @@ module Assert_2_0
104
106
  def assert_raise_message(types, matcher, diagnostic = nil, &block)
105
107
  args = [types].flatten + [diagnostic]
106
108
  exception = assert_raise(*args, &block)
107
- assert(diagnostic){ matcher =~ exception.message }
109
+
110
+ assert_match matcher,
111
+ exception.message,
112
+ [ diagnostic,
113
+ "incorrect #{ exception.class.name
114
+ } message raised from block:",
115
+ "\t"+reflect_source(&block).split("\n").join("\n\t")
116
+ ].compact.join("\n")
117
+
118
+ return exception
119
+ end
120
+
121
+ def deny_raise_message(types, matcher, diagnostic = nil, &block) #:nodoc:
122
+ exception = assert_raise_message(types, //, diagnostic, &block)
123
+
124
+ assert_no_match matcher,
125
+ exception.message,
126
+ [ diagnostic,
127
+ "exception #{ exception.class.name
128
+ } with this message should not raise from block:",
129
+ "\t"+reflect_source(&block).split("\n").join("\n\t")
130
+ ].compact.join("\n")
131
+
108
132
  return exception.message
109
- end # CONSIDER: deny_raise_message?
133
+ end
134
+
135
+ def assert_flunked(gripe, diagnostic = nil, &block) #:nodoc:
136
+ assert_raise_message Test::Unit::AssertionFailedError,
137
+ gripe,
138
+ diagnostic,
139
+ &block
140
+ end
141
+
142
+ def deny_flunked(gripe, diagnostic = nil, &block) #:nodoc:
143
+ deny_raise_message Test::Unit::AssertionFailedError,
144
+ gripe,
145
+ diagnostic,
146
+ &block
147
+ end # ERGO move to assert{ 2.0 }, reflect, and leave there!
110
148
 
111
149
  # This is a copy of the classic assert, so your pre�xisting
112
150
  # +assert+ calls will not change their behavior
@@ -168,7 +168,7 @@ module RubyNodeReflector
168
168
  else
169
169
  green('--> ') + bold(short_inspect(val))
170
170
  end
171
-
171
+
172
172
  lines << line unless already[line] == true
173
173
  already[line] = true
174
174
  end
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.2.0
4
+ version: 0.3.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-13 00:00:00 -08:00
12
+ date: 2008-03-08 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency