fat_zebra 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -1
  3. data/fat_zebra.gemspec +4 -4
  4. data/lib/fat_zebra/api_helper.rb +95 -0
  5. data/lib/fat_zebra/api_operation/find.rb +18 -11
  6. data/lib/fat_zebra/api_operation/save.rb +2 -2
  7. data/lib/fat_zebra/api_operation/search.rb +19 -12
  8. data/lib/fat_zebra/api_operation/void.rb +1 -1
  9. data/lib/fat_zebra/api_resource.rb +7 -73
  10. data/lib/fat_zebra/bank_account.rb +1 -2
  11. data/lib/fat_zebra/batch.rb +5 -3
  12. data/lib/fat_zebra/card.rb +5 -4
  13. data/lib/fat_zebra/config.rb +31 -18
  14. data/lib/fat_zebra/customer.rb +2 -3
  15. data/lib/fat_zebra/direct_credit.rb +2 -3
  16. data/lib/fat_zebra/direct_debit.rb +2 -3
  17. data/lib/fat_zebra/errors.rb +22 -4
  18. data/lib/fat_zebra/fat_zebra_object.rb +4 -115
  19. data/lib/fat_zebra/object_helper.rb +118 -0
  20. data/lib/fat_zebra/payment_plan.rb +1 -2
  21. data/lib/fat_zebra/purchase.rb +3 -6
  22. data/lib/fat_zebra/refund.rb +2 -4
  23. data/lib/fat_zebra/request.rb +12 -8
  24. data/lib/fat_zebra/util.rb +17 -1
  25. data/lib/fat_zebra/version.rb +1 -1
  26. data/lib/fat_zebra/web_hook.rb +1 -2
  27. data/lib/fat_zebra.rb +2 -0
  28. data/spec/cassettes/FatZebra_BankAccount/_create/1_1_3.yml +55 -0
  29. data/spec/cassettes/FatZebra_Batch/_create/with_file/1_1_1_3.yml +65 -0
  30. data/spec/cassettes/FatZebra_Batch/_create/with_path/1_1_2_3.yml +65 -0
  31. data/spec/cassettes/FatZebra_Batch/_find/1_2_3.yml +118 -0
  32. data/spec/cassettes/FatZebra_Card/_create/1_1_7.yml +55 -0
  33. data/spec/cassettes/FatZebra_Card/_update/1_2_4.yml +105 -0
  34. data/spec/cassettes/FatZebra_Card/_update/validations/1_2_5_1.yml +55 -0
  35. data/spec/cassettes/FatZebra_Customer/_create/1_1_7.yml +57 -0
  36. data/spec/cassettes/FatZebra_Customer/_delete/1_5_2.yml +107 -0
  37. data/spec/cassettes/FatZebra_Customer/_find/1_3_3.yml +111 -0
  38. data/spec/cassettes/FatZebra_Customer/_update/1_4_3.yml +108 -0
  39. data/spec/cassettes/FatZebra_DirectCredit/_create/1_1_5.yml +54 -0
  40. data/spec/cassettes/FatZebra_DirectCredit/_delete/1_4_2.yml +103 -0
  41. data/spec/cassettes/FatZebra_DirectCredit/_find/1_2_3.yml +107 -0
  42. data/spec/cassettes/FatZebra_DirectDebit/_create/1_1_5.yml +54 -0
  43. data/spec/cassettes/FatZebra_DirectDebit/_delete/1_4_2.yml +103 -0
  44. data/spec/cassettes/FatZebra_DirectDebit/_find/1_2_3.yml +107 -0
  45. data/spec/cassettes/FatZebra_PaymentPlan/_create/1_1_4.yml +114 -0
  46. data/spec/cassettes/FatZebra_PaymentPlan/_delete/1_5_2.yml +164 -0
  47. data/spec/cassettes/FatZebra_PaymentPlan/_find/1_2_4.yml +173 -0
  48. data/spec/cassettes/FatZebra_PaymentPlan/_update/1_3_4.yml +164 -0
  49. data/spec/cassettes/FatZebra_Purchase/_capture/1_5_3.yml +107 -0
  50. data/spec/cassettes/FatZebra_Purchase/_capture/1_6_3.yml +107 -0
  51. data/spec/cassettes/FatZebra_Purchase/_create/1_1_13.yml +55 -0
  52. data/spec/cassettes/FatZebra_Purchase/_create/bad_request/1_1_14_1.yml +57 -0
  53. data/spec/cassettes/FatZebra_Purchase/_create/bad_request/1_1_14_2.yml +57 -0
  54. data/spec/cassettes/FatZebra_Purchase/_find/1_2_4.yml +109 -0
  55. data/spec/cassettes/FatZebra_Purchase/_find/1_3_1.yml +109 -0
  56. data/spec/cassettes/FatZebra_Purchase/_find/1_3_2.yml +109 -0
  57. data/spec/cassettes/FatZebra_Purchase/_find/1_3_3.yml +109 -0
  58. data/spec/cassettes/FatZebra_Purchase/_find/1_3_4.yml +109 -0
  59. data/spec/cassettes/FatZebra_Purchase/_refund/1_4_3.yml +107 -0
  60. data/spec/cassettes/FatZebra_Purchase/_refund/1_5_3.yml +107 -0
  61. data/spec/cassettes/FatZebra_Purchase/_search/1_3_4.yml +170 -0
  62. data/spec/cassettes/FatZebra_Purchase/_search/1_4_1.yml +170 -0
  63. data/spec/cassettes/FatZebra_Purchase/_search/1_4_2.yml +170 -0
  64. data/spec/cassettes/FatZebra_Purchase/_search/1_4_3.yml +170 -0
  65. data/spec/cassettes/FatZebra_Purchase/_search/1_4_4.yml +170 -0
  66. data/spec/cassettes/FatZebra_Purchase/_settlement/1_8_4.yml +842 -0
  67. data/spec/cassettes/FatZebra_Purchase/_settlement/1_9_1.yml +828 -0
  68. data/spec/cassettes/FatZebra_Purchase/_settlement/1_9_2.yml +830 -0
  69. data/spec/cassettes/FatZebra_Purchase/_settlement/1_9_3.yml +832 -0
  70. data/spec/cassettes/FatZebra_Purchase/_settlement/1_9_4.yml +834 -0
  71. data/spec/cassettes/FatZebra_Purchase/_void/1_6_4.yml +107 -0
  72. data/spec/cassettes/FatZebra_Purchase/_void/1_7_4.yml +107 -0
  73. data/spec/cassettes/FatZebra_Purchase/_void/1_8_1.yml +107 -0
  74. data/spec/cassettes/FatZebra_Purchase/_void/1_8_2.yml +107 -0
  75. data/spec/cassettes/FatZebra_Purchase/_void/1_8_3.yml +107 -0
  76. data/spec/cassettes/FatZebra_Purchase/_void/1_8_4.yml +107 -0
  77. data/spec/cassettes/FatZebra_Refund/_create/1_1_10.yml +107 -0
  78. data/spec/cassettes/FatZebra_Refund/_find/1_2_3.yml +161 -0
  79. data/spec/cassettes/FatZebra_Refund/_void/1_4_4.yml +159 -0
  80. data/spec/cassettes/FatZebra_WebHook/_create/1_1_4.yml +55 -0
  81. data/spec/cassettes/FatZebra_WebHook/_delete/1_4_2.yml +105 -0
  82. data/spec/cassettes/FatZebra_WebHook/_update/1_3_3.yml +106 -0
  83. data/spec/lib/fat_zebra/bank_account_spec.rb +2 -2
  84. data/spec/lib/fat_zebra/batch_spec.rb +4 -4
  85. data/spec/lib/fat_zebra/card_spec.rb +2 -2
  86. data/spec/lib/fat_zebra/config_spec.rb +22 -4
  87. data/spec/lib/fat_zebra/customer_spec.rb +5 -5
  88. data/spec/lib/fat_zebra/direct_credit_spec.rb +4 -4
  89. data/spec/lib/fat_zebra/direct_debit_spec.rb +4 -4
  90. data/spec/lib/fat_zebra/fat_zebra_object_spec.rb +3 -2
  91. data/spec/lib/fat_zebra/payment_plan_spec.rb +4 -4
  92. data/spec/lib/fat_zebra/purchase_spec.rb +16 -3
  93. data/spec/lib/fat_zebra/refund_spec.rb +5 -2
  94. data/spec/lib/fat_zebra/util_spec.rb +5 -0
  95. data/spec/lib/fat_zebra/web_hook_spec.rb +4 -4
  96. data/spec/spec_helper.rb +1 -1
  97. metadata +76 -19
@@ -11,7 +11,7 @@ describe FatZebra::BankAccount do
11
11
  describe '.create', :vcr do
12
12
  subject(:bank_account) { FatZebra::BankAccount.create(valid_bank_account_payload) }
13
13
 
14
- it { is_expected.to be_successful }
14
+ it { is_expected.to be_accepted }
15
15
  it { expect(bank_account.id).to_not be_empty }
16
16
 
17
17
  context 'validations' do
@@ -26,7 +26,7 @@ describe FatZebra::BankAccount do
26
26
 
27
27
  before { 2.times { |i| FatZebra::BankAccount.create(valid_bank_account_payload) } }
28
28
 
29
- it { is_expected.to be_successful }
29
+ it { is_expected.to be_accepted }
30
30
  it { expect(bank_accounts.data.count).to be >= 2 }
31
31
  it { expect(bank_accounts.data.first).to be_a(FatZebra::BankAccount) }
32
32
  end
@@ -12,7 +12,7 @@ describe FatZebra::Batch do
12
12
  subject(:batch) { FatZebra::Batch.create(valid_batch_payload) }
13
13
 
14
14
  context 'with file' do
15
- it { is_expected.to be_successful }
15
+ it { is_expected.to be_accepted }
16
16
  it { expect(batch.reference).to_not be_empty }
17
17
  end
18
18
 
@@ -22,7 +22,7 @@ describe FatZebra::Batch do
22
22
  filename: "BATCH-v1-PURCHASE-TEST-#{Time.now.strftime('%Y%m%d')}-#{SecureRandom.hex}.csv"
23
23
  }}
24
24
 
25
- it { is_expected.to be_successful }
25
+ it { is_expected.to be_accepted }
26
26
  it { expect(batch.reference).to_not be_empty }
27
27
  end
28
28
 
@@ -37,14 +37,14 @@ describe FatZebra::Batch do
37
37
  let(:create) { FatZebra::Batch.create(valid_batch_payload) }
38
38
  subject(:batch) { FatZebra::Batch.find(create.reference) }
39
39
 
40
- it { is_expected.to be_successful }
40
+ it { is_expected.to be_accepted }
41
41
  it { expect(batch.reference).to eq(create.reference) }
42
42
  end
43
43
 
44
44
  describe '.search', :vcr do
45
45
  subject(:batches) { FatZebra::Batch.search }
46
46
 
47
- it { is_expected.to be_successful }
47
+ it { is_expected.to be_accepted }
48
48
  it { expect(batches.data.count).to be >= 2 }
49
49
  it { expect(batches.data.first).to be_a(FatZebra::Batch) }
50
50
  end
@@ -5,7 +5,7 @@ describe FatZebra::Card do
5
5
  describe '.create', :vcr do
6
6
  subject(:credit_card) { FatZebra::Card.create(valid_credit_card_payload) }
7
7
 
8
- it { is_expected.to be_successful }
8
+ it { is_expected.to be_accepted }
9
9
  it { expect(credit_card.token).to_not be_empty }
10
10
  it { expect(credit_card.card_holder).to eq('Matthew Savage') }
11
11
  it { expect(credit_card.card_number).to_not be_empty }
@@ -27,7 +27,7 @@ describe FatZebra::Card do
27
27
  let(:create) { FatZebra::Card.create(valid_credit_card_payload) }
28
28
  subject(:credit_card) { FatZebra::Card.update(create.token, valid_credit_card_update_payload) }
29
29
 
30
- it { is_expected.to be_successful }
30
+ it { is_expected.to be_accepted }
31
31
  it { expect(credit_card.token).to eq(create.token) }
32
32
  it { expect(credit_card.card_expiry).to_not eq(create.card_expiry) }
33
33
 
@@ -25,8 +25,6 @@ describe FatZebra::Config do
25
25
  test_mode: 'my-test_mode',
26
26
  http_secure: 'my-http_secure',
27
27
  api_version: 'my-api_version',
28
- sandbox: 'my-sandbox',
29
- options: 'my-options',
30
28
  proxy: 'my-proxy'
31
29
  }}
32
30
 
@@ -35,8 +33,6 @@ describe FatZebra::Config do
35
33
  it { expect(config.test_mode).to eq(params[:test_mode]) }
36
34
  it { expect(config.http_secure).to eq(params[:http_secure]) }
37
35
  it { expect(config.api_version).to eq(params[:api_version]) }
38
- it { expect(config.sandbox).to eq(params[:sandbox]) }
39
- it { expect(config.options).to eq(params[:options]) }
40
36
  it { expect(config.proxy).to eq(params[:proxy]) }
41
37
  end
42
38
 
@@ -48,5 +44,27 @@ describe FatZebra::Config do
48
44
  end
49
45
  end
50
46
 
47
+ context 'with gateway' do
48
+ before { expect(config.valid!).to be_truthy }
49
+
50
+ context 'with production' do
51
+ subject(:config) { FatZebra::Config.new(params.merge(gateway: :production)) }
52
+
53
+ it { expect(config.gateway).to eq('gateway.fatzebra.com.au') }
54
+ end
55
+ end
56
+
57
+ context 'remove http' do
58
+ let(:params) {{
59
+ token: 'my-token',
60
+ username: 'my-username',
61
+ gateway: 'http://my-gateway',
62
+ proxy: 'https://my-proxy'
63
+ }}
64
+
65
+ it { expect(config.gateway).to eq('my-gateway') }
66
+ it { expect(config.proxy).to eq('my-proxy') }
67
+ end
68
+
51
69
  end
52
70
  end
@@ -5,7 +5,7 @@ describe FatZebra::Customer do
5
5
  describe '.create', :vcr do
6
6
  subject(:customer) { FatZebra::Customer.create(customer_valid_payload) }
7
7
 
8
- it { is_expected.to be_successful }
8
+ it { is_expected.to be_accepted }
9
9
  it { expect(customer.id).to_not be_empty }
10
10
  it { expect(customer.first_name).to eq(customer_valid_payload[:first_name]) }
11
11
  it { expect(customer.last_name).to eq(customer_valid_payload[:last_name]) }
@@ -22,7 +22,7 @@ describe FatZebra::Customer do
22
22
  describe '.search', :vcr do
23
23
  subject(:purchases) { FatZebra::Customer.search }
24
24
 
25
- it { is_expected.to be_successful }
25
+ it { is_expected.to be_accepted }
26
26
  it { expect(purchases.data.count).to be >= 2 }
27
27
  it { expect(purchases.data.first).to be_a(FatZebra::Customer) }
28
28
  end
@@ -31,7 +31,7 @@ describe FatZebra::Customer do
31
31
  let!(:create) { FatZebra::Customer.create(customer_valid_payload) }
32
32
  subject(:customer) { FatZebra::Customer.find(create.reference) }
33
33
 
34
- it { is_expected.to be_successful }
34
+ it { is_expected.to be_accepted }
35
35
  it { expect(customer.reference).to eq(create.reference) }
36
36
  end
37
37
 
@@ -39,7 +39,7 @@ describe FatZebra::Customer do
39
39
  let(:create) { FatZebra::Customer.create(customer_valid_payload) }
40
40
  subject(:customer) { FatZebra::Customer.update(create.id, first_name: 'New Name') }
41
41
 
42
- it { is_expected.to be_successful }
42
+ it { is_expected.to be_accepted }
43
43
  it { expect(customer.first_name).to eq('New Name') }
44
44
  end
45
45
 
@@ -47,7 +47,7 @@ describe FatZebra::Customer do
47
47
  let(:create) { FatZebra::Customer.create(customer_valid_payload) }
48
48
  subject(:customer) { FatZebra::Customer.delete(create.id) }
49
49
 
50
- it { is_expected.to be_successful }
50
+ it { is_expected.to be_accepted }
51
51
  end
52
52
 
53
53
  end
@@ -13,7 +13,7 @@ describe FatZebra::DirectCredit do
13
13
  describe '.create', :vcr do
14
14
  subject(:direct_credit) { FatZebra::DirectCredit.create(valid_direct_credit_payload) }
15
15
 
16
- it { is_expected.to be_successful }
16
+ it { is_expected.to be_accepted }
17
17
  it { expect(direct_credit.bsb).to eq(valid_direct_credit_payload[:bsb]) }
18
18
  it { expect(direct_credit.reference).to_not be_empty }
19
19
  it { expect(direct_credit.id).to_not be_empty }
@@ -29,7 +29,7 @@ describe FatZebra::DirectCredit do
29
29
  let!(:create) { FatZebra::DirectCredit.create(valid_direct_credit_payload) }
30
30
  subject(:direct_credit) { FatZebra::DirectCredit.find(create.reference) }
31
31
 
32
- it { is_expected.to be_successful }
32
+ it { is_expected.to be_accepted }
33
33
  it { expect(direct_credit.reference).to eq(create.reference) }
34
34
  end
35
35
 
@@ -39,7 +39,7 @@ describe FatZebra::DirectCredit do
39
39
 
40
40
  before { 2.times { |i| FatZebra::DirectCredit.create(valid_direct_credit_payload) } }
41
41
 
42
- it { is_expected.to be_successful }
42
+ it { is_expected.to be_accepted }
43
43
  it { expect(direct_credits.data.count).to be >= 2 }
44
44
  end
45
45
 
@@ -47,7 +47,7 @@ describe FatZebra::DirectCredit do
47
47
  let(:create) { FatZebra::DirectCredit.create(valid_direct_credit_payload) }
48
48
  subject(:direct_credit) { FatZebra::DirectCredit.delete(create.id) }
49
49
 
50
- it { is_expected.to be_successful }
50
+ it { is_expected.to be_accepted }
51
51
  end
52
52
 
53
53
  end
@@ -13,7 +13,7 @@ describe FatZebra::DirectDebit do
13
13
  describe '.create', :vcr do
14
14
  subject(:direct_debit) { FatZebra::DirectDebit.create(valid_direct_debit_payload) }
15
15
 
16
- it { is_expected.to be_successful }
16
+ it { is_expected.to be_accepted }
17
17
  it { expect(direct_debit.bsb).to eq(valid_direct_debit_payload[:bsb]) }
18
18
  it { expect(direct_debit.reference).to_not be_empty }
19
19
  it { expect(direct_debit.id).to_not be_empty }
@@ -29,7 +29,7 @@ describe FatZebra::DirectDebit do
29
29
  let!(:create) { FatZebra::DirectDebit.create(valid_direct_debit_payload) }
30
30
  subject(:direct_debit) { FatZebra::DirectDebit.find(create.reference) }
31
31
 
32
- it { is_expected.to be_successful }
32
+ it { is_expected.to be_accepted }
33
33
  it { expect(direct_debit.reference).to eq(create.reference) }
34
34
  end
35
35
 
@@ -39,7 +39,7 @@ describe FatZebra::DirectDebit do
39
39
 
40
40
  before { 2.times { |i| FatZebra::DirectDebit.create(valid_direct_debit_payload) } }
41
41
 
42
- it { is_expected.to be_successful }
42
+ it { is_expected.to be_accepted }
43
43
  it { expect(direct_debits.data.count).to be >= 2 }
44
44
  end
45
45
 
@@ -47,7 +47,7 @@ describe FatZebra::DirectDebit do
47
47
  let(:create) { FatZebra::DirectDebit.create(valid_direct_debit_payload) }
48
48
  subject(:direct_debit) { FatZebra::DirectDebit.delete(create.id) }
49
49
 
50
- it { is_expected.to be_successful }
50
+ it { is_expected.to be_accepted }
51
51
  end
52
52
 
53
53
  end
@@ -8,6 +8,7 @@ describe FatZebra::FatZebraObject do
8
8
  let(:api_response) {{
9
9
  'successful' => true,
10
10
  'response' => {
11
+ successful: true,
11
12
  id: 84,
12
13
  other: 'other test'
13
14
  }
@@ -68,7 +69,7 @@ describe FatZebra::FatZebraObject do
68
69
 
69
70
  before { instance.load_response_api(response) }
70
71
 
71
- it { expect(instance.successful).to be_truthy }
72
+ it { expect(instance.accepted).to be_truthy }
72
73
  it { expect(instance.errors).to eq([]) }
73
74
  end
74
75
 
@@ -99,7 +100,7 @@ describe FatZebra::FatZebraObject do
99
100
  context 'with array' do
100
101
  subject(:instance) { klass.initialize_from(api_responses) }
101
102
 
102
- it { is_expected.to be_successful }
103
+ it { is_expected.to be_accepted }
103
104
  it { expect(instance.data.size).to eq(1) }
104
105
  end
105
106
  end
@@ -19,7 +19,7 @@ describe FatZebra::PaymentPlan do
19
19
  describe '.create', :vcr do
20
20
  subject(:payment_plan) { FatZebra::PaymentPlan.create(payment_plan_valid_payload) }
21
21
 
22
- it { is_expected.to be_successful }
22
+ it { is_expected.to be_accepted }
23
23
  it { expect(payment_plan.id).to_not be_empty }
24
24
  it { expect(payment_plan.payments.count).to eq(5) }
25
25
 
@@ -34,7 +34,7 @@ describe FatZebra::PaymentPlan do
34
34
  let!(:create) { FatZebra::PaymentPlan.create(payment_plan_valid_payload) }
35
35
  subject(:payment_plan) { FatZebra::PaymentPlan.find(create.reference) }
36
36
 
37
- it { is_expected.to be_successful }
37
+ it { is_expected.to be_accepted }
38
38
  it { expect(payment_plan.reference).to eq(create.reference) }
39
39
  it { expect(payment_plan).to be_a(FatZebra::PaymentPlan) }
40
40
  end
@@ -44,7 +44,7 @@ describe FatZebra::PaymentPlan do
44
44
 
45
45
  subject(:payment_plan) { FatZebra::PaymentPlan.update(create.id, new_status: 'Suspended') }
46
46
 
47
- it { is_expected.to be_successful }
47
+ it { is_expected.to be_accepted }
48
48
  it { expect(payment_plan.status).to eq('Suspended') }
49
49
  it { expect(payment_plan).to be_a(FatZebra::PaymentPlan) }
50
50
  end
@@ -62,7 +62,7 @@ describe FatZebra::PaymentPlan do
62
62
  let(:create) { FatZebra::PaymentPlan.create(payment_plan_valid_payload) }
63
63
  subject(:payment_plan) { FatZebra::PaymentPlan.delete(create.id) }
64
64
 
65
- it { is_expected.to be_successful }
65
+ it { is_expected.to be_accepted }
66
66
  end
67
67
 
68
68
  describe '#destroy', :vcr do
@@ -5,6 +5,7 @@ describe FatZebra::Purchase do
5
5
  describe '.create', :vcr do
6
6
  subject(:purchase) { FatZebra::Purchase.create(valid_purchase_payload) }
7
7
 
8
+ it { is_expected.to be_accepted }
8
9
  it { is_expected.to be_successful }
9
10
  it { expect(purchase.card_holder).to eq(valid_purchase_payload[:card_holder]) }
10
11
  it { expect(purchase.currency).to eq('AUD') }
@@ -18,6 +19,13 @@ describe FatZebra::Purchase do
18
19
  it { expect(purchase.metadata).to eq({}) }
19
20
  it { expect(purchase.response_code).to eq('00') }
20
21
 
22
+ context 'bad request' do
23
+ subject(:purchase) { FatZebra::Purchase.create(valid_purchase_payload.merge(currency: 'XXX' )) }
24
+
25
+ it { is_expected.to_not be_accepted }
26
+ it { is_expected.to_not be_successful }
27
+ end
28
+
21
29
  context 'validations' do
22
30
  let(:valid_purchase_payload) {{}}
23
31
 
@@ -29,6 +37,7 @@ describe FatZebra::Purchase do
29
37
  let!(:create) { FatZebra::Purchase.create(valid_purchase_payload) }
30
38
  subject(:purchase) { FatZebra::Purchase.find(create.reference) }
31
39
 
40
+ it { is_expected.to be_accepted }
32
41
  it { is_expected.to be_successful }
33
42
  it { expect(purchase.reference).to eq(create.reference) }
34
43
  it { expect(purchase.transaction_id).to eq(create.transaction_id) }
@@ -40,7 +49,7 @@ describe FatZebra::Purchase do
40
49
 
41
50
  before { 2.times { |i| FatZebra::Purchase.create(valid_purchase_payload.merge(reference: "#{SecureRandom.hex}-#{i}")) } }
42
51
 
43
- it { is_expected.to be_successful }
52
+ it { is_expected.to be_accepted }
44
53
  it { expect(purchases.data.count).to be >= 2 }
45
54
  it { expect(purchases.data.first).to be_a(FatZebra::Purchase) }
46
55
  end
@@ -49,6 +58,7 @@ describe FatZebra::Purchase do
49
58
  let(:purchase) { FatZebra::Purchase.create(valid_purchase_payload) }
50
59
  subject(:refund) { purchase.refund }
51
60
 
61
+ it { is_expected.to be_accepted }
52
62
  it { is_expected.to be_successful }
53
63
  it { expect(refund).to be_a(FatZebra::Refund) }
54
64
  end
@@ -57,6 +67,7 @@ describe FatZebra::Purchase do
57
67
  let(:purchase) { FatZebra::Purchase.create(valid_purchase_payload.merge(capture: false)) }
58
68
  subject(:capture) { purchase.capture }
59
69
 
70
+ it { is_expected.to be_accepted }
60
71
  it { is_expected.to be_successful }
61
72
  it { expect(capture).to be_a(FatZebra::Purchase) }
62
73
  end
@@ -65,15 +76,17 @@ describe FatZebra::Purchase do
65
76
  let(:purchase) { FatZebra::Purchase.create(valid_purchase_payload) }
66
77
  subject(:void) { FatZebra::Purchase.void(purchase.id) }
67
78
 
79
+ it { is_expected.to be_accepted }
68
80
  it { is_expected.to_not be_successful }
69
81
  it { expect(void.message).to eq('Voided') }
70
82
  it { expect(void).to be_a(FatZebra::Purchase) }
71
83
  end
72
84
 
73
85
  describe '#void', :vcr do
74
- let(:purchase) { FatZebra::Purchase.create(valid_purchase_payload) }
86
+ subject(:purchase) { FatZebra::Purchase.create(valid_purchase_payload) }
75
87
  before { expect(purchase.void).to be_truthy }
76
88
 
89
+ it { is_expected.to be_accepted }
77
90
  it { is_expected.to_not be_successful }
78
91
  it { expect(purchase.message).to eq('Voided') }
79
92
  it { expect(purchase).to be_a(FatZebra::Purchase) }
@@ -84,7 +97,7 @@ describe FatZebra::Purchase do
84
97
 
85
98
  subject(:settlement) { FatZebra::Purchase.settlement(from: Time.now - (86400 * 5), to: Time.now) }
86
99
 
87
- it { is_expected.to be_successful }
100
+ it { is_expected.to be_accepted }
88
101
  it { expect(settlement.data.count).to be >= 2 }
89
102
  it { expect(settlement.data.first).to be_a(FatZebra::Purchase) }
90
103
  end
@@ -13,6 +13,7 @@ describe FatZebra::Refund do
13
13
  let(:reference) { purchase.reference }
14
14
  subject(:refund) { FatZebra::Refund.create(valid_refund_payload) }
15
15
 
16
+ it { is_expected.to be_accepted }
16
17
  it { is_expected.to be_successful }
17
18
  it { expect(refund.authorization.to_s).to_not be_empty }
18
19
  it { expect(refund.id).to_not be_empty }
@@ -38,6 +39,7 @@ describe FatZebra::Refund do
38
39
 
39
40
  subject(:direct_credit) { FatZebra::Refund.find(create.reference) }
40
41
 
42
+ it { is_expected.to be_accepted }
41
43
  it { is_expected.to be_successful }
42
44
  it { expect(direct_credit.reference).to eq(create.reference) }
43
45
  end
@@ -52,7 +54,7 @@ describe FatZebra::Refund do
52
54
  end
53
55
  end
54
56
 
55
- it { is_expected.to be_successful }
57
+ it { is_expected.to be_accepted }
56
58
  it { expect(direct_credits.data.count).to be >= 2 }
57
59
  end
58
60
 
@@ -60,10 +62,11 @@ describe FatZebra::Refund do
60
62
  let(:purchase) { FatZebra::Purchase.create(valid_purchase_payload) }
61
63
  let(:transaction_id) { purchase.transaction_id }
62
64
  let(:reference) { purchase.reference }
63
- let(:refund) { FatZebra::Refund.create(valid_refund_payload) }
65
+ subject(:refund) { FatZebra::Refund.create(valid_refund_payload) }
64
66
 
65
67
  before { refund.void() }
66
68
 
69
+ it { is_expected.to be_accepted }
67
70
  it { is_expected.to_not be_successful }
68
71
  it { expect(refund.message).to eq('Voided') }
69
72
  it { expect(refund).to be_a(FatZebra::Refund) }
@@ -10,6 +10,11 @@ describe FatZebra::Util do
10
10
  it { expect(FatZebra::Util.encode_parameters(id: 42, other: 'test')).to eq("id=42&other=test") }
11
11
  end
12
12
 
13
+ describe '#camelize' do
14
+ it { expect(FatZebra::Util.camelize('model')).to eq("Model") }
15
+ it { expect(FatZebra::Util.camelize('my_model')).to eq("MyModel") }
16
+ end
17
+
13
18
  describe '#underscore' do
14
19
  it { expect(FatZebra::Util.underscore('Model')).to eq("model") }
15
20
  it { expect(FatZebra::Util.underscore('MyModel')).to eq("my_model") }
@@ -12,7 +12,7 @@ describe FatZebra::WebHook do
12
12
  describe '.create', :vcr do
13
13
  subject(:web_hook) { FatZebra::WebHook.create(valid_web_hook_payload) }
14
14
 
15
- it { is_expected.to be_successful }
15
+ it { is_expected.to be_accepted }
16
16
  it { expect(web_hook.name).to eq('test hook') }
17
17
  it { expect(web_hook.id).to_not be_empty }
18
18
 
@@ -28,7 +28,7 @@ describe FatZebra::WebHook do
28
28
 
29
29
  before { 2.times { |i| FatZebra::WebHook.create(valid_web_hook_payload) } }
30
30
 
31
- it { is_expected.to be_successful }
31
+ it { is_expected.to be_accepted }
32
32
  it { expect(web_hooks.data.count).to be >= 2 }
33
33
  end
34
34
 
@@ -36,7 +36,7 @@ describe FatZebra::WebHook do
36
36
  subject(:web_hook) { FatZebra::WebHook.create(valid_web_hook_payload) }
37
37
  before { web_hook.update(name: 'New Test hook')}
38
38
 
39
- it { is_expected.to be_successful }
39
+ it { is_expected.to be_accepted }
40
40
  it { expect(web_hook.name).to eq('New Test hook') }
41
41
  end
42
42
 
@@ -44,7 +44,7 @@ describe FatZebra::WebHook do
44
44
  let(:create) { FatZebra::WebHook.create(valid_web_hook_payload) }
45
45
  subject(:web_hook) { FatZebra::WebHook.delete(create.id) }
46
46
 
47
- it { is_expected.to be_successful }
47
+ it { is_expected.to be_accepted }
48
48
  end
49
49
 
50
50
  end
data/spec/spec_helper.rb CHANGED
@@ -46,7 +46,7 @@ RSpec.configure do |config|
46
46
  FatZebra.configure do |config|
47
47
  config.username = 'TEST'
48
48
  config.token = 'TEST'
49
- config.gateway = 'gateway.sandbox.fatzebra.com.au'
49
+ config.gateway = :sandbox
50
50
  config.test_mode = true
51
51
  end
52
52
  end