-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathpaystack_customers_spec.rb
More file actions
60 lines (52 loc) · 2.05 KB
/
Copy pathpaystack_customers_spec.rb
File metadata and controls
60 lines (52 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require 'spec_helper'
require 'paystack/objects/customers.rb'
require 'paystack.rb'
public_test_key = "pk_test_ea7c71f838c766922873f1dd3cc529afe13da1c0"
private_test_key = "sk_test_40e9340686e6187697f8309dbae57c002bb16dd0"
describe PaystackCustomers do
it "should return a valid customers object" do
paystack = Paystack.new(public_test_key, private_test_key)
customers = PaystackCustomers.new(paystack)
expect(customers.nil?).to eq false
end
it "should return a list of customers" do
paystack = Paystack.new(public_test_key, private_test_key)
customers = PaystackCustomers.new(paystack)
expect(customers.nil?).to eq false
list = customers.list(1)
expect(list.nil?).to eq false
end
it "should return a customer hashset/object" do
paystack = Paystack.new(public_test_key, private_test_key)
customers = PaystackCustomers.new(paystack)
expect(customers.nil?).to eq false
list = customers.list(1)
expect(list.nil?).to eq false
temp = list["data"][0]
# puts temp.inspect
hash=customers.get(temp['customer_code'])
expect(hash.nil?).to eq false
expect(hash['data']['customer_code'].nil?).to eq false
end
it "should successfuly update a customer" do
paystack = Paystack.new(public_test_key, private_test_key)
customers = PaystackCustomers.new(paystack)
expect(customers.nil?).to eq false
list = customers.list(1)
expect(list.nil?).to eq false
temp = list["data"][0]
hash=customers.update(temp['id'], :first_name => "Victor", :last_name => "Ikoro", :phone => "+2347061544884")
expect(hash.nil?).to eq false
expect(hash['data']['id'].nil?).to eq false
end
it "should successfuly create a customer" do
paystack = Paystack.new(public_test_key, private_test_key)
customers = PaystackCustomers.new(paystack)
expect(customers.nil?).to eq false
temp = Random.new_seed.to_s
hash=customers.create(:first_name => "#{temp[0..6]}-person", :last_name => "Ogbonge", :phone => "+23470#{temp[0..6]}",:email => "#{temp[0..6]}@gmail.com")
# puts hash
expect(hash.nil?).to eq false
expect(hash['data']['id'].nil?).to eq false
end
end