Skip to content

Commit

Permalink
added tests for checking balance and settlement history
Browse files Browse the repository at this point in the history
  • Loading branch information
mustiag committed May 4, 2017
1 parent daeb772 commit c3a8f33
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 9 deletions.
2 changes: 0 additions & 2 deletions lib/paystack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ def initialize paystack_public_key=nil, paystack_private_key=nil
unless @private_key[0..2] == 'sk_'
raise PaystackBadKeyError, "Invalid private key #{@private_key}"
end


end

#TODO delete if not used
Expand Down
4 changes: 2 additions & 2 deletions lib/paystack/objects/recipients.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def list(page=1)
end


def PaystackRecipients.create(paystackObj, data)
initPostRequest(paystackObj, "#{API::RECIPIENT_PATH}", data)
def PaystackRecipients.create(paystackObj, data={})
initPostRequest(paystackObj, "#{API::RECIPIENT_PATH}", data, true)
end

def PaystackRecipients.list(paystackObj, page=1)
Expand Down
8 changes: 4 additions & 4 deletions lib/paystack/objects/settlements.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require 'paystack/objects/base.rb'

class PaystackSettlements < PaystackBaseObject
def list(data={})
return PaystackBanks.list(@paystack, data)
def list
return PaystackSettlements.list(@paystack)
end


def PaystackSettlements.list(paystackObj, data={})
initGetRequest(paystackObj, "#{API::SETTLEMENT_PATH}",data)
def PaystackSettlements.list(paystackObj)
initGetRequest(paystackObj, "#{API::SETTLEMENT_PATH}")
end
end
2 changes: 1 addition & 1 deletion lib/paystack/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Paystack
class Paystack
VERSION = "0.1.6"
end
19 changes: 19 additions & 0 deletions spec/paystack_balance_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'spec_helper'
require 'paystack/objects/balance.rb'
require 'paystack.rb'

public_test_key = "pk_test_ea7c71f838c766922873f1dd3cc529afe13da1c0"
private_test_key = "sk_test_40e9340686e6187697f8309dbae57c002bb16dd0"

describe PaystackBalance do

it "should return paystack account balance" do
paystack = Paystack.new(public_test_key, private_test_key)
balance = PaystackBalance.new(paystack)
expect(balance.nil?).to eq false
hash = balance.get
expect(hash.nil?).to eq false
expect(hash['message']).to eq "Balances retrieved"
end

end
45 changes: 45 additions & 0 deletions spec/paystack_recipients_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require 'spec_helper'
require 'paystack/objects/recipients.rb'
require 'paystack.rb'

public_test_key = "pk_test_ea7c71f838c766922873f1dd3cc529afe13da1c0"
private_test_key = "sk_test_40e9340686e6187697f8309dbae57c002bb16dd0"

describe PaystackRecipients do
it "should return a valid recipients object" do
paystack = Paystack.new(public_test_key, private_test_key)
plans = PaystackRecipients.new(paystack)
expect(plans.nil?).to eq false
end

it "should return a list of recipients" do
paystack = Paystack.new(public_test_key, private_test_key)
plans = PaystackRecipients.new(paystack)
expect(plans.nil?).to eq false
list = plans.list(1)
puts list
expect(list.nil?).to eq false
end

it "should successfuly create a recipient" do
paystack = Paystack.new(public_test_key, private_test_key)
recipients = PaystackRecipients.new(paystack)
expect(recipients.nil?).to eq false
temp = Random.new_seed.to_s
hash=recipients.create(
:type => "nuban", #Must be nuban
:name => "#{temp[0..2]} Test Plan",
:description => "Dev Test Plan Updated",
:account_number => temp[0..9], #10 digit account number
:bank_code => "044", #monthly, yearly, quarterly, weekly etc
:currency => "NGN",

)
puts hash
expect(hash.nil?).to eq false
expect(hash['data']['id'].nil?).to eq false
#expect(hash['message']).to eq "Recipient created"
end


end
21 changes: 21 additions & 0 deletions spec/paystack_settlements_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'spec_helper'
require 'paystack/objects/settlements.rb'
require 'paystack.rb'

public_test_key = "pk_test_ea7c71f838c766922873f1dd3cc529afe13da1c0"
private_test_key = "sk_test_40e9340686e6187697f8309dbae57c002bb16dd0"

describe PaystackSettlements do

it "should return a list of settlements made" do
paystack = Paystack.new(public_test_key, private_test_key)
settlements = PaystackSettlements.new(paystack)
expect(settlements.nil?).to eq false
list = settlements.list
#puts list
expect(settlements.nil?).to eq false
end



end

0 comments on commit c3a8f33

Please sign in to comment.