Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added default gateway to spec helper to remove duplicated gateway ini…

…tialization
  • Loading branch information...
commit 810399f2d49f922eb315f37ffb647d571ad731a9 1 parent 9b65fcb
Braintree Open Source braintreeps authored
1  spec/braintree/braintree_spec.js
View
@@ -1,5 +1,4 @@
require('../spec_helper');
-var braintree = require('../../lib/braintree');
vows.describe('Braintree').addBatch({
'version': {
9 spec/braintree/http_spec.js
View
@@ -1,18 +1,11 @@
require('../spec_helper');
-var braintree = require('../../lib/braintree');
var Config = require('../../lib/braintree/config').Config;
var Http = require('../../lib/braintree/http').Http;
vows.describe('Http').addBatch({
'UnexpectedError': {
topic: function () {
- var config = Config({
- environment: braintree.Environment.Development,
- merchantId: 'integration_merchant_id',
- publicKey: 'integration_public_key',
- privateKey: 'integration_private_key'
- });
- var http = Http(config);
+ var http = Http(Config(specHelper.defaultConfig));
http.post('/test/error', '', this.callback);
},
'returns the UnexpectedError': function (err, response) {
35 spec/braintree/transaction_spec.js
View
@@ -1,17 +1,10 @@
require('../spec_helper');
-var braintree = require('../../lib/braintree');
vows.describe('Transaction').addBatch({
'create': {
'for a minimal case': {
topic: function () {
- var gateway = braintree.connect({
- environment: braintree.Environment.Development,
- merchantId: 'integration_merchant_id',
- publicKey: 'integration_public_key',
- privateKey: 'integration_private_key'
- });
- gateway.transaction.sale({
+ specHelper.defaultGateway.transaction.sale({
amount: '5.00',
creditCard: {
number: '5105105105105100',
@@ -30,13 +23,7 @@ vows.describe('Transaction').addBatch({
'when processor declined': {
topic: function () {
- var gateway = braintree.connect({
- environment: braintree.Environment.Development,
- merchantId: 'integration_merchant_id',
- publicKey: 'integration_public_key',
- privateKey: 'integration_private_key'
- });
- gateway.transaction.sale({
+ specHelper.defaultGateway.transaction.sale({
amount: '2000.00',
creditCard: {
number: '5105105105105100',
@@ -55,13 +42,7 @@ vows.describe('Transaction').addBatch({
'with errors': {
topic: function () {
- var gateway = braintree.connect({
- environment: braintree.Environment.Development,
- merchantId: 'integration_merchant_id',
- publicKey: 'integration_public_key',
- privateKey: 'integration_private_key'
- });
- gateway.transaction.sale({
+ specHelper.defaultGateway.transaction.sale({
creditCard: {
number: '5105105105105100'
}
@@ -102,13 +83,7 @@ vows.describe('Transaction').addBatch({
'when voiding an authorized transaction': {
topic: function () {
var callback = this.callback;
- var gateway = braintree.connect({
- environment: braintree.Environment.Development,
- merchantId: 'integration_merchant_id',
- publicKey: 'integration_public_key',
- privateKey: 'integration_private_key'
- });
- gateway.transaction.sale(
+ specHelper.defaultGateway.transaction.sale(
{
amount: '5.00',
creditCard: {
@@ -117,7 +92,7 @@ vows.describe('Transaction').addBatch({
}
},
function (err, response) {
- gateway.transaction.void(response.transaction.id, callback);
+ specHelper.defaultGateway.transaction.void(response.transaction.id, callback);
}
)
},
16 spec/spec_helper.js
View
@@ -5,3 +5,19 @@ GLOBAL.assert = require('assert');
GLOBAL.inspect = function (object) {
sys.puts(sys.inspect(object));
};
+
+GLOBAL.braintree = require('./../lib/braintree');
+
+var defaultConfig = {
+ environment: braintree.Environment.Development,
+ merchantId: 'integration_merchant_id',
+ publicKey: 'integration_public_key',
+ privateKey: 'integration_private_key'
+};
+
+var defaultGateway = braintree.connect(defaultConfig);
+
+GLOBAL.specHelper = {
+ defaultConfig: defaultConfig,
+ defaultGateway: defaultGateway
+}
Please sign in to comment.
Something went wrong with that request. Please try again.