gocardless 1.8.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ed8ff8ba2e1109b3ec370bd8c52e2d1f2dc0ae70
4
+ data.tar.gz: 4321b58cabecafefbf4a5257ae6ee6e218d49364
5
+ SHA512:
6
+ metadata.gz: f8594375ca0b9ea638fedf5d2fc4ef137b81b791e2248307277eb4459e941b1606abd49f53e86a4829acd2fd3f09d72ca5a3fd5dbaadda148784d65df24d6a0e
7
+ data.tar.gz: c92b6f3708f2595533dcc368f904fbd83593f8eabf7059b8b9955cfe5bb964792335e584fd129da8b150773f1c0e9a317e70948a374974682ec12c69d23bd214
@@ -1,13 +1,13 @@
1
1
  script: "rake spec"
2
2
  rvm:
3
+ - 2.1.0
3
4
  - 2.0.0
4
5
  - 1.9.3
5
6
  - 1.9.2
6
7
  - 1.8.7
7
8
  - jruby-18mode
8
9
  - jruby-19mode
9
- - rbx-18mode
10
- - ruby-head
10
+ - rbx-2
11
11
  - ree
12
12
  notifications:
13
13
  email:
@@ -1,3 +1,10 @@
1
+ ## 1.9.0 - May 23, 2014
2
+
3
+ - Add ability to refund bills
4
+ - Add ability to cancel bills
5
+ - Add Payout API support
6
+ - Stop using the deprecated OpenSSL::Digest::Digest
7
+
1
8
  ## 1.8.0 - June 12, 2013
2
9
 
3
10
  - Add Client#api_delete
data/README.md CHANGED
@@ -11,5 +11,4 @@ you want to support multiple merchant accounts, see the
11
11
  The full API reference is available at on
12
12
  [rubydoc.info](http://rubydoc.info/github/gocardless/gocardless-ruby/master/frames).
13
13
 
14
- [![Build Status](https://secure.travis-ci.org/gocardless/gocardless-ruby.png?branch=master)](http://travis-ci.org/gocardless/gocardless-ruby)
15
-
14
+ [![Build Status](https://secure.travis-ci.org/gocardless/gocardless-ruby.png?branch=master)](http://travis-ci.org/gocardless/gocardless-ruby) [![Gem Version](https://badge.fury.io/rb/gocardless.svg)](http://badge.fury.io/rb/gocardless)
@@ -4,9 +4,8 @@ Gem::Specification.new do |gem|
4
4
  gem.add_runtime_dependency 'oauth2', '~> 0.7'
5
5
  gem.add_runtime_dependency 'multi_json', '~> 1.0'
6
6
 
7
- gem.add_development_dependency 'rspec', '~> 2.6'
8
- gem.add_development_dependency 'mocha', '~> 0.9.12'
9
- gem.add_development_dependency 'yard', '~> 0.7.3'
7
+ gem.add_development_dependency 'rspec', '~> 2.13'
8
+ gem.add_development_dependency 'yard', '~> 0.7'
10
9
  gem.add_development_dependency 'activesupport', '~> 3.1'
11
10
  gem.add_development_dependency 'rake', '~> 10.0'
12
11
 
@@ -20,4 +19,5 @@ Gem::Specification.new do |gem|
20
19
  gem.summary = %q{Ruby wrapper for the GoCardless API}
21
20
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
21
  gem.version = GoCardless::VERSION.dup
22
+ gem.licenses = ['MIT']
23
23
  end
@@ -10,6 +10,7 @@ module GoCardless
10
10
  require 'gocardless/payment'
11
11
  require 'gocardless/merchant'
12
12
  require 'gocardless/client'
13
+ require 'gocardless/payout'
13
14
 
14
15
  class << self
15
16
  attr_accessor :environment
@@ -17,7 +17,7 @@ module GoCardless
17
17
  # @return [String] the ID of the bill's source (eg subscription, pre_authorization)
18
18
  attr_accessor :source_id
19
19
 
20
- reference_accessor :merchant_id, :user_id, :payment_id
20
+ reference_accessor :merchant_id, :user_id, :payment_id, :payout_id
21
21
  date_accessor :created_at, :paid_at
22
22
 
23
23
  def source
@@ -40,6 +40,20 @@ module GoCardless
40
40
  client.api_post(path)
41
41
  end
42
42
 
43
+ def cancel!
44
+ path = self.class.endpoint.gsub(':id', id.to_s) + '/cancel'
45
+ client.api_put(path)
46
+ end
47
+
48
+ # The ability to refund a payment is disabled by default.
49
+ #
50
+ # Please contact help@gocardless.com if you require access to
51
+ # the refunds API endpoint.
52
+ def refund!
53
+ path = self.class.endpoint.gsub(':id', id.to_s) + '/refund'
54
+ client.api_post(path)
55
+ end
56
+
43
57
  def save
44
58
  save_data({
45
59
  :bill => {
@@ -195,7 +195,8 @@ module GoCardless
195
195
  # Create a new bill under a given pre-authorization
196
196
  # @see PreAuthorization#create_bill
197
197
  #
198
- # @param [Hash] attrs must include +:pre_authorization_id+ and +:amount+
198
+ # @param [Hash] attrs must include +:source_id+ (the id of the
199
+ # pre_authorization you want to bill from) and +:amount+
199
200
  # @return [Bill] the created bill object
200
201
  def create_bill(attrs)
201
202
  Bill.new_with_client(self, attrs).save
@@ -0,0 +1,11 @@
1
+ module GoCardless
2
+ class Payout < Resource
3
+ self.endpoint = '/payouts/:id'
4
+
5
+ attr_accessor :amount,
6
+ :bank_reference,
7
+ :transaction_fees
8
+
9
+ date_accessor :created_at, :paid_at
10
+ end
11
+ end
@@ -90,7 +90,7 @@ module GoCardless
90
90
  # @return [String] the resulting signature
91
91
  def sign_params(params, key)
92
92
  msg = Utils.normalize_params(params)
93
- digest = OpenSSL::Digest::Digest.new('sha256')
93
+ digest = OpenSSL::Digest.new('sha256')
94
94
  OpenSSL::HMAC.hexdigest(digest, key, msg)
95
95
  end
96
96
 
@@ -1,3 +1,3 @@
1
1
  module GoCardless
2
- VERSION = '1.8.0'.freeze
2
+ VERSION = '1.9.0'.freeze
3
3
  end
@@ -28,56 +28,68 @@ describe GoCardless::Bill do
28
28
 
29
29
  it "should be able to be retried" do
30
30
  b = GoCardless::Bill.new(:id => 123)
31
- @client.expects(:api_post).with('/bills/123/retry')
31
+ @client.should_receive(:api_post).with('/bills/123/retry')
32
32
  b.retry!
33
33
  end
34
34
 
35
+ it "should be able to be cancelled" do
36
+ b = GoCardless::Bill.new(:id => 123)
37
+ @client.should_receive(:api_put).with('/bills/123/cancel')
38
+ b.cancel!
39
+ end
40
+
41
+ it "should be able to be refunded" do
42
+ b = GoCardless::Bill.new(:id => 123)
43
+ @client.should_receive(:api_post).with('/bills/123/refund')
44
+ b.refund!
45
+ end
46
+
35
47
  describe "pending query method" do
36
- it "returns true when the subscription status is pending" do
48
+ it "and_return true when the subscription status is pending" do
37
49
  GoCardless::Bill.new(:status => 'pending').pending?.should be_true
38
50
  end
39
51
 
40
- it "returns false otherwise" do
52
+ it "and_return false otherwise" do
41
53
  GoCardless::Bill.new.pending?.should be_false
42
54
  end
43
55
  end
44
56
 
45
57
  describe "paid query method" do
46
- it "returns true when the subscription status is paid" do
58
+ it "and_return true when the subscription status is paid" do
47
59
  GoCardless::Bill.new(:status => 'paid').paid?.should be_true
48
60
  end
49
61
 
50
- it "returns false otherwise" do
62
+ it "and_return false otherwise" do
51
63
  GoCardless::Bill.new.paid?.should be_false
52
64
  end
53
65
  end
54
66
 
55
67
  describe "failed query method" do
56
- it "returns true when the subscription status is failed" do
68
+ it "and_return true when the subscription status is failed" do
57
69
  GoCardless::Bill.new(:status => 'failed').failed?.should be_true
58
70
  end
59
71
 
60
- it "returns false otherwise" do
72
+ it "and_return false otherwise" do
61
73
  GoCardless::Bill.new.failed?.should be_false
62
74
  end
63
75
  end
64
76
 
65
77
  describe "withdrawn query method" do
66
- it "returns true when the subscription status is withdrawn" do
78
+ it "and_return true when the subscription status is withdrawn" do
67
79
  GoCardless::Bill.new(:status => 'withdrawn').withdrawn?.should be_true
68
80
  end
69
81
 
70
- it "returns false otherwise" do
82
+ it "and_return false otherwise" do
71
83
  GoCardless::Bill.new.withdrawn?.should be_false
72
84
  end
73
85
  end
74
86
 
75
87
  describe "refunded query method" do
76
- it "returns true when the subscription status is refunded" do
88
+ it "and_return true when the subscription status is refunded" do
77
89
  GoCardless::Bill.new(:status => 'refunded').refunded?.should be_true
78
90
  end
79
91
 
80
- it "returns false otherwise" do
92
+ it "and_return false otherwise" do
81
93
  GoCardless::Bill.new.refunded?.should be_false
82
94
  end
83
95
  end
@@ -8,17 +8,17 @@ describe GoCardless::Client do
8
8
  end
9
9
 
10
10
  describe ".base_url" do
11
- it "returns the correct url for the production environment" do
11
+ it "and_return the correct url for the production environment" do
12
12
  GoCardless.environment = :production
13
13
  GoCardless::Client.base_url.should == 'https://gocardless.com'
14
14
  end
15
15
 
16
- it "returns the correct url for the sandbox environment" do
16
+ it "and_return the correct url for the sandbox environment" do
17
17
  GoCardless.environment = :sandbox
18
18
  GoCardless::Client.base_url.should == 'https://sandbox.gocardless.com'
19
19
  end
20
20
 
21
- it "returns the correct url when it's set manually" do
21
+ it "and_return the correct url when it's set manually" do
22
22
  GoCardless::Client.base_url = 'https://abc.gocardless.com'
23
23
  GoCardless::Client.base_url.should == 'https://abc.gocardless.com'
24
24
  end
@@ -38,8 +38,8 @@ describe GoCardless::Client do
38
38
  end
39
39
 
40
40
  it "does not raise an error if the credentials are provided as environment variables" do
41
- ENV.expects(:[]).with('GOCARDLESS_APP_ID').returns(@app_id)
42
- ENV.expects(:[]).with('GOCARDLESS_APP_SECRET').returns(@app_secret)
41
+ ENV.should_receive(:[]).with('GOCARDLESS_APP_ID').and_return(@app_id)
42
+ ENV.should_receive(:[]).with('GOCARDLESS_APP_SECRET').and_return(@app_secret)
43
43
 
44
44
  GoCardless::Client.new
45
45
  end
@@ -104,14 +104,14 @@ describe GoCardless::Client do
104
104
  stub(:params => {'scope' => 'manage_merchant:x'}, :token => 'abc')
105
105
  end
106
106
 
107
- before { oauth_client.auth_code.stubs(:get_token).returns(fake_token) }
107
+ before { oauth_client.auth_code.stub(:get_token).and_return(fake_token) }
108
108
 
109
109
  it "calls correct method with correct args" do
110
110
  auth_code = 'fakecode'
111
111
 
112
- oauth_client.auth_code.expects(:get_token).with(
113
- auth_code, has_entry(:redirect_uri => @redirect_uri)
114
- ).returns(fake_token)
112
+ oauth_client.auth_code.should_receive(:get_token).with(
113
+ auth_code, hash_including(:redirect_uri => @redirect_uri)
114
+ ).and_return(fake_token)
115
115
 
116
116
  @client.fetch_access_token(auth_code, {:redirect_uri => @redirect_uri})
117
117
  end
@@ -140,13 +140,13 @@ describe GoCardless::Client do
140
140
  @client.access_token.should == 'TOKEN123 a:1 b:2'
141
141
  end
142
142
 
143
- it "returns nil when there's no token" do
143
+ it "and_return nil when there's no token" do
144
144
  @client.access_token.should be_nil
145
145
  end
146
146
  end
147
147
 
148
148
  describe "#access_token=" do
149
- before { @client.stubs(:warn) }
149
+ before { @client.stub(:warn) }
150
150
 
151
151
  it "deserializes access token correctly" do
152
152
  @client.access_token = 'TOKEN123 a:1 b:2'
@@ -161,12 +161,12 @@ describe GoCardless::Client do
161
161
  end
162
162
 
163
163
  it "issues a deprecation warning when the scope is present" do
164
- @client.expects(:warn)
164
+ @client.should_receive(:warn)
165
165
  @client.access_token = 'TOKEN123 manage_merchant:xyz'
166
166
  end
167
167
 
168
168
  it "doesn't issue a deprecation warning when the scope is missing" do
169
- @client.expects(:warn).never
169
+ @client.should_receive(:warn).never
170
170
  @client.access_token = 'TOKEN123'
171
171
  end
172
172
 
@@ -183,8 +183,8 @@ describe GoCardless::Client do
183
183
  @client.access_token = 'TOKEN123'
184
184
  token = @client.instance_variable_get(:@access_token)
185
185
  r = mock
186
- r.stubs(:parsed)
187
- token.expects(:get).with { |p,o| p =~ %r|/api/v1/test| }.returns(r)
186
+ r.stub(:parsed)
187
+ token.should_receive(:get).with { |p,o| p =~ %r|/api/v1/test| }.and_return(r)
188
188
  @client.api_get('/test')
189
189
  end
190
190
 
@@ -198,8 +198,8 @@ describe GoCardless::Client do
198
198
  @client.access_token = 'TOKEN123'
199
199
  token = @client.instance_variable_get(:@access_token)
200
200
  r = mock
201
- r.stubs(:parsed)
202
- token.expects(:post).with { |p,opts| opts[:body] == '{"a":1}' }.returns(r)
201
+ r.stub(:parsed)
202
+ token.should_receive(:post).with { |p,opts| opts[:body] == '{"a":1}' }.and_return(r)
203
203
  @client.api_post('/test', {:a => 1})
204
204
  end
205
205
 
@@ -213,8 +213,8 @@ describe GoCardless::Client do
213
213
  @client.access_token = 'TOKEN123'
214
214
  token = @client.instance_variable_get(:@access_token)
215
215
  r = mock
216
- r.stubs(:parsed)
217
- token.expects(:delete).with { |p,opts| opts[:body] == '{"a":1}' }.returns(r)
216
+ r.stub(:parsed)
217
+ token.should_receive(:delete).with { |p,opts| opts[:body] == '{"a":1}' }.and_return(r)
218
218
  @client.api_delete('/test', {:a => 1})
219
219
  end
220
220
 
@@ -228,13 +228,13 @@ describe GoCardless::Client do
228
228
  @client.access_token = 'TOKEN'
229
229
  @client.merchant_id = '123'
230
230
  response = mock
231
- response.expects(:parsed)
231
+ response.should_receive(:parsed)
232
232
 
233
233
  token = @client.instance_variable_get(:@access_token)
234
234
  merchant_url = '/api/v1/merchants/123'
235
- token.expects(:get).with { |p,o| p == merchant_url }.returns response
235
+ token.should_receive(:get).with { |p,o| p == merchant_url }.and_return response
236
236
 
237
- GoCardless::Merchant.stubs(:new_with_client)
237
+ GoCardless::Merchant.stub(:new_with_client)
238
238
 
239
239
  @client.merchant
240
240
  end
@@ -243,10 +243,10 @@ describe GoCardless::Client do
243
243
  @client.access_token = 'TOKEN'
244
244
  @client.merchant_id = '123'
245
245
  response = mock
246
- response.expects(:parsed).returns({:name => 'test', :id => 123})
246
+ response.should_receive(:parsed).and_return({:name => 'test', :id => 123})
247
247
 
248
248
  token = @client.instance_variable_get(:@access_token)
249
- token.expects(:get).returns response
249
+ token.should_receive(:get).and_return response
250
250
 
251
251
  merchant = @client.merchant
252
252
  merchant.should be_an_instance_of GoCardless::Merchant
@@ -257,7 +257,7 @@ describe GoCardless::Client do
257
257
 
258
258
  %w{subscription pre_authorization user bill payment}.each do |resource|
259
259
  describe "##{resource}" do
260
- it "returns the correct #{GoCardless::Utils.camelize(resource)} object" do
260
+ it "and_return the correct #{GoCardless::Utils.camelize(resource)} object" do
261
261
  @client.access_token = 'TOKEN'
262
262
  @client.merchant_id = '123'
263
263
  stub_get(@client, {:id => 123})
@@ -299,7 +299,7 @@ describe GoCardless::Client do
299
299
  end
300
300
 
301
301
  it "doesn't confirm the resource when the signature is invalid" do
302
- @client.expects(:request).never
302
+ @client.should_receive(:request).never
303
303
  @client.confirm_resource({:signature => 'xxx'}.merge(@params)) rescue nil
304
304
  end
305
305
 
@@ -311,14 +311,14 @@ describe GoCardless::Client do
311
311
 
312
312
  it "confirms the resource when the signature is valid" do
313
313
  # Once for confirm, once to fetch result
314
- @client.expects(:request).twice.returns(stub(:parsed => {}))
314
+ @client.should_receive(:request).twice.and_return(stub(:parsed => {}))
315
315
  @client.confirm_resource(@client.send(:sign_params, @params))
316
316
  end
317
317
 
318
- it "returns the correct object when the signature is valid" do
319
- @client.stubs(:request).returns(stub(:parsed => {}))
318
+ it "and_return the correct object when the signature is valid" do
319
+ @client.stub(:request).and_return(stub(:parsed => {}))
320
320
  subscription = GoCardless::Subscription.new_with_client @client
321
- GoCardless::Subscription.expects(:find_with_client).returns subscription
321
+ GoCardless::Subscription.should_receive(:find_with_client).and_return subscription
322
322
 
323
323
  # confirm_resource should use the Subcription class because
324
324
  # the :response_type is set to subscription
@@ -327,9 +327,9 @@ describe GoCardless::Client do
327
327
  end
328
328
 
329
329
  it "includes valid http basic credentials" do
330
- GoCardless::Subscription.stubs(:find_with_client)
330
+ GoCardless::Subscription.stub(:find_with_client)
331
331
  auth = 'Basic YWJjOnh5eg=='
332
- @client.expects(:request).once.with do |type, path, opts|
332
+ @client.should_receive(:request).once.with do |type, path, opts|
333
333
  opts.should include :headers
334
334
  opts[:headers].should include 'Authorization'
335
335
  opts[:headers]['Authorization'].should == auth
@@ -338,8 +338,8 @@ describe GoCardless::Client do
338
338
  end
339
339
 
340
340
  it "works with string params" do
341
- @client.stubs(:request)
342
- GoCardless::Subscription.stubs(:find_with_client)
341
+ @client.stub(:request)
342
+ GoCardless::Subscription.stub(:find_with_client)
343
343
  params = Hash[@params.dup.map { |k,v| [k.to_s, v] }]
344
344
  params.keys.each { |p| p.should be_a String }
345
345
  # No ArgumentErrors should be raised
@@ -377,20 +377,20 @@ describe GoCardless::Client do
377
377
  end
378
378
 
379
379
  it "rejects other params not required for the signature" do
380
- @client.expects(:signature_valid?).returns(true).with(hash) do |hash|
380
+ @client.should_receive(:signature_valid?) do |hash|
381
381
  !hash.keys.include?(:foo) && !hash.keys.include?('foo')
382
- end
382
+ end.and_return(true)
383
383
 
384
384
  params = @client.send(:sign_params, @params).merge('foo' => 'bar')
385
385
  @client.response_params_valid?(params)
386
386
  end
387
387
 
388
- it "returns false when the signature is invalid" do
388
+ it "and_return false when the signature is invalid" do
389
389
  params = {:signature => 'xxx'}.merge(@params)
390
390
  @client.response_params_valid?(params).should be_false
391
391
  end
392
392
 
393
- it "returns true when the signature is valid" do
393
+ it "and_return true when the signature is valid" do
394
394
  params = @client.send(:sign_params, @params)
395
395
  @client.response_params_valid?(params).should be_true
396
396
  end
@@ -468,7 +468,7 @@ describe GoCardless::Client do
468
468
  it "should include a timestamp" do
469
469
  # Time.now returning Pacific time
470
470
  time = Time.parse('Sat Jan 01 2011 00:00:00 -0800')
471
- Time.expects(:now).returns time
471
+ Time.should_receive(:now).and_return time
472
472
  params = get_params(@client.send(:new_limit_url, :subscription, :x => 1))
473
473
  # Check that timezone is ISO formatted UTC
474
474
  params['timestamp'].should == "2011-01-01T08:00:00Z"
@@ -476,7 +476,7 @@ describe GoCardless::Client do
476
476
  end
477
477
 
478
478
  describe "#merchant_id" do
479
- it "returns the merchant id when an access token is set" do
479
+ it "and_return the merchant id when an access token is set" do
480
480
  @client.merchant_id = '123'
481
481
  @client.send(:merchant_id).should == '123'
482
482
  end
@@ -489,12 +489,12 @@ describe GoCardless::Client do
489
489
  end
490
490
 
491
491
  describe "#webhook_valid?" do
492
- it "returns false when the webhook signature is invalid" do
492
+ it "and_return false when the webhook signature is invalid" do
493
493
  @client.webhook_valid?({:some => 'stuff', :signature => 'invalid'}).
494
494
  should be_false
495
495
  end
496
496
 
497
- it "returns true when the webhook signature is valid" do
497
+ it "and_return true when the webhook signature is valid" do
498
498
  valid_signature = '175e814f0f64e5e86d41fb8fe06a857cedda715a96d3dc3d885e6d97dbeb7e49'
499
499
  @client.webhook_valid?({:some => 'stuff', :signature => valid_signature}).
500
500
  should be_true
@@ -502,13 +502,13 @@ describe GoCardless::Client do
502
502
  end
503
503
 
504
504
  describe "base_url" do
505
- it "returns a custom base URL when one has been set" do
505
+ it "and_return a custom base URL when one has been set" do
506
506
  @client.base_url = 'http://test.com/'
507
507
  @client.base_url.should == 'http://test.com/'
508
508
  end
509
509
 
510
- it "returns the default value when base_url is not set for the instance" do
511
- GoCardless::Client.stubs(:base_url => 'http://gc.com/')
510
+ it "and_return the default value when base_url is not set for the instance" do
511
+ GoCardless::Client.stub(:base_url => 'http://gc.com/')
512
512
  @client.base_url.should == 'http://gc.com/'
513
513
  end
514
514
  end
@@ -10,7 +10,7 @@ describe GoCardless do
10
10
 
11
11
  describe ".account_details=" do
12
12
  it "creates a Client instance" do
13
- GoCardless::Client.expects :new
13
+ GoCardless::Client.should_receive :new
14
14
  subject.account_details = @details
15
15
  end
16
16
 
@@ -26,7 +26,7 @@ describe GoCardless do
26
26
  %w(new_subscription_url new_pre_authorization_url new_bill_url confirm_resource webhook_valid?).each do |name|
27
27
  it "#{name} delegates to @client" do
28
28
  subject.account_details = @details
29
- subject.instance_variable_get(:@client).expects(name.to_sym)
29
+ subject.instance_variable_get(:@client).should_receive(name.to_sym)
30
30
  subject.send(name)
31
31
  end
32
32
 
@@ -11,46 +11,46 @@ describe GoCardless::PreAuthorization do
11
11
 
12
12
  it "should be cancellable" do
13
13
  s = GoCardless::PreAuthorization.new_with_client(@client, :id => '009988')
14
- @client.expects(:api_put).with('/pre_authorizations/009988/cancel')
14
+ @client.should_receive(:api_put).with('/pre_authorizations/009988/cancel')
15
15
  s.cancel!
16
16
  end
17
17
 
18
18
  describe "inactive query method" do
19
- it "returns true when the subscription status is inactive" do
19
+ it "and_return true when the subscription status is inactive" do
20
20
  GoCardless::PreAuthorization.new(:status => 'inactive').inactive?.should be_true
21
21
  end
22
22
 
23
- it "returns false otherwise" do
23
+ it "and_return false otherwise" do
24
24
  GoCardless::PreAuthorization.new.inactive?.should be_false
25
25
  end
26
26
  end
27
27
 
28
28
  describe "active query method" do
29
- it "returns true when the subscription status is active" do
29
+ it "and_return true when the subscription status is active" do
30
30
  GoCardless::PreAuthorization.new(:status => 'active').active?.should be_true
31
31
  end
32
32
 
33
- it "returns false otherwise" do
33
+ it "and_return false otherwise" do
34
34
  GoCardless::PreAuthorization.new.active?.should be_false
35
35
  end
36
36
  end
37
37
 
38
38
  describe "cancelled query method" do
39
- it "returns true when the subscription status is cancelled" do
39
+ it "and_return true when the subscription status is cancelled" do
40
40
  GoCardless::PreAuthorization.new(:status => 'cancelled').cancelled?.should be_true
41
41
  end
42
42
 
43
- it "returns false otherwise" do
43
+ it "and_return false otherwise" do
44
44
  GoCardless::PreAuthorization.new.cancelled?.should be_false
45
45
  end
46
46
  end
47
47
 
48
48
  describe "expired query method" do
49
- it "returns true when the subscription status is expired" do
49
+ it "and_return true when the subscription status is expired" do
50
50
  GoCardless::PreAuthorization.new(:status => 'expired').expired?.should be_true
51
51
  end
52
52
 
53
- it "returns false otherwise" do
53
+ it "and_return false otherwise" do
54
54
  GoCardless::PreAuthorization.new.expired?.should be_false
55
55
  end
56
56
  end
@@ -64,7 +64,7 @@ describe GoCardless::Resource do
64
64
  self.endpoint = '/test/:id'
65
65
  end
66
66
  mock_client = mock
67
- mock_client.expects(:api_get).returns({:id => 123})
67
+ mock_client.should_receive(:api_get).and_return({:id => 123})
68
68
  resource = test_resource.find_with_client(mock_client, 123)
69
69
  resource.should be_a test_resource
70
70
  resource.id.should == 123
@@ -76,8 +76,8 @@ describe GoCardless::Resource do
76
76
  test_resource = Class.new(GoCardless::Resource) do
77
77
  self.endpoint = '/test/:id'
78
78
  end
79
- GoCardless.stubs(:client => mock)
80
- test_resource.expects(:find_with_client).with(GoCardless.client, 1)
79
+ GoCardless.stub(:client => mock)
80
+ test_resource.should_receive(:find_with_client).with(GoCardless.client, 1)
81
81
  test_resource.find(1)
82
82
  unset_ivar GoCardless, :client
83
83
  end
@@ -214,28 +214,28 @@ describe GoCardless::Resource do
214
214
  client = mock
215
215
  data = {:x => 1, :y => 2}
216
216
  resource = @test_resource.new_with_client(client, data)
217
- client.expects(:api_post).with(anything, data)
217
+ client.should_receive(:api_post).with(anything, data)
218
218
  resource.save
219
219
  end
220
220
 
221
221
  it "sends the correct path" do
222
222
  client = mock
223
223
  resource = @test_resource.new_with_client(client)
224
- client.expects(:api_post).with('/test', anything)
224
+ client.should_receive(:api_post).with('/test', anything)
225
225
  resource.save
226
226
  end
227
227
 
228
228
  it "POSTs when not persisted" do
229
229
  client = mock
230
230
  resource = @test_resource.new_with_client(client)
231
- client.expects(:api_post)
231
+ client.should_receive(:api_post)
232
232
  resource.save
233
233
  end
234
234
 
235
235
  it "PUTs when already persisted" do
236
236
  client = mock
237
237
  resource = @test_resource.new_with_client(client, :id => 1)
238
- client.expects(:api_put)
238
+ client.should_receive(:api_put)
239
239
  resource.save
240
240
  end
241
241
  end
@@ -246,7 +246,7 @@ describe GoCardless::Resource do
246
246
  creatable
247
247
  end
248
248
 
249
- client = mock('client') { stubs :api_post }
249
+ client = double('client', :api_post => nil)
250
250
  test_resource.new_with_client(client).save
251
251
  end
252
252
 
@@ -256,7 +256,7 @@ describe GoCardless::Resource do
256
256
  updatable
257
257
  end
258
258
 
259
- client = mock('client') { stubs :api_put }
259
+ client = double('client', :api_put => nil)
260
260
  test_resource.new_with_client(client, :id => 1).save
261
261
  end
262
262
 
@@ -357,14 +357,14 @@ describe GoCardless::Resource do
357
357
 
358
358
  it "use the correct uri path" do
359
359
  client = mock()
360
- client.expects(:api_get).with('/api/bills/', anything).returns([])
360
+ client.should_receive(:api_get).with('/api/bills/', anything).and_return([])
361
361
  r = @test_resource.new_with_client(client, @attrs)
362
362
  r.bills
363
363
  end
364
364
 
365
365
  it "strips the api prefix from the path" do
366
366
  client = mock()
367
- client.expects(:api_get).with('/bills/', anything).returns([])
367
+ client.should_receive(:api_get).with('/bills/', anything).and_return([])
368
368
  uris = {'bills' => 'https://test.com/api/v123/bills/'}
369
369
  r = @test_resource.new_with_client(client, 'sub_resource_uris' => uris)
370
370
  r.bills
@@ -372,7 +372,7 @@ describe GoCardless::Resource do
372
372
 
373
373
  it "use the correct query string params" do
374
374
  client = mock()
375
- client.expects(:api_get).with(anything, 'merchant_id' => '1').returns([])
375
+ client.should_receive(:api_get).with(anything, 'merchant_id' => '1').and_return([])
376
376
  r = @test_resource.new_with_client(client, @attrs)
377
377
  r.bills
378
378
  end
@@ -380,7 +380,7 @@ describe GoCardless::Resource do
380
380
  it "adds provided params to existing query string params" do
381
381
  client = mock()
382
382
  params = { 'merchant_id' => '1', :amount => '10.00' }
383
- client.expects(:api_get).with(anything, params).returns([])
383
+ client.should_receive(:api_get).with(anything, params).and_return([])
384
384
  r = @test_resource.new_with_client(client, @attrs)
385
385
  r.bills(:amount => '10.00')
386
386
  end
@@ -388,7 +388,7 @@ describe GoCardless::Resource do
388
388
  it "adds provided params when there are no existing query string params" do
389
389
  client = mock()
390
390
  params = { :source_id => 'xxx' }
391
- client.expects(:api_get).with(anything, params).returns([])
391
+ client.should_receive(:api_get).with(anything, params).and_return([])
392
392
  r = @test_resource.new_with_client(client, {
393
393
  'sub_resource_uris' => {
394
394
  'bills' => 'https://test.com/merchants/1/bills'
@@ -1,17 +1,12 @@
1
- require 'mocha'
2
1
  require 'active_support/hash_with_indifferent_access'
3
2
  require 'gocardless'
4
3
 
5
- RSpec.configure do |config|
6
- config.mock_with :mocha
7
- end
8
-
9
4
  def stub_get(client, data)
10
5
  response = mock
11
- response.stubs(:parsed).returns(data)
6
+ response.stub(:parsed).and_return(data)
12
7
 
13
8
  token = client.instance_variable_get(:@access_token)
14
- token.stubs(:get).returns response
9
+ token.stub(:get).and_return response
15
10
  end
16
11
 
17
12
  def unset_ivar(obj, var)
@@ -11,46 +11,46 @@ describe GoCardless::Subscription do
11
11
 
12
12
  it "should be cancellable" do
13
13
  s = GoCardless::Subscription.new_with_client(@client, :id => '009988')
14
- @client.expects(:api_put).with('/subscriptions/009988/cancel')
14
+ @client.should_receive(:api_put).with('/subscriptions/009988/cancel')
15
15
  s.cancel!
16
16
  end
17
17
 
18
18
  describe "inactive query method" do
19
- it "returns true when the subscription status is inactive" do
19
+ it "and_return true when the subscription status is inactive" do
20
20
  GoCardless::Subscription.new(:status => 'inactive').inactive?.should be_true
21
21
  end
22
22
 
23
- it "returns false otherwise" do
23
+ it "and_return false otherwise" do
24
24
  GoCardless::Subscription.new.inactive?.should be_false
25
25
  end
26
26
  end
27
27
 
28
28
  describe "active query method" do
29
- it "returns true when the subscription status is active" do
29
+ it "and_return true when the subscription status is active" do
30
30
  GoCardless::Subscription.new(:status => 'active').active?.should be_true
31
31
  end
32
32
 
33
- it "returns false otherwise" do
33
+ it "and_return false otherwise" do
34
34
  GoCardless::Subscription.new.active?.should be_false
35
35
  end
36
36
  end
37
37
 
38
38
  describe "cancelled query method" do
39
- it "returns true when the subscription status is cancelled" do
39
+ it "and_return true when the subscription status is cancelled" do
40
40
  GoCardless::Subscription.new(:status => 'cancelled').cancelled?.should be_true
41
41
  end
42
42
 
43
- it "returns false otherwise" do
43
+ it "and_return false otherwise" do
44
44
  GoCardless::Subscription.new.cancelled?.should be_false
45
45
  end
46
46
  end
47
47
 
48
48
  describe "expired query method" do
49
- it "returns true when the subscription status is expired" do
49
+ it "and_return true when the subscription status is expired" do
50
50
  GoCardless::Subscription.new(:status => 'expired').expired?.should be_true
51
51
  end
52
52
 
53
- it "returns false otherwise" do
53
+ it "and_return false otherwise" do
54
54
  GoCardless::Subscription.new.expired?.should be_false
55
55
  end
56
56
  end
@@ -108,7 +108,7 @@ describe GoCardless::Utils do
108
108
  describe ".flatten_params" do
109
109
  subject { GoCardless::Utils.method(:flatten_params) }
110
110
 
111
- it "returns an empty array when provided with an empty hash" do
111
+ it "and_return an empty array when provided with an empty hash" do
112
112
  subject[{}].should == []
113
113
  end
114
114
 
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gocardless
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.8.0
4
+ version: 1.9.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Harry Marr
@@ -10,120 +9,92 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-06-12 00:00:00.000000000 Z
12
+ date: 2014-05-23 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
- version_requirements: !ruby/object:Gem::Requirement
15
+ name: oauth2
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - ~>
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0.7'
21
- none: false
22
- name: oauth2
23
21
  type: :runtime
24
22
  prerelease: false
25
- requirement: !ruby/object:Gem::Requirement
23
+ version_requirements: !ruby/object:Gem::Requirement
26
24
  requirements:
27
25
  - - ~>
28
26
  - !ruby/object:Gem::Version
29
27
  version: '0.7'
30
- none: false
31
28
  - !ruby/object:Gem::Dependency
32
- version_requirements: !ruby/object:Gem::Requirement
29
+ name: multi_json
30
+ requirement: !ruby/object:Gem::Requirement
33
31
  requirements:
34
32
  - - ~>
35
33
  - !ruby/object:Gem::Version
36
34
  version: '1.0'
37
- none: false
38
- name: multi_json
39
35
  type: :runtime
40
36
  prerelease: false
41
- requirement: !ruby/object:Gem::Requirement
37
+ version_requirements: !ruby/object:Gem::Requirement
42
38
  requirements:
43
39
  - - ~>
44
40
  - !ruby/object:Gem::Version
45
41
  version: '1.0'
46
- none: false
47
42
  - !ruby/object:Gem::Dependency
48
- version_requirements: !ruby/object:Gem::Requirement
49
- requirements:
50
- - - ~>
51
- - !ruby/object:Gem::Version
52
- version: '2.6'
53
- none: false
54
43
  name: rspec
55
- type: :development
56
- prerelease: false
57
44
  requirement: !ruby/object:Gem::Requirement
58
45
  requirements:
59
46
  - - ~>
60
47
  - !ruby/object:Gem::Version
61
- version: '2.6'
62
- none: false
63
- - !ruby/object:Gem::Dependency
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ~>
67
- - !ruby/object:Gem::Version
68
- version: 0.9.12
69
- none: false
70
- name: mocha
48
+ version: '2.13'
71
49
  type: :development
72
50
  prerelease: false
73
- requirement: !ruby/object:Gem::Requirement
51
+ version_requirements: !ruby/object:Gem::Requirement
74
52
  requirements:
75
53
  - - ~>
76
54
  - !ruby/object:Gem::Version
77
- version: 0.9.12
78
- none: false
55
+ version: '2.13'
79
56
  - !ruby/object:Gem::Dependency
80
- version_requirements: !ruby/object:Gem::Requirement
57
+ name: yard
58
+ requirement: !ruby/object:Gem::Requirement
81
59
  requirements:
82
60
  - - ~>
83
61
  - !ruby/object:Gem::Version
84
- version: 0.7.3
85
- none: false
86
- name: yard
62
+ version: '0.7'
87
63
  type: :development
88
64
  prerelease: false
89
- requirement: !ruby/object:Gem::Requirement
65
+ version_requirements: !ruby/object:Gem::Requirement
90
66
  requirements:
91
67
  - - ~>
92
68
  - !ruby/object:Gem::Version
93
- version: 0.7.3
94
- none: false
69
+ version: '0.7'
95
70
  - !ruby/object:Gem::Dependency
96
- version_requirements: !ruby/object:Gem::Requirement
71
+ name: activesupport
72
+ requirement: !ruby/object:Gem::Requirement
97
73
  requirements:
98
74
  - - ~>
99
75
  - !ruby/object:Gem::Version
100
76
  version: '3.1'
101
- none: false
102
- name: activesupport
103
77
  type: :development
104
78
  prerelease: false
105
- requirement: !ruby/object:Gem::Requirement
79
+ version_requirements: !ruby/object:Gem::Requirement
106
80
  requirements:
107
81
  - - ~>
108
82
  - !ruby/object:Gem::Version
109
83
  version: '3.1'
110
- none: false
111
84
  - !ruby/object:Gem::Dependency
112
- version_requirements: !ruby/object:Gem::Requirement
85
+ name: rake
86
+ requirement: !ruby/object:Gem::Requirement
113
87
  requirements:
114
88
  - - ~>
115
89
  - !ruby/object:Gem::Version
116
90
  version: '10.0'
117
- none: false
118
- name: rake
119
91
  type: :development
120
92
  prerelease: false
121
- requirement: !ruby/object:Gem::Requirement
93
+ version_requirements: !ruby/object:Gem::Requirement
122
94
  requirements:
123
95
  - - ~>
124
96
  - !ruby/object:Gem::Version
125
97
  version: '10.0'
126
- none: false
127
98
  description: A Ruby wrapper for the GoCardless API
128
99
  email:
129
100
  - developers@gocardless.com
@@ -147,6 +118,7 @@ files:
147
118
  - lib/gocardless/errors.rb
148
119
  - lib/gocardless/merchant.rb
149
120
  - lib/gocardless/payment.rb
121
+ - lib/gocardless/payout.rb
150
122
  - lib/gocardless/pre_authorization.rb
151
123
  - lib/gocardless/resource.rb
152
124
  - lib/gocardless/subscription.rb
@@ -163,28 +135,28 @@ files:
163
135
  - spec/user_spec.rb
164
136
  - spec/utils_spec.rb
165
137
  homepage: https://github.com/gocardless/gocardless-ruby
166
- licenses: []
138
+ licenses:
139
+ - MIT
140
+ metadata: {}
167
141
  post_install_message:
168
142
  rdoc_options: []
169
143
  require_paths:
170
144
  - lib
171
145
  required_ruby_version: !ruby/object:Gem::Requirement
172
146
  requirements:
173
- - - ! '>='
147
+ - - '>='
174
148
  - !ruby/object:Gem::Version
175
149
  version: '0'
176
- none: false
177
150
  required_rubygems_version: !ruby/object:Gem::Requirement
178
151
  requirements:
179
- - - ! '>='
152
+ - - '>='
180
153
  - !ruby/object:Gem::Version
181
154
  version: '0'
182
- none: false
183
155
  requirements: []
184
156
  rubyforge_project:
185
- rubygems_version: 1.8.23
157
+ rubygems_version: 2.2.2
186
158
  signing_key:
187
- specification_version: 3
159
+ specification_version: 4
188
160
  summary: Ruby wrapper for the GoCardless API
189
161
  test_files:
190
162
  - spec/bill_spec.rb
@@ -196,4 +168,3 @@ test_files:
196
168
  - spec/subscription_spec.rb
197
169
  - spec/user_spec.rb
198
170
  - spec/utils_spec.rb
199
- has_rdoc: