Skip to content

Commit

Permalink
Boot a rack server for the fake endpoint instead of using ShamRack
Browse files Browse the repository at this point in the history
  • Loading branch information
jferris committed Nov 8, 2011
1 parent 7c4795a commit b345058
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion fake_braintree.gemspec
Expand Up @@ -16,7 +16,7 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

s.add_dependency 'sham_rack'
s.add_dependency 'capybara'
s.add_dependency 'activesupport'
s.add_dependency 'i18n'
s.add_dependency 'sinatra'
Expand Down
10 changes: 7 additions & 3 deletions lib/fake_braintree.rb
@@ -1,6 +1,7 @@
require 'fileutils'
require 'braintree'
require 'sham_rack'
require 'capybara'
require 'capybara/server'

require 'fake_braintree/helpers'
require 'fake_braintree/customer'
Expand All @@ -23,12 +24,15 @@ class << self
end

def self.activate!
Braintree::Configuration.environment = :production
Braintree::Configuration.environment = :development
Braintree::Configuration.merchant_id = "xxx"
Braintree::Configuration.public_key = "xxx"
Braintree::Configuration.private_key = "xxx"
clear!
ShamRack.mount(FakeBraintree::SinatraApp, "www.braintreegateway.com", 443)
Capybara.server_port = 3000
server = Capybara::Server.new(FakeBraintree::SinatraApp)
server.boot
ENV['GATEWAY_PORT'] = server.port.to_s
end

def self.log_file_path
Expand Down
4 changes: 2 additions & 2 deletions spec/fake_braintree_spec.rb
Expand Up @@ -52,8 +52,8 @@
describe "configuration variables" do
subject { Braintree::Configuration }

it "sets the environment to production" do
subject.environment.should == :production
it "sets the environment to development" do
subject.environment.should == :development
end

it "sets some fake API credentials" do
Expand Down

0 comments on commit b345058

Please sign in to comment.