使用ActiveMerchant响应强制进行虚假响应

时间:2010-08-24 20:52:15

标签: ruby-on-rails ruby

有一个类似于RailsCasts ActiveMerchant tutorial的交易模型。

如何创建虚假回复?

尝试过类似下面的内容,但没有运气。

response = @success=true, @params = {"ref" => "123"}, @authorization = "54321", ...

模型/ order_transaction.rb

class OrderTransaction < ActiveRecord::Base
  belongs_to :order
  serialize :params

  def response=(response)
    self.success       = response.success?
    self.authorization = response.authorization
    self.message       = response.message
    self.params        = response.params
  rescue ActiveMerchant::ActiveMerchantError => e
    self.success       = false
    self.authorization = nil
    self.message       = e.message
    self.params        = {}
  end
end

1 个答案:

答案 0 :(得分:0)

你可以做点什么

a = OpenStruct.new
def a.success?
 true
end