有一个类似于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
答案 0 :(得分:0)
a = OpenStruct.new
def a.success?
true
end