gocardless 1.11.2 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -3
- data/CHANGELOG.md +10 -0
- data/Gemfile +1 -0
- data/gocardless.gemspec +5 -5
- data/lib/gocardless.rb +11 -2
- data/lib/gocardless/client.rb +1 -0
- data/lib/gocardless/version.rb +1 -1
- data/spec/bill_spec.rb +7 -7
- data/spec/client_spec.rb +109 -104
- data/spec/gocardless_spec.rb +20 -2
- data/spec/page_spec.rb +11 -11
- data/spec/paginator_spec.rb +16 -16
- data/spec/pre_authorization_spec.rb +1 -1
- data/spec/resource_spec.rb +61 -61
- data/spec/spec_helper.rb +4 -4
- data/spec/subscription_spec.rb +1 -1
- data/spec/user_spec.rb +4 -4
- data/spec/utils_spec.rb +62 -58
- metadata +14 -13
data/spec/spec_helper.rb
CHANGED
@@ -3,10 +3,10 @@ require 'gocardless'
|
|
3
3
|
|
4
4
|
def stub_get(client, data)
|
5
5
|
response = double
|
6
|
-
response.
|
6
|
+
allow(response).to receive(:parsed).and_return(data)
|
7
7
|
|
8
8
|
token = client.instance_variable_get(:@access_token)
|
9
|
-
token.
|
9
|
+
allow(token).to receive(:get).and_return response
|
10
10
|
end
|
11
11
|
|
12
12
|
def unset_ivar(obj, var)
|
@@ -17,12 +17,12 @@ shared_examples_for "it has a query method for" do |status|
|
|
17
17
|
describe "##{status}?" do
|
18
18
|
context "when #{status}" do
|
19
19
|
let(:object) { described_class.new(:status => status) }
|
20
|
-
specify { object.send("#{status}?").
|
20
|
+
specify { expect(object.send("#{status}?")).to be_truthy }
|
21
21
|
end
|
22
22
|
|
23
23
|
context "when not #{status}" do
|
24
24
|
let(:object) { described_class.new }
|
25
|
-
specify { object.send("#{status}?").
|
25
|
+
specify { expect(object.send("#{status}?")).to be_falsey }
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
data/spec/subscription_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe GoCardless::Subscription do
|
|
9
9
|
let(:subscription) { GoCardless::Subscription.new(:id => '009988') }
|
10
10
|
|
11
11
|
it "should be cancellable" do
|
12
|
-
client.
|
12
|
+
expect(client).to receive(:api_put).with('/subscriptions/009988/cancel')
|
13
13
|
subscription.cancel!
|
14
14
|
end
|
15
15
|
|
data/spec/user_spec.rb
CHANGED
@@ -7,25 +7,25 @@ describe GoCardless::User do
|
|
7
7
|
context "with first and last name" do
|
8
8
|
let(:first) { "First" }
|
9
9
|
let(:last) { "Last" }
|
10
|
-
specify { user.name.
|
10
|
+
specify { expect(user.name).to eq("First Last") }
|
11
11
|
end
|
12
12
|
|
13
13
|
context "with first name only" do
|
14
14
|
let(:first) { "First" }
|
15
15
|
let(:last) { nil }
|
16
|
-
specify { user.name.
|
16
|
+
specify { expect(user.name).to eq("First") }
|
17
17
|
end
|
18
18
|
|
19
19
|
context "with last name only" do
|
20
20
|
let(:first) { nil }
|
21
21
|
let(:last) { "Last" }
|
22
|
-
specify { user.name.
|
22
|
+
specify { expect(user.name).to eq("Last") }
|
23
23
|
end
|
24
24
|
|
25
25
|
context "with no first or last name" do
|
26
26
|
let(:first) { nil }
|
27
27
|
let(:last) { nil }
|
28
|
-
specify { user.name.
|
28
|
+
specify { expect(user.name).to eq("") }
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/spec/utils_spec.rb
CHANGED
@@ -7,33 +7,33 @@ describe GoCardless::Utils do
|
|
7
7
|
describe "string helpers" do
|
8
8
|
describe ".camelize" do
|
9
9
|
it "converts underscored words to camel case" do
|
10
|
-
GoCardless::Utils.camelize("a_test_string").
|
10
|
+
expect(GoCardless::Utils.camelize("a_test_string")).to eq("ATestString")
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
describe ".underscore" do
|
15
15
|
it "converts camel case words to underscored form" do
|
16
|
-
GoCardless::Utils.underscore("ATestString").
|
16
|
+
expect(GoCardless::Utils.underscore("ATestString")).to eq("a_test_string")
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
describe ".singularize" do
|
21
21
|
it "removes trailing 's' characters" do
|
22
|
-
GoCardless::Utils.singularize("desks").
|
22
|
+
expect(GoCardless::Utils.singularize("desks")).to eq("desk")
|
23
23
|
end
|
24
24
|
|
25
25
|
it "converts 'i' suffix to 'us'" do
|
26
|
-
GoCardless::Utils.singularize("cacti").
|
26
|
+
expect(GoCardless::Utils.singularize("cacti")).to eq("cactus")
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
describe '.secure_compare' do
|
31
31
|
it 'is true for the same strings' do
|
32
|
-
GoCardless::Utils.secure_compare('hello', 'hello').
|
32
|
+
expect(GoCardless::Utils.secure_compare('hello', 'hello')).to be_truthy
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'is false for different strings' do
|
36
|
-
GoCardless::Utils.secure_compare('hello', 'banjo').
|
36
|
+
expect(GoCardless::Utils.secure_compare('hello', 'banjo')).to be_falsey
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -43,27 +43,27 @@ describe GoCardless::Utils do
|
|
43
43
|
it "converts keys to symbols" do
|
44
44
|
hash = {'string' => true, 123 => true, :symbol => true}
|
45
45
|
keys = GoCardless::Utils.symbolize_keys(hash).keys
|
46
|
-
keys.length.
|
47
|
-
keys.
|
48
|
-
keys.
|
49
|
-
keys.
|
46
|
+
expect(keys.length).to eq(3)
|
47
|
+
expect(keys).to include :string
|
48
|
+
expect(keys).to include :'123'
|
49
|
+
expect(keys).to include :symbol
|
50
50
|
end
|
51
51
|
|
52
52
|
it "preserves the original hash" do
|
53
53
|
hash = {'string' => true}
|
54
54
|
GoCardless::Utils.symbolize_keys(hash)
|
55
|
-
hash.keys.
|
55
|
+
expect(hash.keys).to eq(['string'])
|
56
56
|
end
|
57
57
|
|
58
58
|
it "doesn't overwrite existing symbol keys" do
|
59
59
|
hash = {'x' => 1, :x => 2}
|
60
|
-
GoCardless::Utils.symbolize_keys(hash).
|
60
|
+
expect(GoCardless::Utils.symbolize_keys(hash)).to eq(hash)
|
61
61
|
end
|
62
62
|
|
63
63
|
it "works with sinatra params' default proc" do
|
64
64
|
hash = Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
|
65
65
|
hash['x'] = 1
|
66
|
-
GoCardless::Utils.symbolize_keys(hash).
|
66
|
+
expect(GoCardless::Utils.symbolize_keys(hash)).to eq({:x => 1})
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -71,7 +71,7 @@ describe GoCardless::Utils do
|
|
71
71
|
it "modifies the original hash" do
|
72
72
|
hash = {'string' => true}
|
73
73
|
GoCardless::Utils.symbolize_keys!(hash)
|
74
|
-
hash.keys.
|
74
|
+
expect(hash.keys).to eq([:string])
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -81,37 +81,37 @@ describe GoCardless::Utils do
|
|
81
81
|
subject { GoCardless::Utils.method(:percent_encode) }
|
82
82
|
|
83
83
|
it "works with empty strings" do
|
84
|
-
subject[""].
|
84
|
+
expect(subject[""]).to eq("")
|
85
85
|
end
|
86
86
|
|
87
87
|
it "doesn't encode lowercase alpha characters" do
|
88
|
-
subject["abcxyz"].
|
88
|
+
expect(subject["abcxyz"]).to eq("abcxyz")
|
89
89
|
end
|
90
90
|
|
91
91
|
it "doesn't encode uppercase alpha characters" do
|
92
|
-
subject["ABCXYZ"].
|
92
|
+
expect(subject["ABCXYZ"]).to eq("ABCXYZ")
|
93
93
|
end
|
94
94
|
|
95
95
|
it "doesn't encode digits" do
|
96
|
-
subject["1234567890"].
|
96
|
+
expect(subject["1234567890"]).to eq("1234567890")
|
97
97
|
end
|
98
98
|
|
99
99
|
it "doesn't encode unreserved non-alphanumeric characters" do
|
100
|
-
subject["-._~"].
|
100
|
+
expect(subject["-._~"]).to eq("-._~")
|
101
101
|
end
|
102
102
|
|
103
103
|
it "encodes non-ascii alpha characters" do
|
104
|
-
subject["å"].
|
104
|
+
expect(subject["å"]).to eq("%C3%A5")
|
105
105
|
end
|
106
106
|
|
107
107
|
it "encodes reserved ascii characters" do
|
108
|
-
subject[" !\"\#$%&'()"].
|
109
|
-
subject["*+,/{|}:;"].
|
110
|
-
subject["<=>?@[\\]^`"].
|
108
|
+
expect(subject[" !\"\#$%&'()"]).to eq("%20%21%22%23%24%25%26%27%28%29")
|
109
|
+
expect(subject["*+,/{|}:;"]).to eq("%2A%2B%2C%2F%7B%7C%7D%3A%3B")
|
110
|
+
expect(subject["<=>?@[\\]^`"]).to eq("%3C%3D%3E%3F%40%5B%5C%5D%5E%60")
|
111
111
|
end
|
112
112
|
|
113
113
|
it "encodes other non-ascii characters" do
|
114
|
-
subject["支払い"].
|
114
|
+
expect(subject["支払い"]).to eq("%E6%94%AF%E6%89%95%E3%81%84")
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
@@ -119,66 +119,66 @@ describe GoCardless::Utils do
|
|
119
119
|
subject { GoCardless::Utils.method(:flatten_params) }
|
120
120
|
|
121
121
|
it "and_return an empty array when provided with an empty hash" do
|
122
|
-
subject[{}].
|
122
|
+
expect(subject[{}]).to eq([])
|
123
123
|
end
|
124
124
|
|
125
125
|
it "converts hashes to key-value arrays" do
|
126
|
-
subject['a' => 'b'].
|
126
|
+
expect(subject['a' => 'b']).to eq([['a', 'b']])
|
127
127
|
end
|
128
128
|
|
129
129
|
it "works with integer keys and values" do
|
130
|
-
subject[123 => 456].
|
130
|
+
expect(subject[123 => 456]).to eq([['123', '456']])
|
131
131
|
end
|
132
132
|
|
133
133
|
it "converts DateTime objects to ISO8601-fomatted strings" do
|
134
134
|
date = '2001-02-03T12:23:45Z'
|
135
|
-
subject[:date => Time.parse(date)][0][1].
|
135
|
+
expect(subject[:date => Time.parse(date)][0][1]).to eq(date)
|
136
136
|
end
|
137
137
|
|
138
138
|
it "works with symbol keys and values" do
|
139
|
-
subject[:a => :b].
|
139
|
+
expect(subject[:a => :b]).to eq([['a', 'b']])
|
140
140
|
end
|
141
141
|
|
142
142
|
it "uses empty-bracket syntax for arrays" do
|
143
|
-
subject['a' => ['b']].
|
143
|
+
expect(subject['a' => ['b']]).to eq([['a[]', 'b']])
|
144
144
|
end
|
145
145
|
|
146
146
|
it "excludes values with empty arrays" do
|
147
|
-
subject['a' => []].
|
147
|
+
expect(subject['a' => []]).to eq([])
|
148
148
|
end
|
149
149
|
|
150
150
|
it "includes all array values separately" do
|
151
151
|
result = subject['a' => ['b', 'c']]
|
152
|
-
result.
|
153
|
-
result.
|
154
|
-
result.length.
|
152
|
+
expect(result).to include ['a[]', 'b']
|
153
|
+
expect(result).to include ['a[]', 'c']
|
154
|
+
expect(result.length).to eq(2)
|
155
155
|
end
|
156
156
|
|
157
157
|
it "flattens nested arrays" do
|
158
|
-
subject['a' => [['b']]].
|
158
|
+
expect(subject['a' => [['b']]]).to eq([['a[][]', 'b']])
|
159
159
|
end
|
160
160
|
|
161
161
|
it "uses the bracket-syntax for hashes" do
|
162
|
-
subject['a' => {'b' => 'c'}].
|
162
|
+
expect(subject['a' => {'b' => 'c'}]).to eq([['a[b]', 'c']])
|
163
163
|
end
|
164
164
|
|
165
165
|
it "includes all hash k/v pairs separately" do
|
166
166
|
result = subject['a' => {'b' => 'c', 'd' => 'e'}]
|
167
|
-
result.
|
168
|
-
result.
|
169
|
-
result.length.
|
167
|
+
expect(result).to include ['a[b]', 'c']
|
168
|
+
expect(result).to include ['a[d]', 'e']
|
169
|
+
expect(result.length).to eq(2)
|
170
170
|
end
|
171
171
|
|
172
172
|
it "flattens nested hashes" do
|
173
|
-
subject['a' => {'b' => {'c' => 'd'}}].
|
173
|
+
expect(subject['a' => {'b' => {'c' => 'd'}}]).to eq([['a[b][c]', 'd']])
|
174
174
|
end
|
175
175
|
|
176
176
|
it "works with arrays inside hashes" do
|
177
|
-
subject['a' => {'b' => ['c']}].
|
177
|
+
expect(subject['a' => {'b' => ['c']}]).to eq([['a[b][]', 'c']])
|
178
178
|
end
|
179
179
|
|
180
180
|
it "works with hashes inside arrays" do
|
181
|
-
subject['a' => [{'b' => 'c'}]].
|
181
|
+
expect(subject['a' => [{'b' => 'c'}]]).to eq([['a[][b]', 'c']])
|
182
182
|
end
|
183
183
|
end
|
184
184
|
|
@@ -186,19 +186,19 @@ describe GoCardless::Utils do
|
|
186
186
|
subject { GoCardless::Utils.method(:normalize_params) }
|
187
187
|
|
188
188
|
it "percent encodes keys and values" do
|
189
|
-
subject['!' => '+'].split('=').
|
189
|
+
expect(subject['!' => '+'].split('=')).to eq(['%21', '%2B'])
|
190
190
|
end
|
191
191
|
|
192
192
|
it "joins items by '=' signs" do
|
193
|
-
subject['a' => 'b'].
|
193
|
+
expect(subject['a' => 'b']).to eq('a=b')
|
194
194
|
end
|
195
195
|
|
196
196
|
it "joins pairs by '&' signs" do
|
197
|
-
subject['a' => 'b', 'c' => 'd'].
|
197
|
+
expect(subject['a' => 'b', 'c' => 'd']).to eq('a=b&c=d')
|
198
198
|
end
|
199
199
|
|
200
200
|
it "sorts pairs by name then value" do
|
201
|
-
subject['a0' => 'b', 'a' => 'c'].
|
201
|
+
expect(subject['a0' => 'b', 'a' => 'c']).to eq('a=c&a0=b')
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
@@ -207,7 +207,7 @@ describe GoCardless::Utils do
|
|
207
207
|
key = 'testsecret'
|
208
208
|
params = {:test => true}
|
209
209
|
sig = '6e4613b729ce15c288f70e72463739feeb05fc0b89b55d248d7f259b5367148b'
|
210
|
-
GoCardless::Utils.sign_params(params, key).
|
210
|
+
expect(GoCardless::Utils.sign_params(params, key)).to eq(sig)
|
211
211
|
end
|
212
212
|
end
|
213
213
|
end
|
@@ -215,40 +215,44 @@ describe GoCardless::Utils do
|
|
215
215
|
describe "date and time helpers" do
|
216
216
|
describe ".iso_format_time" do
|
217
217
|
it "should work with a Time object" do
|
218
|
-
|
219
|
-
d
|
218
|
+
t = "1st January 2012 00:00 UTC"
|
219
|
+
d = GoCardless::Utils.iso_format_time(Time.parse(t))
|
220
|
+
expect(d).to eq("2012-01-01T00:00:00Z")
|
220
221
|
end
|
221
222
|
|
222
223
|
it "should work with a DateTime object" do
|
223
224
|
d = GoCardless::Utils.iso_format_time(DateTime.parse("1st January 2012"))
|
224
|
-
d.
|
225
|
+
expect(d).to eq("2012-01-01T00:00:00Z")
|
225
226
|
end
|
226
227
|
|
227
228
|
it "should work with a Date object" do
|
228
229
|
d = GoCardless::Utils.iso_format_time(Date.parse("1st January 2012"))
|
229
|
-
d.
|
230
|
+
expect(d).to eq("2012-01-01T00:00:00Z")
|
230
231
|
end
|
231
232
|
|
232
233
|
it "should leave a string untouched" do
|
233
234
|
date = "1st January 2012"
|
234
|
-
GoCardless::Utils.iso_format_time(date).
|
235
|
+
expect(GoCardless::Utils.iso_format_time(date)).to eq(date)
|
235
236
|
end
|
236
237
|
end
|
237
238
|
|
238
239
|
describe ".stringify_times" do
|
239
240
|
it "stringifies time objects" do
|
240
|
-
|
241
|
-
d
|
241
|
+
t = "1st January 2012 00:00 UTC"
|
242
|
+
d = GoCardless::Utils.iso_format_time(Time.parse(t))
|
243
|
+
expect(d).to eq("2012-01-01T00:00:00Z")
|
242
244
|
end
|
243
245
|
|
244
246
|
it "stringifies time values in hashes" do
|
245
|
-
|
246
|
-
d
|
247
|
+
t = "1st Jan 2012 00:00 UTC"
|
248
|
+
d = GoCardless::Utils.stringify_times(:t => Time.parse(t))
|
249
|
+
expect(d).to eq({ :t => "2012-01-01T00:00:00Z" })
|
247
250
|
end
|
248
251
|
|
249
252
|
it "stringifies time values in arrays" do
|
250
|
-
|
251
|
-
d
|
253
|
+
t = "1st Jan 2012 00:00 UTC"
|
254
|
+
d = GoCardless::Utils.stringify_times([Time.parse(t)])
|
255
|
+
expect(d).to eq(["2012-01-01T00:00:00Z"])
|
252
256
|
end
|
253
257
|
end
|
254
258
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gocardless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harry Marr
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-10-
|
12
|
+
date: 2014-10-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth2
|
@@ -17,28 +17,28 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ~>
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '0
|
20
|
+
version: '1.0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '0
|
27
|
+
version: '1.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: multi_json
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '1.
|
34
|
+
version: '1.10'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ~>
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '1.
|
41
|
+
version: '1.10'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,42 +59,42 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - ~>
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '0.
|
62
|
+
version: '0.8'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '0.
|
69
|
+
version: '0.8'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: activesupport
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '3.
|
76
|
+
version: '3.2'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - ~>
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '3.
|
83
|
+
version: '3.2'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: rake
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - ~>
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '10.
|
90
|
+
version: '10.3'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - ~>
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '10.
|
97
|
+
version: '10.3'
|
98
98
|
description: A Ruby wrapper for the GoCardless API
|
99
99
|
email:
|
100
100
|
- developers@gocardless.com
|
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
159
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.4.
|
160
|
+
rubygems_version: 2.4.1
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: Ruby wrapper for the GoCardless API
|
@@ -173,3 +173,4 @@ test_files:
|
|
173
173
|
- spec/subscription_spec.rb
|
174
174
|
- spec/user_spec.rb
|
175
175
|
- spec/utils_spec.rb
|
176
|
+
has_rdoc:
|