gocardless 1.11.2 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
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.stub(:parsed).and_return(data)
6
+ allow(response).to receive(:parsed).and_return(data)
7
7
 
8
8
  token = client.instance_variable_get(:@access_token)
9
- token.stub(:get).and_return response
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}?").should be_truthy }
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}?").should be_falsey }
25
+ specify { expect(object.send("#{status}?")).to be_falsey }
26
26
  end
27
27
  end
28
28
  end
@@ -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.should_receive(:api_put).with('/subscriptions/009988/cancel')
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.should == "First Last" }
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.should == "First" }
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.should == "Last" }
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.should == "" }
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").should == "ATestString"
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").should == "a_test_string"
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").should == "desk"
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").should == "cactus"
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').should be_truthy
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').should be_falsey
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.should == 3
47
- keys.should include :string
48
- keys.should include :'123'
49
- keys.should include :symbol
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.should == ['string']
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).should == 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).should == {:x => 1}
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.should == [:string]
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[""].should == ""
84
+ expect(subject[""]).to eq("")
85
85
  end
86
86
 
87
87
  it "doesn't encode lowercase alpha characters" do
88
- subject["abcxyz"].should == "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"].should == "ABCXYZ"
92
+ expect(subject["ABCXYZ"]).to eq("ABCXYZ")
93
93
  end
94
94
 
95
95
  it "doesn't encode digits" do
96
- subject["1234567890"].should == "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["-._~"].should == "-._~"
100
+ expect(subject["-._~"]).to eq("-._~")
101
101
  end
102
102
 
103
103
  it "encodes non-ascii alpha characters" do
104
- subject["å"].should == "%C3%A5"
104
+ expect(subject["å"]).to eq("%C3%A5")
105
105
  end
106
106
 
107
107
  it "encodes reserved ascii characters" do
108
- subject[" !\"\#$%&'()"].should == "%20%21%22%23%24%25%26%27%28%29"
109
- subject["*+,/{|}:;"].should == "%2A%2B%2C%2F%7B%7C%7D%3A%3B"
110
- subject["<=>?@[\\]^`"].should == "%3C%3D%3E%3F%40%5B%5C%5D%5E%60"
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["支払い"].should == "%E6%94%AF%E6%89%95%E3%81%84"
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[{}].should == []
122
+ expect(subject[{}]).to eq([])
123
123
  end
124
124
 
125
125
  it "converts hashes to key-value arrays" do
126
- subject['a' => 'b'].should == [['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].should == [['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].should == date
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].should == [['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']].should == [['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' => []].should == []
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.should include ['a[]', 'b']
153
- result.should include ['a[]', 'c']
154
- result.length.should == 2
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']]].should == [['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'}].should == [['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.should include ['a[b]', 'c']
168
- result.should include ['a[d]', 'e']
169
- result.length.should == 2
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'}}].should == [['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']}].should == [['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'}]].should == [['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('=').should == ['%21', '%2B']
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'].should == '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'].should == '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'].should == 'a=c&a0=b'
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).should == sig
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
- d = GoCardless::Utils.iso_format_time(Time.parse("1st January 2012"))
219
- d.should == "2012-01-01T00:00:00Z"
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.should == "2012-01-01T00:00:00Z"
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.should == "2012-01-01T00:00:00Z"
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).should == 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
- d = GoCardless::Utils.stringify_times(Time.parse("1st Jan 2012"))
241
- d.should == "2012-01-01T00:00:00Z"
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
- d = GoCardless::Utils.stringify_times(:t => Time.parse("1st Jan 2012"))
246
- d.should == { :t => "2012-01-01T00:00:00Z" }
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
- d = GoCardless::Utils.stringify_times([Time.parse("1st Jan 2012")])
251
- d.should == ["2012-01-01T00:00:00Z"]
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.11.2
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-27 00:00:00.000000000 Z
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.7'
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.7'
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.0'
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.0'
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.7'
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.7'
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.1'
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.1'
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.0'
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.0'
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.2
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: