spec/spec_helper.rb in blather-0.4.14 vs spec/spec_helper.rb in blather-0.4.15
- old
+ new
@@ -28,9 +28,36 @@
assert_equal(args[:by], (new_val - init_val), msg) if args[:by]
assert_equal([args[:from], args[:to]], [(init_val if args[:from]), new_val], msg) if args[:to]
refute_equal(init_val, new_val, msg) if args.empty?
end
+
+ def assert_nothing_raised(*args)
+ self._assertions += 1
+ if Module === args.last
+ msg = nil
+ else
+ msg = args.pop
+ end
+ begin
+ line = __LINE__; yield
+ rescue Exception => e
+ bt = e.backtrace
+ as = e.instance_of?(MiniTest::Assertion)
+ if as
+ ans = /\A#{Regexp.quote(__FILE__)}:#{line}:in /o
+ bt.reject! {|ln| ans =~ ln}
+ end
+ if ((args.empty? && !as) ||
+ args.any? {|a| a.instance_of?(Module) ? e.is_a?(a) : e.class == a })
+ msg = message(msg) { "Exception raised:\n<#{mu_pp(e)}>" }
+ raise MiniTest::Assertion, msg.call, bt
+ else
+ raise
+ end
+ end
+ nil
+ end
end
end
class Object
def must_change *args, &block