Skip to content

Commit

Permalink
Move setup into an activate method.
Browse files Browse the repository at this point in the history
  • Loading branch information
r00k committed Aug 31, 2011
1 parent 54bf4ac commit 97e7b4b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

Currently in alpha. Needs complete test coverage, then more functionality can
be added.

Call FakeBraintree.activate! to make go.
16 changes: 9 additions & 7 deletions lib/fake_braintree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
require 'fake_braintree/sinatra_app'
require 'fake_braintree/version'

Braintree::Configuration.environment = :production
Braintree::Configuration.merchant_id = "xxx"
Braintree::Configuration.public_key = "xxx"
Braintree::Configuration.private_key = "xxx"

module FakeBraintree
class << self
@customers = {}
Expand All @@ -24,6 +19,15 @@ class << self
attr_accessor :customers, :subscriptions, :failures, :transaction, :decline_all_cards
end

def self.activate!
Braintree::Configuration.environment = :production
Braintree::Configuration.merchant_id = "xxx"
Braintree::Configuration.public_key = "xxx"
Braintree::Configuration.private_key = "xxx"
clear!
ShamRack.mount(FakeBraintree::SinatraApp, "www.braintreegateway.com", 443)
end

def self.clear!
self.customers = {}
self.subscriptions = {}
Expand Down Expand Up @@ -157,5 +161,3 @@ def self.generated_transaction
"gateway_rejection_reason"=>nil}
end
end

ShamRack.mount(FakeBraintree::SinatraApp, "www.braintreegateway.com", 443)
4 changes: 4 additions & 0 deletions spec/fake_braintree_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
end

describe "configuration variables" do
before do
FakeBraintree.activate!
end

it "sets the environment configuration" do
Braintree::Configuration.environment.should == :production
end
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
File.new('tmp/braintree_log', 'w').close

Braintree::Configuration.logger = Logger.new("tmp/log")
FakeBraintree.activate!

RSpec.configure do |config|
config.mock_with :mocha
Expand Down

0 comments on commit 97e7b4b

Please sign in to comment.