Skip to content
This repository
Browse code

Add unit tests for exception extensions

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2646 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 8103d373e698351029e6803ef59686a94a5d1207 1 parent 6273753
Nicholas Seckar authored October 16, 2005
24  activesupport/test/core_ext/exception_test.rb
... ...
@@ -0,0 +1,24 @@
  1
+require 'test/unit'
  2
+require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/exception'
  3
+
  4
+class ExceptionExtTests < Test::Unit::TestCase
  5
+  
  6
+  def get_exception(cls = RuntimeError, msg = nil, trace = nil)
  7
+    begin raise cls, msg, (trace || caller)
  8
+    rescue Object => e
  9
+      return e
  10
+    end
  11
+  end
  12
+  
  13
+  def setup
  14
+    Exception::TraceSubstitutions.clear
  15
+  end
  16
+  
  17
+  def test_clean_backtrace
  18
+    Exception::TraceSubstitutions << [/\s*hidden.*/, '']
  19
+    e = get_exception RuntimeError, 'RAWR', ['bhal.rb', 'rawh hid den stuff is not here', 'almost all']
  20
+    assert_kind_of Exception, e
  21
+    assert_equal ['bhal.rb', 'rawh hid den stuff is not here', 'almost all'], e.clean_backtrace
  22
+  end
  23
+  
  24
+end

0 notes on commit 8103d37

Please sign in to comment.
Something went wrong with that request. Please try again.