lib/fake_braintree.rb in fake_braintree-0.1.1 vs lib/fake_braintree.rb in fake_braintree-0.2.0
- old
+ new
@@ -16,16 +16,15 @@
module FakeBraintree
mattr_accessor :registry, :verify_all_cards, :decline_all_cards
def self.activate!
- self.registry = Registry.new
+ initialize_registry
self.verify_all_cards = false
-
set_configuration
clear!
- Server.new.boot
+ boot_server
end
def self.log_file_path
'tmp/log'
end
@@ -58,16 +57,18 @@
"errors" => failure["errors"],
"params" => {}}
end
def self.create_failure
- { "message" => "Do Not Honor",
+ {
+ "message" => "Do Not Honor",
"verification" => { "status" => "processor_declined",
"processor_response_text" => "Do Not Honor",
"processor_response_code" => '2000' },
"errors" => { 'errors' => [] },
- "params" => {} }
+ "params" => {}
+ }
end
def self.decline_all_cards!
self.decline_all_cards = true
end
@@ -85,11 +86,12 @@
'amount' => options[:amount],
'status' => options[:status] }
created_at = options[:created_at] || Time.now
{'status_history' => [history_item],
'subscription_id' => options[:subscription_id],
- 'created_at' => created_at }
+ 'created_at' => created_at,
+ 'amount' => options[:amount] }
end
private
def self.set_configuration
@@ -97,9 +99,16 @@
Braintree::Configuration.merchant_id = "xxx"
Braintree::Configuration.public_key = "xxx"
Braintree::Configuration.private_key = "xxx"
end
+ def self.boot_server
+ Server.new.boot
+ end
+
+ def self.initialize_registry
+ self.registry = Registry.new
+ end
end
FakeBraintree.activate!
Braintree::Configuration.logger = Logger.new(FakeBraintree.log_file_path)