Skip to content

Commit

Permalink
Fix custom assertions for Ruby 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Cody Fauser committed Feb 2, 2010
1 parent 0ae2fd6 commit 188728e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
@@ -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]
Expand Down
8 changes: 5 additions & 3 deletions test/test_helper.rb
Expand Up @@ -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]
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 188728e

Please sign in to comment.