balanced 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -28,3 +28,6 @@ Gemfile.lock
28
28
 
29
29
  # vcr cassettes
30
30
  spec/cassettes
31
+
32
+ # OS X
33
+ .DS_Store
@@ -5,4 +5,5 @@ Josh Deeden
5
5
  Ivan Lyutov
6
6
  Alex Sharp
7
7
  Marc Sherry
8
- Joonas Bergius
8
+ Joonas Bergius
9
+ Ben Mills
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in balanced.gemspec
4
4
 
@@ -8,12 +8,13 @@ gem "faraday_middleware"
8
8
  group :development do
9
9
  gem "yard"
10
10
  gem "ruby-debug19"
11
- gem "guard", '~> 1.1.1'
12
- gem "guard-rspec", '~> 1.0.0'
11
+ gem "guard", '~> 1.6.2'
12
+ gem "guard-rspec", '~> 2.4.1'
13
13
  end
14
14
 
15
15
  group :test do
16
- gem "rspec", '~> 2.10'
17
- gem "rake", '~> 0.9.2'
18
- gem "vcr", '~> 2.2.0'
16
+ gem 'net-http-persistent'
17
+ gem "rspec", '~> 2.13.0'
18
+ gem "rake", '~> 10.0.3'
19
+ gem "vcr", '~> 2.4.0'
19
20
  end
data/README.md CHANGED
@@ -69,3 +69,10 @@ Documentation is built using YARD - http://rubydoc.info/docs/yard
69
69
  export AMAZON_ACCESS_KEY_ID='xxx'
70
70
  export AMAZON_SECRET_ACCESS_KEY='yyy'
71
71
  ./upload_docs.rb
72
+
73
+ ### Troubleshooting
74
+
75
+ #####OpenSSL
76
+ SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
77
+
78
+ The machine's Ruby/OpenSSL environment can't find any root certificates to trust. Please refer [here](http://www.google.com/search?q=SSL+connect+returned=1+errno=0+state=SSLv3) to find the best solution for your environment.
@@ -13,8 +13,8 @@ Gem::Specification.new do |gem|
13
13
  gem.summary = %q{Sign up on https://balancedpayments.com/}
14
14
  gem.homepage = "https://balancedpayments.com"
15
15
 
16
- gem.add_dependency("faraday", '~> 0.8')
17
- gem.add_dependency("faraday_middleware", '~> 0.8.7')
16
+ gem.add_dependency("faraday", '>= 0.8.6')
17
+ gem.add_dependency("faraday_middleware", '~> 0.9.0')
18
18
 
19
19
  gem.files = `git ls-files`.split($\)
20
20
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -7,7 +7,7 @@ require "balanced_exception_middleware"
7
7
 
8
8
  module Balanced
9
9
  class Client
10
-
10
+
11
11
  DEFAULTS = {
12
12
  :scheme => 'http',
13
13
  :host => 'localhost',
@@ -17,7 +17,8 @@ module Balanced
17
17
  :connection_timeout => 30,
18
18
  :read_timeout => 30,
19
19
  :logger => nil,
20
- :ssl_verify => true
20
+ :ssl_verify => true,
21
+ :faraday_adapter => Faraday.default_adapter
21
22
  }
22
23
 
23
24
  attr_reader :conn
@@ -56,7 +57,7 @@ module Balanced
56
57
  cxn.response :handle_balanced_errors
57
58
  cxn.response :json
58
59
  # cxn.response :raise_error # raise exceptions on 40x, 50x responses
59
- cxn.adapter Faraday.default_adapter
60
+ cxn.adapter config[:faraday_adapter]
60
61
  end
61
62
  conn.path_prefix = '/'
62
63
  conn.headers['User-Agent'] = "balanced-ruby/#{Balanced::VERSION}"
@@ -23,10 +23,21 @@ module Balanced
23
23
  elsif !Balanced.is_collection(uri)
24
24
  method = :put
25
25
  end
26
- @response = Balanced.send(method, uri, self.attributes)
26
+ attributes_to_submit = self.sanitize
27
+ @response = Balanced.send(method, uri, attributes_to_submit)
27
28
  reload @response
28
29
  end
29
30
 
31
+ def sanitize
32
+ to_submit = {}
33
+ @attributes.each do |key, value|
34
+ if not value.is_a? Balanced::Resource
35
+ to_submit[key] = value
36
+ end
37
+ end
38
+ to_submit
39
+ end
40
+
30
41
  def warn_on_positional args
31
42
  msg = <<-WARNING
32
43
  Called from: #{caller[1]}
@@ -1,3 +1,3 @@
1
1
  module Balanced
2
- VERSION = '0.6.0'
2
+ VERSION = '0.7.0'
3
3
  end
@@ -1,20 +1,14 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Balanced::Account do
4
- use_vcr_cassette
3
+ describe Balanced::Account, :vcr do
5
4
  before do
6
5
  api_key = Balanced::ApiKey.new.save
7
6
  Balanced.configure api_key.secret
8
7
  @marketplace = Balanced::Marketplace.new.save
9
8
  end
10
9
 
11
- describe "Account.uri" do
12
- use_vcr_cassette
13
-
14
- context "when ApiKey is not configured" do
15
-
16
- use_vcr_cassette
17
-
10
+ describe "Account.uri", :vcr do
11
+ context "when ApiKey is not configured", :vcr do
18
12
  before do
19
13
  Balanced::Marketplace.stub(:marketplace_uri) { nil }
20
14
  Balanced.configure nil
@@ -27,8 +21,7 @@ describe Balanced::Account do
27
21
  end
28
22
  end
29
23
 
30
- context "when ApiKey is configured" do
31
- use_vcr_cassette
24
+ context "when ApiKey is configured", :vcr do
32
25
  before do
33
26
  api_key = Balanced::ApiKey.new.save
34
27
  Balanced.configure api_key.secret
@@ -43,9 +36,7 @@ describe Balanced::Account do
43
36
  end
44
37
  end
45
38
 
46
- describe "merchant" do
47
- use_vcr_cassette
48
-
39
+ describe "merchant", :vcr do
49
40
  before do
50
41
  @merchant_attributes = {
51
42
  :type => "person",
@@ -87,8 +78,7 @@ describe Balanced::Account do
87
78
 
88
79
  end
89
80
 
90
- describe "#credit" do
91
- use_vcr_cassette
81
+ describe "#credit", :vcr do
92
82
  before do
93
83
  @buyer.debit :amount => 1250
94
84
  end
@@ -181,8 +171,7 @@ describe Balanced::Account do
181
171
  end
182
172
  end
183
173
 
184
- describe "#add_bank_account" do
185
- use_vcr_cassette
174
+ describe "#add_bank_account", :vcr do
186
175
  before do
187
176
  @new_bank_account = @marketplace.create_bank_account(
188
177
  :account_number => "1234567890",
@@ -195,8 +184,7 @@ describe Balanced::Account do
195
184
  it { -> { @merchant.add_bank_account(@new_bank_account.uri) }.should_not raise_error }
196
185
  end
197
186
 
198
- describe "after executing" do
199
- use_vcr_cassette
187
+ describe "after executing", :vcr do
200
188
  before do
201
189
  @merchant.add_bank_account(@new_bank_account.uri)
202
190
  @bank_accounts = Balanced::BankAccount.find(@merchant.bank_accounts_uri).items
@@ -210,8 +198,7 @@ describe Balanced::Account do
210
198
 
211
199
  describe "buyer" do
212
200
  describe "#save" do
213
- describe "when creating" do
214
- use_vcr_cassette :record => :new_episodes
201
+ describe "when creating", :vcr => { :record => :new_episodes } do
215
202
  before do
216
203
  card = Balanced::Card.new(
217
204
  :card_number => "5105105105105100",
@@ -229,8 +216,7 @@ describe Balanced::Account do
229
216
  end
230
217
 
231
218
  describe "after #save" do
232
- describe "attributes" do
233
- use_vcr_cassette :record => :new_episodes
219
+ describe "attributes", :vcr => { :record => :new_episodes } do
234
220
  before do
235
221
  card = Balanced::Card.new(
236
222
  :card_number => "4111111111111111",
@@ -316,9 +302,7 @@ describe Balanced::Account do
316
302
  end
317
303
 
318
304
  describe "#add_card" do
319
-
320
- describe "when executing" do
321
- use_vcr_cassette
305
+ describe "when executing", :vcr do
322
306
  before do
323
307
  card = Balanced::Card.new(
324
308
  :card_number => "4111111111111111",
@@ -341,9 +325,7 @@ describe Balanced::Account do
341
325
  -> { @buyer.add_card(@new_card.uri) }.should_not raise_error
342
326
  end
343
327
  end
344
- describe "after executing" do
345
- use_vcr_cassette
346
-
328
+ describe "after executing", :vcr do
347
329
  before do
348
330
  card = Balanced::Card.new(
349
331
  :card_number => "4111111111111111",
@@ -370,11 +352,8 @@ describe Balanced::Account do
370
352
  end
371
353
 
372
354
  describe "#promote_to_merchant" do
373
-
374
- describe "when executing" do
375
- use_vcr_cassette
355
+ describe "when executing", :vcr do
376
356
  before do
377
-
378
357
  @merchant_attributes = {
379
358
  :type => "person",
380
359
  :name => "Billy Jones",
@@ -401,9 +380,7 @@ describe Balanced::Account do
401
380
  -> { @buyer.promote_to_merchant @merchant_attributes}.should_not raise_error
402
381
  end
403
382
  end
404
- describe "after executing" do
405
- use_vcr_cassette
406
-
383
+ describe "after executing", :vcr do
407
384
  before do
408
385
  @merchant_attributes = {
409
386
  :type => "person",
@@ -433,8 +410,7 @@ describe Balanced::Account do
433
410
 
434
411
  end
435
412
 
436
- describe "#debit" do
437
- use_vcr_cassette :match_requests_on => [:body], :record => :new_episodes
413
+ describe "#debit", :vcr => { :match_requests_on => [:body], :record => :new_episodes } do
438
414
  before do
439
415
  card = Balanced::Card.new(
440
416
  :card_number => "4111111111111111",
@@ -502,9 +478,7 @@ describe Balanced::Account do
502
478
  end
503
479
  end
504
480
 
505
- describe ".find" do
506
- use_vcr_cassette
507
-
481
+ describe ".find", :vcr do
508
482
  before do
509
483
  api_key = Balanced::ApiKey.new.save
510
484
  Balanced.configure api_key.secret
@@ -520,8 +494,7 @@ describe Balanced::Account do
520
494
  )
521
495
  end
522
496
 
523
- context "(:all, :some_field => 'op')" do
524
- use_vcr_cassette
497
+ context "(:all, :some_field => 'op')", :vcr do
525
498
  it "should find the account by returning a page with items of one" do
526
499
  response = Balanced::Account.find(:all, :email_address => "john.doe@example.com")
527
500
  response.should be_instance_of Array
@@ -529,19 +502,15 @@ describe Balanced::Account do
529
502
  end
530
503
  end
531
504
 
532
- context "(:first, :some_field => 'op')" do
533
- use_vcr_cassette
505
+ context "(:first, :some_field => 'op')", :vcr do
534
506
  it "should find the account by returning the first item" do
535
507
  response = Balanced::Account.find(:first, :email_address => "john.doe@example.com")
536
508
  response.should be_instance_of Balanced::Account
537
509
  end
538
510
  end
539
-
540
-
541
511
  end
542
512
 
543
- describe ".find_by_email" do
544
- use_vcr_cassette :record => :new_episodes
513
+ describe ".find_by_email", :vcr => { :record => :new_episodes } do
545
514
  before do
546
515
  api_key = Balanced::ApiKey.new.save
547
516
  Balanced.configure api_key.secret
@@ -557,15 +526,13 @@ describe Balanced::Account do
557
526
  )
558
527
  end
559
528
 
560
- context "email address is in system" do
561
- use_vcr_cassette :record => :new_episodes
529
+ context "email address is in system", :vcr => { :record => :new_episodes } do
562
530
  it "should return account object" do
563
531
  Balanced::Account.find_by_email("john.doe@example.com").should be_instance_of Balanced::Account
564
532
  end
565
533
  end
566
534
 
567
- context "email address does not exist" do
568
- use_vcr_cassette :record => :new_episodes
535
+ context "email address does not exist", :vcr => { :record => :new_episodes } do
569
536
  it "should return nil" do
570
537
  Balanced::Account.find_by_email("foo@bar.com").should be_nil
571
538
  end
@@ -1,8 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Balanced::ApiKey do
4
- describe "attributes" do
5
- use_vcr_cassette
4
+ describe "attributes", :vcr do
6
5
  before do
7
6
  @key = Balanced::ApiKey.new.save
8
7
  end
@@ -19,32 +18,26 @@ describe Balanced::ApiKey do
19
18
  end
20
19
  end
21
20
 
22
- describe "new key" do
23
- use_vcr_cassette
24
-
25
- describe "before configure" do
26
- use_vcr_cassette
21
+ describe "new key", :vcr do
22
+ describe "before configure", :vcr do
27
23
  before do
28
24
  @new_key = Balanced::ApiKey.new.save
29
25
  end
30
- describe "#merchant" do
31
- use_vcr_cassette
26
+ describe "#merchant", :vcr do
32
27
  subject { @new_key.merchant }
33
28
  it { should_not be_nil }
34
29
  it { should be_instance_of Balanced::Merchant }
35
30
  end
36
31
  end
37
32
 
38
- describe "after configure" do
39
- use_vcr_cassette
33
+ describe "after configure", :vcr do
40
34
  before do
41
35
  @new_key = Balanced::ApiKey.new.save
42
36
  Balanced.configure @new_key.secret
43
37
  @new_key = Balanced::ApiKey.new.save
44
38
  end
45
39
 
46
- describe "#merchant" do
47
- use_vcr_cassette
40
+ describe "#merchant", :vcr do
48
41
  subject { @new_key.merchant }
49
42
  it { should_not be_nil }
50
43
  it { should be_instance_of Balanced::Merchant }
@@ -1,8 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Balanced::BankAccount do
4
- use_vcr_cassette
5
-
3
+ describe Balanced::BankAccount, :vcr do
6
4
  before do
7
5
  api_key = Balanced::ApiKey.new.save
8
6
  Balanced.configure api_key.secret
@@ -27,9 +25,7 @@ describe Balanced::BankAccount do
27
25
  }
28
26
  end
29
27
 
30
- describe 'when exception is thrown' do
31
- use_vcr_cassette
32
-
28
+ describe 'when exception is thrown', :vcr do
33
29
  it 'should not create without a type field' do
34
30
  lambda { Balanced::BankAccount.new(
35
31
  :account_number => "0987654321",
@@ -39,9 +35,7 @@ describe Balanced::BankAccount do
39
35
  end
40
36
  end
41
37
 
42
- describe 'create' do
43
- use_vcr_cassette
44
-
38
+ describe 'create', :vcr do
45
39
  before do
46
40
  @bank_account = @marketplace.create_bank_account(
47
41
  :account_number => "0987654321",
@@ -64,8 +58,7 @@ describe Balanced::BankAccount do
64
58
  end
65
59
  end
66
60
 
67
- context 'with an account' do
68
- use_vcr_cassette
61
+ context 'with an account', :vcr do
69
62
  before do
70
63
  @account = @marketplace.create_account
71
64
  bank_account = @marketplace.create_bank_account(
@@ -85,21 +78,35 @@ describe Balanced::BankAccount do
85
78
 
86
79
  end
87
80
 
88
- describe 'account_number' do
89
- use_vcr_cassette
81
+ describe 'account_number', :vcr do
90
82
  subject { @bank_account.account_number }
91
83
  it { should end_with '4321' }
92
84
  end
93
85
 
94
- describe 'fingerprint' do
95
- use_vcr_cassette
86
+ describe 'fingerprint', :vcr do
96
87
  subject { @bank_account.fingerprint }
97
88
  it { should have_at_least(20).characters }
98
89
  end
99
90
 
100
- describe 'credit' do
101
- use_vcr_cassette
91
+ describe 'does not invalidate on save', :vcr do
92
+ before do
93
+ @bank_account = @marketplace.create_bank_account(
94
+ :account_number => "0987654321",
95
+ :bank_code => "321174851",
96
+ :name => "Timmy T. McTimmerson",
97
+ :type => "checking"
98
+ )
99
+ @account = @marketplace.create_account
100
+ @account.add_bank_account(@bank_account.uri)
101
+ @bank_account = @account.bank_accounts[0]
102
+ @bank_account.save
103
+ end
104
+
105
+ subject { @bank_account.is_valid }
106
+ it { should be_true }
107
+ end
102
108
 
109
+ describe 'credit', :vcr do
103
110
  before do
104
111
  @credit = @bank_account.credit(
105
112
  :amount => 50,
@@ -111,12 +118,9 @@ describe Balanced::BankAccount do
111
118
  subject { @credit.bank_account }
112
119
  its(:account_number) { should end_with '4321' }
113
120
  its(:routing_number) { should eql '321174851' }
114
-
115
121
  end
116
122
 
117
- describe 'with an account' do
118
- use_vcr_cassette
119
-
123
+ describe 'with an account', :vcr do
120
124
  before do
121
125
  @account = @marketplace.create_account
122
126
  bank_account = @marketplace.create_bank_account(
@@ -137,16 +141,12 @@ describe Balanced::BankAccount do
137
141
  it { should respond_to :account }
138
142
  it { should be_instance_of Balanced::Credit }
139
143
  end
140
-
141
144
  end
142
-
143
145
  end
144
146
 
145
147
  describe 'verification' do
146
148
 
147
- describe 'cannot debit when unverified' do
148
- use_vcr_cassette
149
-
149
+ describe 'cannot debit when unverified', :vcr do
150
150
  before do
151
151
  @bank_account = @marketplace.create_bank_account(
152
152
  :account_number => "0987654321",
@@ -165,9 +165,7 @@ describe Balanced::BankAccount do
165
165
  end
166
166
  end
167
167
 
168
- describe 'debits when verified' do
169
- use_vcr_cassette
170
-
168
+ describe 'debits when verified', :vcr do
171
169
  before do
172
170
  @bank_account = @marketplace.create_bank_account(
173
171
  :account_number => "0987654321",
@@ -188,9 +186,7 @@ describe Balanced::BankAccount do
188
186
  end
189
187
  end
190
188
 
191
- describe 'errors when incorrectly verified' do
192
- use_vcr_cassette
193
-
189
+ describe 'errors when incorrectly verified', :vcr do
194
190
  before do
195
191
  @bank_account = @marketplace.create_bank_account(
196
192
  :account_number => "0987654321",
@@ -1,19 +1,14 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Balanced::Callback do
4
- use_vcr_cassette
5
-
3
+ describe Balanced::Callback, :vcr do
6
4
  before do
7
5
  api_key = Balanced::ApiKey.new.save
8
6
  Balanced.configure api_key.secret
9
7
 
10
8
  @marketplace = Balanced::Marketplace.new.save
11
-
12
9
  end
13
10
 
14
- describe "create" do
15
- use_vcr_cassette
16
-
11
+ describe "create", :vcr do
17
12
  before do
18
13
  @callback = @marketplace.create_callback(
19
14
  :url => "http://www.example.com/balanced_callback"
@@ -21,17 +16,13 @@ describe Balanced::Callback do
21
16
  end
22
17
 
23
18
  context 'check url' do
24
-
25
19
  subject { @callback.url}
26
20
  it { should eql "http://www.example.com/balanced_callback" }
27
-
28
21
  end
29
22
 
30
23
  end
31
24
 
32
- describe "delete" do
33
- use_vcr_cassette
34
-
25
+ describe "delete", :vcr do
35
26
  before do
36
27
  @callback = @marketplace.create_callback(
37
28
  :url => "http://www.example.com/balanced_callback"
@@ -40,13 +31,8 @@ describe Balanced::Callback do
40
31
 
41
32
  context 'delete' do
42
33
  it "should delete without an error" do
43
-
44
34
  @callback.destroy
45
-
46
35
  end
47
-
48
36
  end
49
-
50
37
  end
51
-
52
38
  end
@@ -1,9 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Balanced::Credit do
4
-
5
- use_vcr_cassette
6
-
3
+ describe Balanced::Credit, :vcr do
7
4
  before do
8
5
  api_key = Balanced::ApiKey.new.save
9
6
  Balanced.configure api_key.secret
@@ -22,9 +19,7 @@ describe Balanced::Credit do
22
19
  @buyer.debit :amount => 10000000
23
20
  end
24
21
 
25
- describe "#create" do
26
- use_vcr_cassette
27
-
22
+ describe "#create", :vcr do
28
23
  before do
29
24
  @credit = Balanced::Credit.new(
30
25
  :amount => 5000,
@@ -38,23 +33,19 @@ describe Balanced::Credit do
38
33
  ).save
39
34
  end
40
35
 
41
- describe 'amount' do
42
- use_vcr_cassette
36
+ describe 'amount', :vcr do
43
37
  subject { @credit.amount }
44
38
  it { should == 5000 }
45
39
  end
46
40
 
47
- describe 'account' do
48
- use_vcr_cassette
41
+ describe 'account', :vcr do
49
42
  subject { @credit.account }
50
43
  it { should be_nil }
51
44
  end
52
45
 
53
- describe 'bank_account' do
54
- use_vcr_cassette
46
+ describe 'bank_account', :vcr do
55
47
  subject { @credit.bank_account }
56
48
  its(:account_number) { should end_with '4321' }
57
49
  end
58
-
59
50
  end
60
51
  end
@@ -1,7 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Balanced::Hold do
4
- use_vcr_cassette
3
+ describe Balanced::Hold, :vcr do
5
4
  before do
6
5
  api_key = Balanced::ApiKey.new.save
7
6
  Balanced.configure api_key.secret
@@ -17,29 +16,24 @@ describe Balanced::Hold do
17
16
  )
18
17
  end
19
18
 
20
- describe "#void" do
21
- use_vcr_cassette
22
-
19
+ describe "#void", :vcr do
23
20
  before do
24
21
  @hold = @buyer.hold :amount => 100
25
22
  end
26
23
 
27
- describe 'before' do
28
- use_vcr_cassette
24
+ describe 'before', :vcr do
29
25
  subject { @hold.is_void }
30
26
  it { should be_false }
31
27
  end
32
28
 
33
- describe 'after' do
34
- use_vcr_cassette
29
+ describe 'after', :vcr do
35
30
  before { @hold.void }
36
31
 
37
32
  subject { @hold.is_void }
38
33
  it { should be_true }
39
34
  end
40
35
 
41
- describe 'when exception is thrown' do
42
- use_vcr_cassette
36
+ describe 'when exception is thrown', :vcr do
43
37
  before do
44
38
  @hold = @buyer.hold :amount => 150
45
39
  @debit = @hold.capture
@@ -49,8 +43,6 @@ describe Balanced::Hold do
49
43
  lambda { @hold.void }.should raise_error(Balanced::Conflict)
50
44
  @hold.is_void.should be_false
51
45
  end
52
-
53
46
  end
54
-
55
47
  end
56
48
  end
@@ -1,9 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
 
4
- describe Balanced::Marketplace do
5
- use_vcr_cassette
6
-
4
+ describe Balanced::Marketplace, :vcr do
7
5
  before do
8
6
  api_key = Balanced::ApiKey.new.save
9
7
  Balanced.configure api_key.secret
@@ -29,9 +27,7 @@ describe Balanced::Marketplace do
29
27
  )
30
28
  end
31
29
 
32
- describe "create_bank_account" do
33
- use_vcr_cassette
34
-
30
+ describe "create_bank_account", :vcr do
35
31
  it "can create a bank account using the option hash" do
36
32
  bank_account = @marketplace.create_bank_account(
37
33
  :name => "Jon Q.",
@@ -44,9 +40,7 @@ describe Balanced::Marketplace do
44
40
 
45
41
  end
46
42
 
47
- describe "create_account" do
48
- use_vcr_cassette :new_episodes
49
-
43
+ describe "create_account", :vcr => { :cassette_name => :new_episodes } do
50
44
  before do
51
45
  @account = @marketplace.create_account
52
46
  @account_with_attributes = @marketplace.create_account(
@@ -69,9 +63,7 @@ describe Balanced::Marketplace do
69
63
 
70
64
  end
71
65
 
72
- describe "create_card" do
73
- use_vcr_cassette
74
-
66
+ describe "create_card", :vcr do
75
67
  it "can create a card" do
76
68
  card = @marketplace.create_card(
77
69
  :card_number => "4111111111111111",
@@ -83,9 +75,7 @@ describe Balanced::Marketplace do
83
75
  end
84
76
  end
85
77
 
86
- describe "create_merchant" do
87
- use_vcr_cassette
88
-
78
+ describe "create_merchant", :vcr do
89
79
  describe "class" do
90
80
  subject { @merchant }
91
81
  it { should be_instance_of Balanced::Account }
@@ -151,9 +141,7 @@ describe Balanced::Marketplace do
151
141
  end
152
142
 
153
143
  describe Balanced::Marketplace, '.marketplace_uri' do
154
- context 'when invoking .my_marketplace' do
155
- use_vcr_cassette
156
-
144
+ context 'when invoking .my_marketplace', :vcr do
157
145
  it 'sets the marketplace_id after the first call implicitly' do
158
146
 
159
147
  Balanced.configure nil
@@ -179,9 +167,7 @@ describe Balanced::Marketplace, '.marketplace_uri' do
179
167
  end
180
168
  end
181
169
 
182
- context 'when creating a Balanced::Marketplace resource' do
183
- use_vcr_cassette
184
-
170
+ context 'when creating a Balanced::Marketplace resource', :vcr do
185
171
  it 'sets the marketplace_uri' do
186
172
  api_key = Balanced::ApiKey.new.save
187
173
  Balanced.configure api_key.secret
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Balanced::Resource, '.uri' do
4
- use_vcr_cassette
5
-
3
+ describe Balanced::Resource, '.uri', :vcr do
6
4
  describe "before the marketplace is configured" do
7
5
  it 'raises an exception' do
8
6
  Balanced::Marketplace.stub(:marketplace_uri) { nil }
@@ -20,9 +18,7 @@ describe Balanced::Resource, '.uri' do
20
18
  end
21
19
  end
22
20
 
23
- describe Balanced::Resource, 'loading a resource and generating methods from the response body' do
24
- use_vcr_cassette
25
-
21
+ describe Balanced::Resource, 'loading a resource and generating methods from the response body', :vcr do
26
22
  before do
27
23
  make_marketplace
28
24
  @account = Balanced::Account.new(email: 'user@example.com', name: 'John Doe').save
@@ -1,9 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Balanced::Transaction do
4
-
5
- use_vcr_cassette
6
-
3
+ describe Balanced::Transaction, :vcr do
7
4
  before do
8
5
  api_key = Balanced::ApiKey.new.save
9
6
  Balanced.configure api_key.secret
@@ -47,16 +44,12 @@ describe Balanced::Transaction do
47
44
 
48
45
  end
49
46
 
50
- describe "Transaction" do
51
- use_vcr_cassette
52
-
47
+ describe "Transaction", :vcr do
53
48
  it "#all" do
54
49
  Balanced::Transaction.all.length.should eql(15)
55
50
  end
56
51
 
57
- describe "#paginate" do
58
- use_vcr_cassette
59
-
52
+ describe "#paginate", :vcr do
60
53
  it "#total" do
61
54
  Balanced::Transaction.paginate.total.should eql(15)
62
55
  end
@@ -68,8 +61,6 @@ describe Balanced::Transaction do
68
61
  end
69
62
  counter.should eql(15)
70
63
  end
71
-
72
64
  end
73
-
74
65
  end
75
66
  end
@@ -1,8 +1,20 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Balanced do
4
- describe "configure" do
5
- use_vcr_cassette
4
+ describe 'configuring the faraday http adapter' do
5
+ it 'sets it to net http when nothing is passed in' do
6
+ client = Balanced.configure 'secret'
7
+ client.conn.builder.handlers.should include Faraday::Adapter::NetHttp
8
+ end
9
+
10
+ it 'allows the user to set it' do
11
+ client = Balanced.configure 'secret', :faraday_adapter => :net_http_persistent
12
+ client.conn.builder.handlers.should include Faraday::Adapter::NetHttpPersistent
13
+ client.conn.builder.handlers.should_not include Faraday::Adapter::NetHttp
14
+ end
15
+ end
16
+
17
+ describe "configure", :vcr do
6
18
  before do
7
19
  @api_key = Balanced::ApiKey.new.save
8
20
 
@@ -37,16 +49,14 @@ describe Balanced do
37
49
  end
38
50
  end
39
51
 
40
- describe "reconfigure with new api key" do
41
- use_vcr_cassette
52
+ describe "reconfigure with new api key", :vcr do
42
53
  before do
43
54
  @new_api_key = Balanced::ApiKey.new.save
44
55
  Balanced.configure @new_api_key.secret
45
56
  end
46
57
 
47
58
  describe "api key" do
48
- describe "merchant" do
49
- use_vcr_cassette
59
+ describe "merchant", :vcr do
50
60
  subject { @api_key.merchant }
51
61
  it { should_not be_nil }
52
62
  end
@@ -66,9 +76,7 @@ describe Balanced do
66
76
  it { should_not be_nil }
67
77
 
68
78
  end
69
- describe "merchant" do
70
- use_vcr_cassette
71
-
79
+ describe "merchant", :vcr do
72
80
  subject { @new_api_key.merchant }
73
81
  it { should_not be_nil }
74
82
  end
@@ -1,12 +1,10 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe "balanced client" do
4
-
5
4
  it "should allow setting and reading of the api_key" do
6
5
  client = Balanced::Client.new "miscreant"
7
6
  client.api_key.should eq("miscreant")
8
7
  client.api_key = "foo"
9
8
  client.api_key.should eq("foo")
10
9
  end
11
-
12
10
  end
@@ -13,6 +13,7 @@ end
13
13
  VCR.configure do |c|
14
14
  c.cassette_library_dir = 'spec/cassettes'
15
15
  c.hook_into :faraday
16
+ c.configure_rspec_metadata!
16
17
  end
17
18
 
18
19
  # TODO: better way to do this?
@@ -27,8 +28,8 @@ if !host.nil? then
27
28
  end
28
29
 
29
30
  RSpec.configure do |c|
30
- c.extend VCR::RSpec::Macros
31
-
31
+ c.treat_symbols_as_metadata_keys_with_true_values = true
32
+
32
33
  # @return [Balanced::Marketplace]
33
34
  def make_marketplace
34
35
  api_key = Balanced::ApiKey.new.save
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: balanced
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,24 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-23 00:00:00.000000000 Z
12
+ date: 2013-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: '0.8'
21
+ version: 0.8.6
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: '0.8'
29
+ version: 0.8.6
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: faraday_middleware
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 0.8.7
37
+ version: 0.9.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,12 +42,13 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 0.8.7
45
+ version: 0.9.0
46
46
  description: ! "Balanced is the payments platform for marketplaces.\n Integrate
47
47
  a payments experience just like Amazon for your marketplace.\n Forget about dealing
48
48
  with banking systems, compliance, fraud, and security.\n "
49
49
  email:
50
- - mahmoud@poundpay.com
50
+ - !binary |-
51
+ bWFobW91ZEBwb3VuZHBheS5jb20=
51
52
  executables: []
52
53
  extensions: []
53
54
  extra_rdoc_files: []
@@ -136,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
137
  version: '0'
137
138
  requirements: []
138
139
  rubyforge_project:
139
- rubygems_version: 1.8.23
140
+ rubygems_version: 1.8.24
140
141
  signing_key:
141
142
  specification_version: 3
142
143
  summary: Sign up on https://balancedpayments.com/