gocardless 1.9.0 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ require 'active_support/hash_with_indifferent_access'
2
2
  require 'gocardless'
3
3
 
4
4
  def stub_get(client, data)
5
- response = mock
5
+ response = double
6
6
  response.stub(:parsed).and_return(data)
7
7
 
8
8
  token = client.instance_variable_get(:@access_token)
@@ -13,3 +13,16 @@ def unset_ivar(obj, var)
13
13
  obj.instance_variable_set "@#{var}", nil if obj.instance_variable_get "@#{var}"
14
14
  end
15
15
 
16
+ shared_examples_for "it has a query method for" do |status|
17
+ describe "##{status}?" do
18
+ context "when #{status}" do
19
+ let(:object) { described_class.new(:status => status) }
20
+ specify { object.send("#{status}?").should be_true }
21
+ end
22
+
23
+ context "when not #{status}" do
24
+ let(:object) { described_class.new }
25
+ specify { object.send("#{status}?").should be_false }
26
+ end
27
+ end
28
+ end
@@ -1,57 +1,20 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe GoCardless::Subscription do
4
- before :each do
5
- @app_id = 'abc'
6
- @app_secret = 'xyz'
7
- GoCardless.account_details = {:app_id => @app_id, :app_secret => @app_secret,
8
- :token => 'xxx', :merchant_id => '1'}
9
- @client = GoCardless.client
4
+ before do
5
+ GoCardless.account_details = {:app_id => 'abc', :app_secret => 'xyz',
6
+ :token => 'xxx', :merchant_id => '123'}
10
7
  end
8
+ let(:client) { GoCardless.client }
9
+ let(:subscription) { GoCardless::Subscription.new(:id => '009988') }
11
10
 
12
11
  it "should be cancellable" do
13
- s = GoCardless::Subscription.new_with_client(@client, :id => '009988')
14
- @client.should_receive(:api_put).with('/subscriptions/009988/cancel')
15
- s.cancel!
12
+ client.should_receive(:api_put).with('/subscriptions/009988/cancel')
13
+ subscription.cancel!
16
14
  end
17
15
 
18
- describe "inactive query method" do
19
- it "and_return true when the subscription status is inactive" do
20
- GoCardless::Subscription.new(:status => 'inactive').inactive?.should be_true
21
- end
22
-
23
- it "and_return false otherwise" do
24
- GoCardless::Subscription.new.inactive?.should be_false
25
- end
26
- end
27
-
28
- describe "active query method" do
29
- it "and_return true when the subscription status is active" do
30
- GoCardless::Subscription.new(:status => 'active').active?.should be_true
31
- end
32
-
33
- it "and_return false otherwise" do
34
- GoCardless::Subscription.new.active?.should be_false
35
- end
36
- end
37
-
38
- describe "cancelled query method" do
39
- it "and_return true when the subscription status is cancelled" do
40
- GoCardless::Subscription.new(:status => 'cancelled').cancelled?.should be_true
41
- end
42
-
43
- it "and_return false otherwise" do
44
- GoCardless::Subscription.new.cancelled?.should be_false
45
- end
46
- end
47
-
48
- describe "expired query method" do
49
- it "and_return true when the subscription status is expired" do
50
- GoCardless::Subscription.new(:status => 'expired').expired?.should be_true
51
- end
52
-
53
- it "and_return false otherwise" do
54
- GoCardless::Subscription.new.expired?.should be_false
55
- end
56
- end
16
+ it_behaves_like "it has a query method for", "inactive"
17
+ it_behaves_like "it has a query method for", "active"
18
+ it_behaves_like "it has a query method for", "cancelled"
19
+ it_behaves_like "it has a query method for", "expired"
57
20
  end
@@ -1,33 +1,31 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe GoCardless::User do
4
- let(:user) { GoCardless::User.new(:id => 123, :first_name => first, :last_name => last) }
4
+ let(:user) { GoCardless::User.new(:first_name => first, :last_name => last) }
5
5
 
6
6
  describe "#name" do
7
- subject { user.name }
8
-
9
7
  context "with first and last name" do
10
8
  let(:first) { "First" }
11
9
  let(:last) { "Last" }
12
- it { should == "First Last" }
10
+ specify { user.name.should == "First Last" }
13
11
  end
14
12
 
15
13
  context "with first name only" do
16
14
  let(:first) { "First" }
17
15
  let(:last) { nil }
18
- it { should == "First" }
16
+ specify { user.name.should == "First" }
19
17
  end
20
18
 
21
19
  context "with last name only" do
22
20
  let(:first) { nil }
23
21
  let(:last) { "Last" }
24
- it { should == "Last" }
22
+ specify { user.name.should == "Last" }
25
23
  end
26
24
 
27
25
  context "with no first or last name" do
28
26
  let(:first) { nil }
29
27
  let(:last) { nil }
30
- it { should == "" }
28
+ specify { user.name.should == "" }
31
29
  end
32
30
  end
33
31
  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.9.0
4
+ version: 1.10.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-05-23 00:00:00.000000000 Z
12
+ date: 2014-06-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth2
@@ -117,7 +117,8 @@ files:
117
117
  - lib/gocardless/client.rb
118
118
  - lib/gocardless/errors.rb
119
119
  - lib/gocardless/merchant.rb
120
- - lib/gocardless/payment.rb
120
+ - lib/gocardless/page.rb
121
+ - lib/gocardless/paginator.rb
121
122
  - lib/gocardless/payout.rb
122
123
  - lib/gocardless/pre_authorization.rb
123
124
  - lib/gocardless/resource.rb
@@ -128,6 +129,8 @@ files:
128
129
  - spec/bill_spec.rb
129
130
  - spec/client_spec.rb
130
131
  - spec/gocardless_spec.rb
132
+ - spec/page_spec.rb
133
+ - spec/paginator_spec.rb
131
134
  - spec/pre_authorization_spec.rb
132
135
  - spec/resource_spec.rb
133
136
  - spec/spec_helper.rb
@@ -162,6 +165,8 @@ test_files:
162
165
  - spec/bill_spec.rb
163
166
  - spec/client_spec.rb
164
167
  - spec/gocardless_spec.rb
168
+ - spec/page_spec.rb
169
+ - spec/paginator_spec.rb
165
170
  - spec/pre_authorization_spec.rb
166
171
  - spec/resource_spec.rb
167
172
  - spec/spec_helper.rb
@@ -1,9 +0,0 @@
1
- module GoCardless
2
- class Payment < Resource
3
- self.endpoint = '/payments/:id'
4
-
5
- attr_accessor :amount, :currency, :status
6
- reference_accessor :merchant_id, :user_id
7
- date_accessor :created_at
8
- end
9
- end