Permalink
Browse files

Fix custom assertions for Ruby 1.9

  • Loading branch information...
1 parent 0ae2fd6 commit 188728eccc8c67fab9e4e508a90c1b25831fdab4 Cody Fauser committed Feb 2, 2010
Showing with 6 additions and 3 deletions.
  1. +1 −0 CHANGELOG
  2. +5 −3 test/test_helper.rb
View
@@ -1,5 +1,6 @@
= ActiveMerchant CHANGELOG
+* Fix custom assertions for Ruby 1.9 [cody]
* Deprecate Money objects [cody]
* Update JCB rejex to catch all valid PANs [pjhyett]
* Remove old TransaXGateway constant [cody]
View
@@ -30,6 +30,8 @@ class SubclassGateway < SimpleTestGateway
module ActiveMerchant
module Assertions
+ AssertionClass = RUBY_VERSION > '1.9' ? MiniTest::Assertion : Test::Unit::AssertionFailedError
+
def assert_field(field, value)
clean_backtrace do
assert_equal value, @helper.fields[field]
@@ -92,10 +94,10 @@ def assert_not_valid(validateable)
private
def clean_backtrace(&block)
- yield
- rescue Test::Unit::AssertionFailedError => e
+ yield
+ rescue AssertionClass => e
path = File.expand_path(__FILE__)
- raise Test::Unit::AssertionFailedError, e.message, e.backtrace.reject { |line| File.expand_path(line) =~ /#{path}/ }
+ raise AssertionClass, e.message, e.backtrace.reject { |line| File.expand_path(line) =~ /#{path}/ }
end
end

0 comments on commit 188728e

Please sign in to comment.