Skip to content

Commit

Permalink
[ruby19-compat] Updates to get tests passing in Ruby 1.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Cody Fauser committed Nov 12, 2010
1 parent 44890f7 commit 44a704f
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 30 deletions.
6 changes: 4 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
$:.unshift File.expand_path('../lib', __FILE__)

require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/gempackagetask'
require 'lib/support/gateway_support'
require 'lib/support/outbound_hosts'
require 'support/gateway_support'
require 'support/outbound_hosts'

desc "Run the unit test suite"
task :default => 'test:units'
Expand Down
2 changes: 1 addition & 1 deletion lib/active_merchant/billing/gateways/first_pay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def add_address(post, options)
end

def add_invoice(post, options)
post[:trackid] = rand(Time.now)
post[:trackid] = rand(Time.now.to_i)
end

def add_creditcard(post, creditcard)
Expand Down
2 changes: 0 additions & 2 deletions lib/active_merchant/billing/gateways/paybox_direct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ def commit(action, money = nil, parameters = nil)
:timestamp => parameters[:dateq]),
:test => test?,
:authorization => response[:numappel].to_s + response[:numtrans].to_s,
:cvv_result => '',
:avs_result => '',
:fraud_review => fraud_review?(response),
:sent_params => parameters.delete_if{|key,value| ['porteur','dateval','cvv'].include?(key.to_s)}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def transaction_id
end

def received_at
Time.local(*params['time'].scan(/../))
Time.parse("20#{params['time']}")
end

def gross
Expand Down
2 changes: 1 addition & 1 deletion lib/active_merchant/common/country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def initialize(options = {})
end

def code(format)
@codes.select{|c| c.format == format}
@codes.detect{|c| c.format == format}
end

def ==(other)
Expand Down
2 changes: 1 addition & 1 deletion lib/support/gateway_support.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rubygems'
require 'active_support'
require 'lib/active_merchant'
require 'active_merchant'


class GatewaySupport #:nodoc:
Expand Down
2 changes: 1 addition & 1 deletion test/unit/gateways/secure_net_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_supported_card_types

def test_failure_without_response_reason_text
assert_nothing_raised do
assert_equal '', @gateway.send(:message_from, '')
assert_equal '', @gateway.send(:message_from, {})
end
end

Expand Down
29 changes: 8 additions & 21 deletions test/unit/integrations/action_view_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,10 @@ def url_for(options, *parameters_for_method_reference)

def test_basic_payment_service
payment_service_for('order-1','test', :service => :bogus){}

expected = [
/^<form.*action="http:\/\/www.bogus.com".*/,
/<input id="account" name="account" type="hidden" value="test" \/>/,
/<input id="order" name="order" type="hidden" value="order-1" \/>/,
/<\/form>/
]

@output_buffer.split("\n").reject(&:blank?).each_with_index do |line, index|
assert_match expected[index], line.chomp, "Failed to match #{line}"
end
assert_match(/^<form.*action="http:\/\/www.bogus.com".*/, @output_buffer)
assert_match(/<input id="account" name="account" type="hidden" value="test" \/>/, @output_buffer)
assert_match(/<input id="order" name="order" type="hidden" value="order-1" \/>/, @output_buffer)
assert_match(/<\/form>/, @output_buffer)
end

def test_payment_service_no_block_given
Expand Down Expand Up @@ -81,16 +74,10 @@ def test_html_safety
with_routes do
get :payment_action

expected = [
/^<form.*action="http:\/\/www.bogus.com".*/,
/<input id="account" name="account" type="hidden" value="test" \/>/,
/<input id="order" name="order" type="hidden" value="order-1" \/>/,
/<\/form>/
]

@response.body.split("\n").reject(&:blank?).each_with_index do |line, index|
assert_match expected[index], line.chomp, "Failed to match #{line}"
end
assert_match(/^<form.*action="http:\/\/www.bogus.com".*/, @response.body)
assert_match(/<input id="account" name="account" type="hidden" value="test" \/>/, @response.body)
assert_match(/<input id="order" name="order" type="hidden" value="order-1" \/>/, @response.body)
assert_match(/<\/form>/, @response.body)
end
end

Expand Down

0 comments on commit 44a704f

Please sign in to comment.