Skip to content

Commit

Permalink
Update tests for new Braintree API
Browse files Browse the repository at this point in the history
These new URLs were introduced in Braintree 2.32.0:

braintree/braintree_ruby@c257502#diff-9
  • Loading branch information
gabebw committed Aug 8, 2014
1 parent f75fefd commit 4da0da4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion fake_braintree.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |s|
s.required_ruby_version = Gem::Requirement.new(">= 1.9.2")

s.add_dependency 'activesupport'
s.add_dependency 'braintree', '~> 2.5'
s.add_dependency 'braintree', '~> 2.32'
s.add_dependency 'capybara'
s.add_dependency 'sinatra'

Expand Down
5 changes: 3 additions & 2 deletions lib/fake_braintree/sinatra_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def hash_from_request_body_with_key(key)
end

# Braintree::CreditCard.find
get '/merchants/:merchant_id/payment_methods/:credit_card_token' do
get '/merchants/:merchant_id/payment_methods/credit_card/:credit_card_token' do
credit_card = FakeBraintree.registry.credit_cards[params[:credit_card_token]]
if credit_card
gzipped_response(200, credit_card.to_xml(root: 'credit_card'))
Expand All @@ -100,10 +100,11 @@ def hash_from_request_body_with_key(key)
end

# Braintree::CreditCard.update
put '/merchants/:merchant_id/payment_methods/:credit_card_token' do
put '/merchants/:merchant_id/payment_methods/credit_card/:credit_card_token' do
credit_card = FakeBraintree.registry.credit_cards[params[:credit_card_token]]
updates = hash_from_request_body_with_key('credit_card')
options = {token: params[:credit_card_token], merchant_id: params[:merchant_id]}

CreditCard.new(updates, options).update
end

Expand Down
11 changes: 0 additions & 11 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
require 'bundler'

Bundler.require

require 'rspec'
require 'fake_braintree'
require 'timecop'

def clear_braintree_log
path = File.expand_path("./tmp/braintree_log")
FileUtils.mkdir_p(File.dirname(path))
logger = Logger.new(path)
logger.level = Logger::DEBUG
Braintree::Configuration.logger = logger
end

Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each {|f| require f}

clear_braintree_log

TEST_CC_NUMBER = %w(4111 1111 1111 1111).join

RSpec.configure do |config|
Expand Down
7 changes: 7 additions & 0 deletions spec/support/braintree_logging.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
path = File.expand_path("./tmp/braintree_log")
FileUtils.mkdir_p(File.dirname(path))

logger = Logger.new(path)
logger.level = Logger::DEBUG

Braintree::Configuration.logger = logger

0 comments on commit 4da0da4

Please sign in to comment.