pin_up 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/pin_up.gemspec CHANGED
@@ -2,16 +2,14 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: pin_up 1.0.0 ruby lib
6
5
 
7
6
  Gem::Specification.new do |s|
8
7
  s.name = "pin_up"
9
- s.version = "1.0.0"
8
+ s.version = "1.1.0"
10
9
 
11
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib"]
13
11
  s.authors = ["Daniel Nitsikopoulos"]
14
- s.date = "2015-02-27"
12
+ s.date = "2015-07-17"
15
13
  s.description = "A Ruby gem wrapper for the pin-payments (pin.net.au) API"
16
14
  s.email = "dnitza@gmail.com"
17
15
  s.extra_rdoc_files = [
@@ -19,7 +17,6 @@ Gem::Specification.new do |s|
19
17
  "README.md"
20
18
  ]
21
19
  s.files = [
22
- ".DS_Store",
23
20
  ".document",
24
21
  ".travis.yml",
25
22
  "Gemfile",
@@ -31,27 +28,36 @@ Gem::Specification.new do |s|
31
28
  "VERSION",
32
29
  "build",
33
30
  "lib/pin_up.rb",
31
+ "lib/pin_up/balance.rb",
32
+ "lib/pin_up/bank_accounts.rb",
34
33
  "lib/pin_up/base.rb",
35
34
  "lib/pin_up/card.rb",
36
35
  "lib/pin_up/charge.rb",
37
36
  "lib/pin_up/client.rb",
38
37
  "lib/pin_up/customer.rb",
39
38
  "lib/pin_up/pin_errors.rb",
39
+ "lib/pin_up/recipient.rb",
40
40
  "lib/pin_up/refund.rb",
41
41
  "lib/pin_up/retrying_client.rb",
42
+ "lib/pin_up/transfer.rb",
42
43
  "pin_up.gemspec",
44
+ "spec/balance_spec.rb",
45
+ "spec/bank_accounts_spec.rb",
43
46
  "spec/base_spec.rb",
44
47
  "spec/cards_spec.rb",
45
48
  "spec/charges_spec.rb",
46
49
  "spec/client_spec.rb",
47
50
  "spec/customers_spec.rb",
48
51
  "spec/errors_spec.rb",
52
+ "spec/recipients_spec.rb",
49
53
  "spec/refund_spec.rb",
50
- "spec/spec_helper.rb"
54
+ "spec/spec_helper.rb",
55
+ "spec/transfers_spec.rb"
51
56
  ]
52
57
  s.homepage = "http://github.com/dNitza/pin_up"
53
58
  s.licenses = ["MIT"]
54
- s.rubygems_version = "2.2.2"
59
+ s.require_paths = ["lib"]
60
+ s.rubygems_version = "2.0.14"
55
61
  s.summary = "A Ruby gem wrapper for the pin-payments API"
56
62
 
57
63
  if s.respond_to? :specification_version then
@@ -61,39 +67,36 @@ Gem::Specification.new do |s|
61
67
  s.add_runtime_dependency(%q<httparty>, [">= 0.11.0"])
62
68
  s.add_development_dependency(%q<shoulda>, ["~> 3.5"])
63
69
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
64
- s.add_development_dependency(%q<rspec>, ["~> 2.13"])
70
+ s.add_development_dependency(%q<rspec>, [">= 0"])
65
71
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
66
72
  s.add_development_dependency(%q<simplecov>, ["~> 0.7.1"])
67
73
  s.add_development_dependency(%q<webmock>, ["~> 1.12.3"])
68
74
  s.add_development_dependency(%q<vcr>, ["~> 2.5.0"])
69
- s.add_development_dependency(%q<guard-rspec>, ["~> 3.0.2"])
75
+ s.add_development_dependency(%q<guard-rspec>, [">= 0"])
70
76
  s.add_development_dependency(%q<terminal-notifier-guard>, ["~> 1.5.3"])
71
- s.add_development_dependency(%q<capybara>, ["~> 2.1.0"])
72
77
  else
73
78
  s.add_dependency(%q<httparty>, [">= 0.11.0"])
74
79
  s.add_dependency(%q<shoulda>, ["~> 3.5"])
75
80
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
76
- s.add_dependency(%q<rspec>, ["~> 2.13"])
81
+ s.add_dependency(%q<rspec>, [">= 0"])
77
82
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
78
83
  s.add_dependency(%q<simplecov>, ["~> 0.7.1"])
79
84
  s.add_dependency(%q<webmock>, ["~> 1.12.3"])
80
85
  s.add_dependency(%q<vcr>, ["~> 2.5.0"])
81
- s.add_dependency(%q<guard-rspec>, ["~> 3.0.2"])
86
+ s.add_dependency(%q<guard-rspec>, [">= 0"])
82
87
  s.add_dependency(%q<terminal-notifier-guard>, ["~> 1.5.3"])
83
- s.add_dependency(%q<capybara>, ["~> 2.1.0"])
84
88
  end
85
89
  else
86
90
  s.add_dependency(%q<httparty>, [">= 0.11.0"])
87
91
  s.add_dependency(%q<shoulda>, ["~> 3.5"])
88
92
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
89
- s.add_dependency(%q<rspec>, ["~> 2.13"])
93
+ s.add_dependency(%q<rspec>, [">= 0"])
90
94
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
91
95
  s.add_dependency(%q<simplecov>, ["~> 0.7.1"])
92
96
  s.add_dependency(%q<webmock>, ["~> 1.12.3"])
93
97
  s.add_dependency(%q<vcr>, ["~> 2.5.0"])
94
- s.add_dependency(%q<guard-rspec>, ["~> 3.0.2"])
98
+ s.add_dependency(%q<guard-rspec>, [">= 0"])
95
99
  s.add_dependency(%q<terminal-notifier-guard>, ["~> 1.5.3"])
96
- s.add_dependency(%q<capybara>, ["~> 2.1.0"])
97
100
  end
98
101
  end
99
102
 
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pin::Balance, :vcr do
4
+ before(:each) do
5
+ Pin::Base.new(ENV['PIN_SECRET'], :test)
6
+ end
7
+
8
+ it 'returns the current balance of your Pin Payments account.' do
9
+ expect(Pin::Balance.get).to include('available', 'pending')
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pin::BankAccounts, :vcr do
4
+ before(:each) do
5
+ Pin::Base.new(ENV['PIN_SECRET'], :test)
6
+ end
7
+
8
+ it 'creates a bank account token and returns its details' do
9
+ options = { name: 'Roland Robot', bsb: '123456', number: '987654321' }
10
+ expect(Pin::BankAccounts.create(options)['token']).to match(/^[a-z]{2}[_]/)
11
+ end
12
+ end
data/spec/cards_spec.rb CHANGED
@@ -7,6 +7,6 @@ RSpec.describe 'Card', :vcr, class: Pin::Card do
7
7
 
8
8
  it 'should create a card and respond with the card detail from pin' do
9
9
  options = { number: '5520000000000000', expiry_month: '12', expiry_year: '2018', cvc: '123', name: 'Roland Robot', address_line1: '123 Fake Road', address_line2: '', address_city: 'Melbourne', address_postcode: '1223', address_state: 'Vic', address_country: 'AU' }
10
- Pin::Card.create(options)['token'].should match(/^[a-z]{4}[_]/)
10
+ expect(Pin::Card.create(options)['token']).to match(/^[a-z]{4}[_]/)
11
11
  end
12
12
  end
data/spec/charges_spec.rb CHANGED
@@ -6,42 +6,42 @@ describe 'Charge', :vcr, class: Pin::Charges do
6
6
  end
7
7
 
8
8
  it 'should list charges in Pin' do
9
- Pin::Charges.all.should_not == []
9
+ expect(Pin::Charges.all).to_not eq []
10
10
  end
11
11
 
12
- it 'should show a charge given a token' do
13
- Pin::Charges.find('ch_0kdOMXP7gG0_W_Vh8qAWdA')['token'].should match(/^[a-z]{2}[_]/)
12
+ it 'should not show a charge if end_date is out of range' do
13
+ expect(Pin::Charges.search(end_date: 'Mar 25, 2011')).to eq []
14
14
  end
15
15
 
16
- it 'should show a charge given a search term' do
17
- Pin::Charges.search(query: 'mid Plan - My Focusbook', end_date: 'Mar 25, 2013').should_not == []
16
+ it 'should create a charge given details' do
17
+ options = { email: 'dNitza@gmail.com', description: 'A new charge from testing Pin gem', amount: '400', currency: 'AUD', ip_address: '127.0.0.1', customer_token: 'cus_6XnfOD5bvQ1qkaf3LqmhfQ' }
18
+ expect(Pin::Charges.create(options)['success']).to eq true
18
19
  end
19
20
 
20
- it 'should not show a charge if end_date is out of range' do
21
- Pin::Charges.search(end_date: 'Mar 25, 2011').should == []
21
+ it 'should show a charge given a token' do
22
+ expect(Pin::Charges.find('ch_YFEgBSs5qTIWggGt72jn7Q')['token']).to match(/^[a-z]{2}[_]/)
22
23
  end
23
24
 
24
- it 'should create a charge given details' do
25
- options = { email: 'dNitza@gmail.com', description: 'A new charge from testing Pin gem', amount: '400', currency: 'AUD', ip_address: '127.0.0.1', customer_token: 'cus_8ImkZdEZ6BXUA6NcJDZg_g' }
26
- Pin::Charges.create(options)['success'].should eq true
25
+ it 'should show a charge given a search term' do
26
+ expect(Pin::Charges.search(query: 'A new charge from testing Pin gem', end_date: 'Mar 25, 2016')).to_not eq []
27
27
  end
28
28
 
29
29
  it 'should return pagination if "pagination" is true' do
30
- Pin::Charges.all(3, true)[:pagination]['current'] == 3
30
+ expect(Pin::Charges.all(3, true)[:pagination]['current']).to eq 3
31
31
  end
32
32
 
33
33
  it 'should list charges on a page given a page' do
34
- Pin::Charges.all(1).should_not == []
34
+ expect(Pin::Charges.all(1)).to_not eq []
35
35
  end
36
36
 
37
37
  it 'should create a pre-auth (capture a charge)' do
38
- options = { email: 'dNitza@gmail.com', description: 'A new captured charge from testing Pin gem', amount: '400', currency: 'AUD', ip_address: '127.0.0.1', customer_token: 'cus_8ImkZdEZ6BXUA6NcJDZg_g', capture: false }
39
- Pin::Charges.create(options)['captured'].should eq false
38
+ options = { email: 'dNitza@gmail.com', description: 'A new captured charge from testing Pin gem', amount: '400', currency: 'AUD', ip_address: '127.0.0.1', customer_token: 'cus_6XnfOD5bvQ1qkaf3LqmhfQ', capture: false }
39
+ expect(Pin::Charges.create(options)['captured']).to eq false
40
40
  end
41
41
 
42
42
  it 'should capture a charge' do
43
- options = { email: 'dNitza@gmail.com', description: 'A new captured charge from testing Pin gem', amount: '400', currency: 'AUD', ip_address: '127.0.0.1', customer_token: 'cus_8ImkZdEZ6BXUA6NcJDZg_g', capture: false }
43
+ options = { email: 'dNitza@gmail.com', description: 'A new captured charge from testing Pin gem', amount: '400', currency: 'AUD', ip_address: '127.0.0.1', customer_token: 'cus_6XnfOD5bvQ1qkaf3LqmhfQ', capture: false }
44
44
  token = Pin::Charges.create(options)['token']
45
- Pin::Charges.capture(token)['success'].should eq true
45
+ expect(Pin::Charges.capture(token)['success']).to eq true
46
46
  end
47
47
  end
@@ -6,17 +6,17 @@ describe 'Customer', :vcr, class: Pin::Customer do
6
6
  end
7
7
 
8
8
  it 'should list customers' do
9
- Pin::Customer.all.should_not == []
9
+ expect(Pin::Customer.all).to_not eq []
10
10
  end
11
11
 
12
12
  it 'should go to a specific page when page paramater is passed' do
13
13
  request = Pin::Customer.all(20, true)
14
- request[:pagination]['current'].should == 20
14
+ expect(request[:pagination]['current']).to eq 20
15
15
  end
16
16
 
17
17
  it 'should list customers on a page given a page' do
18
18
  request = Pin::Customer.all(1, true)
19
- request[:response].should_not == []
19
+ expect(request[:response]).to_not eq []
20
20
  end
21
21
 
22
22
  it 'should return pagination if true is passed for pagination' do
@@ -26,38 +26,64 @@ describe 'Customer', :vcr, class: Pin::Customer do
26
26
 
27
27
  it 'should not list customers on a page given a page if there are no customers' do
28
28
  request = Pin::Customer.all(25, true)
29
- request[:response].should == []
29
+ expect(request[:response]).to eq []
30
30
  end
31
31
 
32
- it 'should show a customer given a token' do
33
- Pin::Customer.find('cus_8ImkZdEZ6BXUA6NcJDZg_g')['token'].should == 'cus_8ImkZdEZ6BXUA6NcJDZg_g'
32
+ it 'should show a customer given a token' do
33
+ expect(Pin::Customer.find('cus_6XnfOD5bvQ1qkaf3LqmhfQ')['token']).to eq 'cus_6XnfOD5bvQ1qkaf3LqmhfQ'
34
34
  end
35
35
 
36
36
  it 'should list charges to a customer given a token' do
37
- Pin::Customer.charges('cus_8ImkZdEZ6BXUA6NcJDZg_g')[0]['token'].should match(/^[a-z]{2}[_]/)
37
+ expect(Pin::Customer.charges('cus_6XnfOD5bvQ1qkaf3LqmhfQ')[0]['token']).to match(/^[a-z]{2}[_]/)
38
38
  end
39
39
 
40
40
  it 'should show pagination on a page given a token and a page' do
41
- Pin::Customer.charges('cus_8ImkZdEZ6BXUA6NcJDZg_g', 5, true)[:pagination]['current'] == 5
41
+ expect(Pin::Customer.charges('cus_6XnfOD5bvQ1qkaf3LqmhfQ', 5, true)[:pagination]['current']).to eq 5
42
42
  end
43
43
 
44
44
  it 'should list charges to a customer on a page given a token and a page' do
45
- Pin::Customer.charges('cus_8ImkZdEZ6BXUA6NcJDZg_g', 1, true)[:response][0]['token'].should match(/^[a-z]{2}[_]/)
45
+ expect(Pin::Customer.charges('cus_6XnfOD5bvQ1qkaf3LqmhfQ', 1, true)[:response][0]['token']).to match(/^[a-z]{2}[_]/)
46
46
  end
47
47
 
48
48
  it 'should create a customer given an email and card details' do
49
- Pin::Customer.create('dNitza@gmail.com', number: '5520000000000000', expiry_month: '12', expiry_year: '2016', cvc: '123', name: 'Roland Robot', address_line1: '123 fake street', address_city: 'Melbourne', address_postcode: '1234', address_state: 'Vic', address_country: 'Australia')['token'].should match(/^[a-z]{3}[_]/)
49
+ expect(Pin::Customer.create('dNitza@gmail.com', number: '5520000000000000', expiry_month: '12', expiry_year: '2016', cvc: '123', name: 'Roland Robot', address_line1: '123 fake street', address_city: 'Melbourne', address_postcode: '1234', address_state: 'Vic', address_country: 'Australia')['token']).to match(/^[a-z]{3}[_]/)
50
50
  end
51
51
 
52
52
  it 'should update a customer given a token and details to update' do
53
53
  options = { email: 'dNitza@gmail.com', card: { number: '5520000000000000', address_line1: '12345 Fake Street', expiry_month: '05', expiry_year: '2016', cvc: '123', name: 'Daniel Nitsikopoulos', address_city: 'Melbourne', address_postcode: '1234', address_state: 'VIC', address_country: 'Australia' } }
54
- Pin::Customer.update('cus_sRtAD2Am-goZoLg1K-HVpA', options)['card']['address_line1'].should == '12345 Fake Street'
54
+ expect(Pin::Customer.update('cus_6XnfOD5bvQ1qkaf3LqmhfQ', options)['card']['address_line1']).to eq '12345 Fake Street'
55
55
  end
56
56
 
57
57
  it 'should create a customer given a card token customer email' do
58
58
  options = { number: '5520000000000000', expiry_month: '12', expiry_year: '2018', cvc: '123', name: 'Roland TestRobot', address_line1: '123 Fake Road', address_line2: '', address_city: 'Melbourne', address_postcode: '1223', address_state: 'Vic', address_country: 'AU' }
59
59
  @card = Pin::Card.create(options)
60
- Pin::Customer.create('nitza98@hotmail.com', @card['token'])['token'].should match(/^[a-z]{3}[_]/)
60
+ expect(Pin::Customer.create('nitza98@hotmail.com', @card['token'])['token']).to match(/^[a-z]{3}[_]/)
61
+ end
62
+
63
+ it 'should list all cards belonging to this customer' do
64
+ token = 'cus_6XnfOD5bvQ1qkaf3LqmhfQ'
65
+ expect(Pin::Customer.cards(token).first['token']).to match(/(card)[_]([\w-]{22})/)
66
+ end
67
+
68
+ it 'should create a card given customer token and card hash' do
69
+ customer_token = 'cus_6XnfOD5bvQ1qkaf3LqmhfQ'
70
+ card = { publishable_api_key: ENV['PUBLISHABLE_SECRET'], number: '5520000000000000', expiry_month: '12', expiry_year: '2018', cvc: '123', name: 'Roland TestRobot', address_line1: '123 Fake Road', address_line2: '', address_city: 'Melbourne', address_postcode: '1223', address_state: 'Vic', address_country: 'AU' }
71
+ expect(Pin::Customer.create_card(customer_token, card)['token']).to match(/(card)[_]([\w-]{22})/)
72
+ end
73
+
74
+ it 'should create a card then add it to a customer' do
75
+ options = { number: '5520000000000000', expiry_month: '12', expiry_year: '2018', cvc: '123', name: 'Roland Robot', address_line1: '123 Fake Road', address_line2: '', address_city: 'Melbourne', address_postcode: '1223', address_state: 'Vic', address_country: 'AU' }
76
+ card_token = Pin::Card.create(options)['token']
77
+ customer_token = 'cus_6XnfOD5bvQ1qkaf3LqmhfQ'
78
+ expect(Pin::Customer.create_card(customer_token, card_token)['token']).to match(/(card)[_]([\w-]{22})/)
79
+ end
80
+
81
+ it 'should delete a card given a token' do
82
+ options = { number: '5520000000000000', expiry_month: '12', expiry_year: '2018', cvc: '123', name: 'Roland Robot', address_line1: '123 Fake Road', address_line2: '', address_city: 'Melbourne', address_postcode: '1223', address_state: 'Vic', address_country: 'AU' }
83
+ card_token = Pin::Card.create(options)['token']
84
+ customer_token = 'cus_6XnfOD5bvQ1qkaf3LqmhfQ'
85
+ Pin::Customer.create_card(customer_token, card_token)
86
+ expect(Pin::Customer.delete_card(customer_token, card_token).code).to eq 204
61
87
  end
62
88
 
63
89
  end
data/spec/errors_spec.rb CHANGED
@@ -11,7 +11,7 @@ describe 'Errors', :vcr, class: Pin::PinError do
11
11
 
12
12
  it 'should raise a 422 error when trying to update missing a param' do
13
13
  options = { email: 'dNitza@gmail.com', card: { address_line1: '12345 Fake Street', expiry_month: '05', expiry_year: '2016', cvc: '123', address_city: 'Melbourne', address_postcode: '1234', address_state: 'VIC', address_country: 'Australia' } }
14
- expect { Pin::Customer.update('cus_sRtAD2Am-goZoLg1K-HVpA', options) }.to raise_error(Pin::InvalidResource, "card_number_invalid: Card number can't be blank card_name_invalid: Card name can't be blank ")
14
+ expect { Pin::Customer.update('cus_6XnfOD5bvQ1qkaf3LqmhfQ', options) }.to raise_error(Pin::InvalidResource, "card_number_invalid: Card number can't be blank card_name_invalid: Card name can't be blank ")
15
15
  end
16
16
 
17
17
  it 'should raise a 422 error when trying to make a payment with an expired card' do
@@ -67,15 +67,22 @@ describe 'Errors', :vcr, class: Pin::PinError do
67
67
  end
68
68
 
69
69
  it 'should raise a 422 error if no 2nd argument is given' do
70
- options = { email: 'dNitza@gmail.com', description: 'A new charge from testing Pin gem', amount: '400', currency: 'AUD', ip_address: '127.0.0.1', customer_token: 'cus_8ImkZdEZ6BXUA6NcJDZg_g' }
70
+ options = { email: 'dNitza@gmail.com', description: 'A new charge from testing Pin gem', amount: '400', currency: 'AUD', ip_address: '127.0.0.1', customer_token: 'cus_6XnfOD5bvQ1qkaf3LqmhfQ' }
71
71
  @charge = Pin::Charges.create(options)
72
72
  expect { Pin::Refund.create(@charge['token']) }.to raise_error(Pin::InvalidResource, "amount_invalid: Amount can't be blank amount_invalid: Amount is not a number ")
73
73
  end
74
74
 
75
75
  xit 'should raise a 422 error if a value of < 100 is given' do
76
- options = { email: 'dNitza@gmail.com', description: 'A new charge from testing Pin gem', amount: '10', currency: 'AUD', ip_address: '127.0.0.1', customer_token: 'cus_8ImkZdEZ6BXUA6NcJDZg_g' }
76
+ options = { email: 'dNitza@gmail.com', description: 'A new charge from testing Pin gem', amount: '10', currency: 'AUD', ip_address: '127.0.0.1', customer_token: 'cus_6XnfOD5bvQ1qkaf3LqmhfQ' }
77
77
  @charge = Pin::Charges.create(options)
78
- expect { Pin::Refund.create(@charge['token'], 90) }.to raise_error(Pin::InvalidResource, 'amount_invalid: Amount must be more than 100 ($1.00 AUD) ')
78
+ expect { Pin::Refund.create(@charge['token'], 90) }.to raise_error(Pin::InvalidResource, 'amount_invalid: Amount must be more than 100 ($1.00 AUD)')
79
+ end
80
+
81
+ it 'should raise a 400 error when attempting to delete customer\'s primary card' do
82
+ customer_token = 'cus_6XnfOD5bvQ1qkaf3LqmhfQ'
83
+ cards = Pin::Customer.cards(customer_token)
84
+ primary_card_token = cards.select{|card| card['primary'] }.first['token']
85
+ expect { Pin::Customer.delete_card(customer_token, primary_card_token) }.to raise_error(Pin::InvalidResource, 'You cannot delete a customer\'s primary card token')
79
86
  end
80
87
 
81
88
  end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pin::Recipient, :vcr do
4
+ before(:each) do
5
+ Pin::Base.new(ENV['PIN_SECRET'], :test)
6
+ end
7
+
8
+ it 'should create a new recipient' do
9
+ options = { email: 'hello@example.com', name: 'Roland Robot', bank_account: { name: 'Roland Robot', bsb: '123456', number: 987654321 } }
10
+ expect(Pin::Recipient.create(options)['token']).to match(/^[a-z]{2}[_]/)
11
+ end
12
+
13
+ it 'lists out recipients' do
14
+ expect(Pin::Recipient.all).to_not eq []
15
+ end
16
+
17
+ it 'gets a recipient given a token' do
18
+ options = { email: 'hello@example.com', name: 'Roland Robot', bank_account: { name: 'Roland Robot', bsb: '123456', number: 987654321 } }
19
+ recipient = Pin::Recipient.create(options)
20
+ expect(Pin::Recipient.find(recipient['token'])['token']).to eq recipient['token']
21
+ end
22
+
23
+ it 'updates the given details of a recipient and returns its details' do
24
+ options = { email: 'hello@example.com', name: 'Roland Robot', bank_account: { name: 'Roland Robot', bsb: '123456', number: 987654321 } }
25
+ recipient = Pin::Recipient.create(options)
26
+ updated_options = { email: 'new_email@example.com' }
27
+ expect(Pin::Recipient.update(recipient['token'], updated_options)['email']).to eq 'new_email@example.com'
28
+ end
29
+
30
+ xit 'returns a list of recipients transfers' do
31
+ # disbaled until we have transfers
32
+ options = { email: 'hello@example.com', name: 'Roland Robot', bank_account: { name: 'Roland Robot', bsb: '123456', number: 987654321 } }
33
+ recipient = Pin::Recipient.create(options)
34
+ expect(Pin::Recipient.transfers(recipient['token'])).to_not eq []
35
+ end
36
+ end
data/spec/refund_spec.rb CHANGED
@@ -6,21 +6,21 @@ describe 'Refund', :vcr, class: Pin::Refund do
6
6
  end
7
7
 
8
8
  it 'should list all refunds made to a charge given a token' do
9
- Pin::Refund.find('ch_S_3tP81Q9_sDngSv27gShQ')[0]['token'].should == 'rf_O4lHrNzwXYmMmTbBq0ZLPw'
9
+ expect(Pin::Refund.find('ch_5q0DiDnHZIggDfVDqcP-jQ')[0]['token']).to match(/^[a-z]{2}[_]/)
10
10
  end
11
11
 
12
12
  it 'should return nothing if looking for a charge without a refund' do
13
- Pin::Refund.find('ch_rqPIWDK71YU46M4MAQHQKg').should == []
13
+ expect(Pin::Refund.find('ch_Dsd62Ey5Hmd3B1dDHNKYvA')).to eq []
14
14
  end
15
15
 
16
16
  it 'should return a page of refunds given a page and token' do
17
- Pin::Refund.find('ch_S_3tP81Q9_sDngSv27gShQ', 1, true)[:response].should_not == []
17
+ expect(Pin::Refund.find('ch_5q0DiDnHZIggDfVDqcP-jQ', 1, true)[:response]).to_not eq []
18
18
  end
19
19
 
20
20
  it 'should create a refund for a given amount and charge' do
21
- options = { email: 'dNitza@gmail.com', description: 'A new charge from testing Pin gem', amount: '400', currency: 'AUD', ip_address: '127.0.0.1', customer_token: 'cus_8ImkZdEZ6BXUA6NcJDZg_g' }
21
+ options = { email: 'dNitza@gmail.com', description: 'A new charge from testing Pin gem', amount: '400', currency: 'AUD', ip_address: '127.0.0.1', customer_token: 'cus_6XnfOD5bvQ1qkaf3LqmhfQ'}
22
22
  @charge = Pin::Charges.create(options)
23
- Pin::Refund.create(@charge['token'], '400')['amount'].should == 400
23
+ expect(Pin::Refund.create(@charge['token'], '400')['amount']).to eq 400
24
24
  end
25
25
 
26
26
  end
data/spec/spec_helper.rb CHANGED
@@ -4,7 +4,7 @@ SimpleCov.start
4
4
  require 'rubygems'
5
5
  require 'bundler/setup'
6
6
  require 'webmock/rspec'
7
- require 'capybara/rspec'
7
+ # require 'capybara/rspec'
8
8
  require 'vcr'
9
9
 
10
10
  require 'net/https'
@@ -18,7 +18,6 @@ require 'pin_up'
18
18
 
19
19
  RSpec.configure do |config|
20
20
  config.include WebMock::API
21
- config.treat_symbols_as_metadata_keys_with_true_values = true
22
21
  config.around(:each, :vcr) do |example|
23
22
  name = example
24
23
  .metadata[:full_description]
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pin::Transfer, :vcr do
4
+ before(:each) do
5
+ Pin::Base.new(ENV['PIN_SECRET'], :test)
6
+ end
7
+
8
+ options = { email: 'hello@example.com', name: 'Roland Robot', bank_account: { name: 'Roland Robot', bsb: '123456', number: 987654321 } }
9
+ let(:recipient){ Pin::Recipient.create(options) }
10
+
11
+ it 'creates a transfer for a recipient, given a transfer hash' do
12
+ transfer = { amount: 400, currency: 'AUD', description: 'Pay day', recipient: recipient['token'] }
13
+ expect(Pin::Transfer.create(transfer)['token']).to match(/^[a-z]{4}[_]/)
14
+ end
15
+
16
+ it 'returns a paginated list of all transfers' do
17
+ expect(Pin::Transfer.all).to_not eq []
18
+ end
19
+
20
+ it 'returns the details of a transfer' do
21
+ options = { amount: 400, currency: 'AUD', description: 'Pay day', recipient: recipient['token'] }
22
+ transfer_token = Pin::Transfer.create(options)['token']
23
+ expect(Pin::Transfer.find(transfer_token)['token']).to eq transfer_token
24
+ end
25
+
26
+ xit 'returns the line items associated with transfer' do
27
+ # disabled until an issue with recipient creation is worked out
28
+ options = { amount: 400, currency: 'AUD', description: 'Pay day', recipient: recipient['token'] }
29
+ transfer_token = Pin::Transfer.create(options)['token']
30
+ expect(Pin::Transfer.line_items(transfer_token).first).to include('type', 'object', 'token', 'amount')
31
+ end
32
+ end