-
Notifications
You must be signed in to change notification settings - Fork 14
/
event_spec.rb
104 lines (63 loc) · 2.68 KB
/
event_spec.rb
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
require 'spec_helper'
describe GoCardlessPro::Resources::Event do
describe 'initialising' do
let(:data) do
{
'action' => 'action-input',
'created_at' => 'created_at-input',
'details' => 'details-input',
'id' => 'id-input',
'links' => {
'mandate' => 'mandate-input',
'new_customer_bank_account' => 'new_customer_bank_account-input',
'new_mandate' => 'new_mandate-input',
'organisation' => 'organisation-input',
'parent_event' => 'parent_event-input',
'payment' => 'payment-input',
'payout' => 'payout-input',
'previous_customer_bank_account' => 'previous_customer_bank_account-input',
'refund' => 'refund-input',
'subscription' => 'subscription-input'
},
'metadata' => 'metadata-input',
'resource_type' => 'resource_type-input'
}
end
it 'can be initialized from an unenveloped response' do
resource = described_class.new(data)
expect(resource.action).to eq('action-input')
expect(resource.created_at).to eq('created_at-input')
expect(resource.details).to eq('details-input')
expect(resource.id).to eq('id-input')
expect(resource.links.mandate).to eq('mandate-input')
expect(resource.links.new_customer_bank_account).to eq('new_customer_bank_account-input')
expect(resource.links.new_mandate).to eq('new_mandate-input')
expect(resource.links.organisation).to eq('organisation-input')
expect(resource.links.parent_event).to eq('parent_event-input')
expect(resource.links.payment).to eq('payment-input')
expect(resource.links.payout).to eq('payout-input')
expect(resource.links.previous_customer_bank_account).to eq('previous_customer_bank_account-input')
expect(resource.links.refund).to eq('refund-input')
expect(resource.links.subscription).to eq('subscription-input')
expect(resource.metadata).to eq('metadata-input')
expect(resource.resource_type).to eq('resource_type-input')
end
it 'can handle new attributes without erroring' do
data['foo'] = 'bar'
expect { described_class.new(data) }.to_not raise_error
end
it 'can handle new link attributes without erroring' do
data['links']['foo'] = 'bar'
expect { described_class.new(data) }.to_not raise_error
end
it 'can handle a nil links value' do
data['links'] = nil
expect { described_class.new(data).links }.to_not raise_error
end
describe '#to_h' do
it 'returns a hash representing the resource' do
expect(described_class.new(data).to_h).to eq(data)
end
end
end
end