recurly 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of recurly might be problematic. Click here for more details.
- data/README.md +53 -7
- data/lib/recurly/account.rb +60 -7
- data/lib/recurly/base.rb +60 -43
- data/lib/recurly/billing_info.rb +2 -3
- data/lib/recurly/charge.rb +7 -2
- data/lib/recurly/credit.rb +7 -2
- data/lib/recurly/formats/xml_with_pagination.rb +38 -0
- data/lib/recurly/invoice.rb +17 -2
- data/lib/recurly/plan.rb +1 -4
- data/lib/recurly/subscription.rb +10 -11
- data/lib/recurly/transaction.rb +16 -1
- data/lib/recurly/version.rb +3 -0
- data/lib/recurly.rb +32 -9
- data/spec/integration/account_spec.rb +92 -0
- data/spec/integration/billing_info_spec.rb +66 -0
- data/spec/integration/charge_spec.rb +82 -0
- data/spec/integration/credit_spec.rb +87 -0
- data/spec/integration/invoice_spec.rb +75 -0
- data/spec/integration/plan_spec.rb +85 -0
- data/spec/integration/subscription_spec.rb +90 -0
- data/spec/integration/transaction_spec.rb +116 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/spec_settings.yml.example +3 -0
- data/spec/support/factory.rb +204 -0
- data/spec/support/spec_settings.rb +36 -0
- data/spec/support/vcr.rb +11 -0
- metadata +112 -52
- data/Manifest +0 -23
- data/Rakefile +0 -14
- data/recurly.gemspec +0 -31
- data/test/account_test.rb +0 -41
- data/test/billing_info_test.rb +0 -28
- data/test/charge_test.rb +0 -30
- data/test/credit_test.rb +0 -30
- data/test/plan_test.rb +0 -18
- data/test/subscription_test.rb +0 -87
- data/test/test_helper.rb +0 -44
- data/test/transaction_test.rb +0 -19
@@ -0,0 +1,204 @@
|
|
1
|
+
module Recurly
|
2
|
+
module Factory
|
3
|
+
|
4
|
+
# creates an account
|
5
|
+
def self.create_account(account_code, overrides = {})
|
6
|
+
attributes = {
|
7
|
+
# version is used to avoid duplicate account errors on recurly's api, pass in a different one every time
|
8
|
+
:account_code => account_code,
|
9
|
+
:first_name => 'Verena',
|
10
|
+
:last_name => 'Test',
|
11
|
+
:email => 'verena@test.com',
|
12
|
+
:company_name => 'Recurly Ruby Gem'
|
13
|
+
}
|
14
|
+
|
15
|
+
# add overrides
|
16
|
+
overrides.each do |key, val|
|
17
|
+
attributes[key] = val
|
18
|
+
end
|
19
|
+
|
20
|
+
account = Account.new(attributes)
|
21
|
+
account.save!
|
22
|
+
account
|
23
|
+
end
|
24
|
+
|
25
|
+
# creates an account with associated billing information
|
26
|
+
def self.create_account_with_billing_info(account_code, address_overrides = {}, credit_card_overrides = {})
|
27
|
+
account = Factory.create_account(account_code)
|
28
|
+
|
29
|
+
# create billing info
|
30
|
+
billing_info = BillingInfo.new(billing_attributes(address_overrides, credit_card_overrides))
|
31
|
+
billing_info.account_code = account_code
|
32
|
+
billing_info.first_name = account.first_name unless billing_info.respond_to?(:first_name)
|
33
|
+
billing_info.last_name = account.last_name unless billing_info.respond_to?(:last_name)
|
34
|
+
billing_info.save!
|
35
|
+
|
36
|
+
# return account
|
37
|
+
account
|
38
|
+
end
|
39
|
+
|
40
|
+
# returns a hash of billing information
|
41
|
+
def self.billing_attributes(address_overrides = {}, credit_card_overrides = {})
|
42
|
+
attributes = {
|
43
|
+
:address1 => '123 Test St',
|
44
|
+
:city => 'San Francisco',
|
45
|
+
:state => 'CA',
|
46
|
+
:zip => '94115',
|
47
|
+
:country => "US",
|
48
|
+
:credit_card => {
|
49
|
+
:number => '1',
|
50
|
+
:year => Time.now.year + 1,
|
51
|
+
:month => Time.now.month,
|
52
|
+
:verification_value => '123'
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
# overrides for address
|
57
|
+
address_overrides.each do |key, val|
|
58
|
+
attributes[key] = val
|
59
|
+
end
|
60
|
+
|
61
|
+
# overrides for credit cards
|
62
|
+
credit_card_overrides.each do |key, val|
|
63
|
+
attributes[:credit_card][key] = val
|
64
|
+
end
|
65
|
+
|
66
|
+
attributes
|
67
|
+
end
|
68
|
+
|
69
|
+
# Creates a subscription for an account
|
70
|
+
def self.create_subscription(account, plan, overrides={})
|
71
|
+
plan = self.send("#{plan}_plan") if plan.is_a?(Symbol)
|
72
|
+
|
73
|
+
# default to paid plan if none specified
|
74
|
+
plan ||= paid_plan
|
75
|
+
|
76
|
+
account.billing_info = BillingInfo.new(billing_attributes)
|
77
|
+
|
78
|
+
# set account information
|
79
|
+
account.billing_info.first_name = account.first_name
|
80
|
+
account.billing_info.last_name = account.last_name
|
81
|
+
|
82
|
+
attributes = {
|
83
|
+
:account_code => account.account_code,
|
84
|
+
:plan_code => (plan || paid_plan).plan_code,
|
85
|
+
:quantity => 1,
|
86
|
+
:account => account
|
87
|
+
}
|
88
|
+
|
89
|
+
overrides.each do |key,val|
|
90
|
+
attributes[key] = val
|
91
|
+
end
|
92
|
+
|
93
|
+
subscription = Subscription.new(attributes)
|
94
|
+
subscription.save!
|
95
|
+
return subscription
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.create_charge(account_code, attributes = {})
|
99
|
+
charge = Charge.new({
|
100
|
+
:account_code => account_code,
|
101
|
+
:amount => 10.00,
|
102
|
+
:description => "charge description"
|
103
|
+
}.merge(attributes))
|
104
|
+
charge.save!
|
105
|
+
charge
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.create_transaction(account_code, overrides = {})
|
109
|
+
attributes = {
|
110
|
+
:account => {
|
111
|
+
:account_code => account_code
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
overrides.each do |key, val|
|
116
|
+
attributes[key] = val
|
117
|
+
end
|
118
|
+
|
119
|
+
transaction = Transaction.new(attributes)
|
120
|
+
transaction.save!
|
121
|
+
|
122
|
+
transaction
|
123
|
+
end
|
124
|
+
|
125
|
+
# creates a full transaction from scratch
|
126
|
+
def self.create_full_transaction(account_code, overrides = {}, address_overrides = {}, credit_card_overrides = {})
|
127
|
+
attributes = {
|
128
|
+
:account => {
|
129
|
+
:account_code => account_code,
|
130
|
+
:first_name => 'Verena',
|
131
|
+
:last_name => 'Test',
|
132
|
+
:email => 'verena@test.com',
|
133
|
+
:company_name => 'Recurly Ruby Gem',
|
134
|
+
:billing_info => billing_attributes(address_overrides, credit_card_overrides)
|
135
|
+
}
|
136
|
+
}
|
137
|
+
|
138
|
+
overrides.each do |key, val|
|
139
|
+
attributes[key] = val
|
140
|
+
end
|
141
|
+
|
142
|
+
transaction = Transaction.new(attributes)
|
143
|
+
transaction.save!
|
144
|
+
|
145
|
+
transaction
|
146
|
+
end
|
147
|
+
|
148
|
+
def self.create_credit(account_code, attributes = {})
|
149
|
+
credit = Credit.new({
|
150
|
+
:account_code => account_code,
|
151
|
+
:amount => 10.00,
|
152
|
+
:description => "free moniez"
|
153
|
+
}.merge(attributes))
|
154
|
+
credit.save!
|
155
|
+
credit
|
156
|
+
end
|
157
|
+
|
158
|
+
def self.trial_plan
|
159
|
+
find_or_create_plan({
|
160
|
+
:plan_code => "trial",
|
161
|
+
:name => "Trial",
|
162
|
+
|
163
|
+
# 10 dollars a month
|
164
|
+
:unit_amount_in_cents => 1000,
|
165
|
+
|
166
|
+
# 1 year intervals
|
167
|
+
:plan_interval_length => 1,
|
168
|
+
:plan_interval_unit => "years",
|
169
|
+
|
170
|
+
# 1 month trial
|
171
|
+
:trial_interval_length => 1,
|
172
|
+
:trial_interval_unit => "months"
|
173
|
+
})
|
174
|
+
end
|
175
|
+
|
176
|
+
def self.paid_plan
|
177
|
+
find_or_create_plan({
|
178
|
+
:plan_code => "paid",
|
179
|
+
:name => "Paid",
|
180
|
+
|
181
|
+
# 10 dollars a month
|
182
|
+
:unit_amount_in_cents => 1000,
|
183
|
+
|
184
|
+
# 1 month intervals
|
185
|
+
:plan_interval_length => 1,
|
186
|
+
:plan_interval_unit => "months",
|
187
|
+
|
188
|
+
# 0 trial
|
189
|
+
:trial_interval_length => 0,
|
190
|
+
:trial_interval_unit => "months"
|
191
|
+
})
|
192
|
+
end
|
193
|
+
|
194
|
+
def self.find_or_create_plan(data)
|
195
|
+
begin
|
196
|
+
return Plan.find(data[:plan_code])
|
197
|
+
rescue ActiveResource::ResourceNotFound => e
|
198
|
+
plan = Plan.new(data)
|
199
|
+
plan.save!
|
200
|
+
return plan
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Recurly
|
5
|
+
module SpecSettings
|
6
|
+
SETTINGS_PATH = File.dirname(__FILE__) + '/../spec_settings.yml'
|
7
|
+
|
8
|
+
class << self
|
9
|
+
# keep all the settings global for now
|
10
|
+
attr_accessor :settings
|
11
|
+
|
12
|
+
def [](val)
|
13
|
+
self.settings[val]
|
14
|
+
end
|
15
|
+
|
16
|
+
def []=(key,val)
|
17
|
+
self.settings[key] = val
|
18
|
+
end
|
19
|
+
|
20
|
+
def reload!
|
21
|
+
if File.exists?(SETTINGS_PATH)
|
22
|
+
self.settings = YAML.load_file(SETTINGS_PATH)
|
23
|
+
else
|
24
|
+
raise "spec/spec_settings.yml file not found. Run rake recurly:setup to create one"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def save!
|
29
|
+
File.open(SETTINGS_PATH, 'w' ) do |out|
|
30
|
+
YAML.dump(self.settings, out)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
data/spec/support/vcr.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'vcr'
|
2
|
+
require 'vcr/rspec'
|
3
|
+
VCR.config do |c|
|
4
|
+
c.cassette_library_dir = 'spec/vcr'
|
5
|
+
c.http_stubbing_library = :webmock
|
6
|
+
c.default_cassette_options = { :record => :new_episodes }
|
7
|
+
end
|
8
|
+
|
9
|
+
RSpec.configure do |c|
|
10
|
+
c.extend VCR::RSpec::Macros
|
11
|
+
end
|
metadata
CHANGED
@@ -1,108 +1,168 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recurly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Isaac Hall
|
14
|
+
- Jacques Crocker
|
13
15
|
autorequire:
|
14
16
|
bindir: bin
|
15
17
|
cert_chain: []
|
16
18
|
|
17
|
-
date: 2010-
|
19
|
+
date: 2010-10-08 00:00:00 -07:00
|
18
20
|
default_executable:
|
19
|
-
dependencies:
|
20
|
-
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: activeresource
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 5
|
31
|
+
segments:
|
32
|
+
- 2
|
33
|
+
- 3
|
34
|
+
version: "2.3"
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 2632228393
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
- 0
|
49
|
+
- 0
|
50
|
+
- beta
|
51
|
+
- 22
|
52
|
+
version: 2.0.0.beta.22
|
53
|
+
type: :development
|
54
|
+
version_requirements: *id002
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
prerelease: false
|
58
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 3
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: vcr
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 3
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
version: "0"
|
81
|
+
type: :development
|
82
|
+
version_requirements: *id004
|
21
83
|
description: A Ruby API wrapper for Recurly. Super Simple Subscription billing.
|
22
|
-
email:
|
84
|
+
email:
|
85
|
+
- support@recurly.com
|
23
86
|
executables: []
|
24
87
|
|
25
88
|
extensions: []
|
26
89
|
|
27
|
-
extra_rdoc_files:
|
28
|
-
|
29
|
-
|
30
|
-
- lib/recurly.rb
|
90
|
+
extra_rdoc_files: []
|
91
|
+
|
92
|
+
files:
|
31
93
|
- lib/recurly/account.rb
|
32
94
|
- lib/recurly/base.rb
|
33
95
|
- lib/recurly/billing_info.rb
|
34
96
|
- lib/recurly/charge.rb
|
35
97
|
- lib/recurly/credit.rb
|
98
|
+
- lib/recurly/formats/xml_with_pagination.rb
|
36
99
|
- lib/recurly/invoice.rb
|
37
100
|
- lib/recurly/plan.rb
|
38
101
|
- lib/recurly/subscription.rb
|
39
102
|
- lib/recurly/transaction.rb
|
40
|
-
|
103
|
+
- lib/recurly/version.rb
|
104
|
+
- lib/recurly.rb
|
105
|
+
- init.rb
|
41
106
|
- LICENSE
|
42
107
|
- README.md
|
43
|
-
-
|
44
|
-
-
|
45
|
-
-
|
46
|
-
-
|
47
|
-
-
|
48
|
-
-
|
49
|
-
-
|
50
|
-
-
|
51
|
-
-
|
52
|
-
-
|
53
|
-
-
|
54
|
-
-
|
55
|
-
-
|
56
|
-
- test/account_test.rb
|
57
|
-
- test/billing_info_test.rb
|
58
|
-
- test/charge_test.rb
|
59
|
-
- test/credit_test.rb
|
60
|
-
- test/plan_test.rb
|
61
|
-
- test/subscription_test.rb
|
62
|
-
- test/test_helper.rb
|
63
|
-
- Manifest
|
108
|
+
- spec/integration/account_spec.rb
|
109
|
+
- spec/integration/billing_info_spec.rb
|
110
|
+
- spec/integration/charge_spec.rb
|
111
|
+
- spec/integration/credit_spec.rb
|
112
|
+
- spec/integration/invoice_spec.rb
|
113
|
+
- spec/integration/plan_spec.rb
|
114
|
+
- spec/integration/subscription_spec.rb
|
115
|
+
- spec/integration/transaction_spec.rb
|
116
|
+
- spec/spec_helper.rb
|
117
|
+
- spec/spec_settings.yml.example
|
118
|
+
- spec/support/factory.rb
|
119
|
+
- spec/support/spec_settings.rb
|
120
|
+
- spec/support/vcr.rb
|
64
121
|
has_rdoc: true
|
65
122
|
homepage: http://github.com/recurly/recurly-client-ruby
|
66
123
|
licenses: []
|
67
124
|
|
68
125
|
post_install_message:
|
69
126
|
rdoc_options:
|
70
|
-
- --
|
71
|
-
- --inline-source
|
72
|
-
- --title
|
73
|
-
- Recurly
|
74
|
-
- --main
|
75
|
-
- README.md
|
127
|
+
- --charset=UTF-8
|
76
128
|
require_paths:
|
77
129
|
- lib
|
78
130
|
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
79
132
|
requirements:
|
80
133
|
- - ">="
|
81
134
|
- !ruby/object:Gem::Version
|
135
|
+
hash: 3
|
82
136
|
segments:
|
83
137
|
- 0
|
84
138
|
version: "0"
|
85
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
86
141
|
requirements:
|
87
142
|
- - ">="
|
88
143
|
- !ruby/object:Gem::Version
|
144
|
+
hash: 3
|
89
145
|
segments:
|
90
|
-
-
|
91
|
-
|
92
|
-
version: "1.2"
|
146
|
+
- 0
|
147
|
+
version: "0"
|
93
148
|
requirements: []
|
94
149
|
|
95
150
|
rubyforge_project: recurly
|
96
|
-
rubygems_version: 1.3.
|
151
|
+
rubygems_version: 1.3.7
|
97
152
|
signing_key:
|
98
153
|
specification_version: 3
|
99
|
-
summary:
|
154
|
+
summary: Ruby API wrapper for Recurly
|
100
155
|
test_files:
|
101
|
-
-
|
102
|
-
-
|
103
|
-
-
|
104
|
-
-
|
105
|
-
-
|
106
|
-
-
|
107
|
-
-
|
108
|
-
-
|
156
|
+
- spec/integration/account_spec.rb
|
157
|
+
- spec/integration/billing_info_spec.rb
|
158
|
+
- spec/integration/charge_spec.rb
|
159
|
+
- spec/integration/credit_spec.rb
|
160
|
+
- spec/integration/invoice_spec.rb
|
161
|
+
- spec/integration/plan_spec.rb
|
162
|
+
- spec/integration/subscription_spec.rb
|
163
|
+
- spec/integration/transaction_spec.rb
|
164
|
+
- spec/spec_helper.rb
|
165
|
+
- spec/spec_settings.yml.example
|
166
|
+
- spec/support/factory.rb
|
167
|
+
- spec/support/spec_settings.rb
|
168
|
+
- spec/support/vcr.rb
|
data/Manifest
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
LICENSE
|
2
|
-
README.md
|
3
|
-
Rakefile
|
4
|
-
init.rb
|
5
|
-
lib/recurly.rb
|
6
|
-
lib/recurly/account.rb
|
7
|
-
lib/recurly/base.rb
|
8
|
-
lib/recurly/billing_info.rb
|
9
|
-
lib/recurly/charge.rb
|
10
|
-
lib/recurly/credit.rb
|
11
|
-
lib/recurly/invoice.rb
|
12
|
-
lib/recurly/plan.rb
|
13
|
-
lib/recurly/subscription.rb
|
14
|
-
lib/recurly/transaction.rb
|
15
|
-
recurly.gemspec
|
16
|
-
test/account_test.rb
|
17
|
-
test/billing_info_test.rb
|
18
|
-
test/charge_test.rb
|
19
|
-
test/credit_test.rb
|
20
|
-
test/plan_test.rb
|
21
|
-
test/subscription_test.rb
|
22
|
-
test/test_helper.rb
|
23
|
-
Manifest
|
data/Rakefile
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
require 'echoe'
|
4
|
-
|
5
|
-
Echoe.new('recurly', '0.1.4') do |p|
|
6
|
-
p.description = "A Ruby API wrapper for Recurly. Super Simple Subscription billing."
|
7
|
-
p.url = "http://github.com/recurly/recurly-client-ruby"
|
8
|
-
p.author = "Isaac Hall"
|
9
|
-
p.email = "support@recurly.com"
|
10
|
-
p.ignore_pattern = ["tmp/*", "script/*"]
|
11
|
-
p.development_dependencies = []
|
12
|
-
end
|
13
|
-
|
14
|
-
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
data/recurly.gemspec
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{recurly}
|
5
|
-
s.version = "0.1.4"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Isaac Hall"]
|
9
|
-
s.date = %q{2010-04-01}
|
10
|
-
s.description = %q{A Ruby API wrapper for Recurly. Super Simple Subscription billing.}
|
11
|
-
s.email = %q{support@recurly.com}
|
12
|
-
s.extra_rdoc_files = ["LICENSE", "README.md", "lib/recurly.rb", "lib/recurly/account.rb", "lib/recurly/base.rb", "lib/recurly/billing_info.rb", "lib/recurly/charge.rb", "lib/recurly/credit.rb", "lib/recurly/invoice.rb", "lib/recurly/plan.rb", "lib/recurly/subscription.rb", "lib/recurly/transaction.rb"]
|
13
|
-
s.files = ["LICENSE", "README.md", "Rakefile", "init.rb", "lib/recurly.rb", "lib/recurly/account.rb", "lib/recurly/base.rb", "lib/recurly/billing_info.rb", "lib/recurly/charge.rb", "lib/recurly/credit.rb", "lib/recurly/invoice.rb", "lib/recurly/plan.rb", "lib/recurly/subscription.rb", "lib/recurly/transaction.rb", "recurly.gemspec", "test/account_test.rb", "test/billing_info_test.rb", "test/charge_test.rb", "test/credit_test.rb", "test/plan_test.rb", "test/subscription_test.rb", "test/test_helper.rb", "Manifest", "test/transaction_test.rb"]
|
14
|
-
s.homepage = %q{http://github.com/recurly/recurly-client-ruby}
|
15
|
-
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Recurly", "--main", "README.md"]
|
16
|
-
s.require_paths = ["lib"]
|
17
|
-
s.rubyforge_project = %q{recurly}
|
18
|
-
s.rubygems_version = %q{1.3.6}
|
19
|
-
s.summary = %q{A Ruby API wrapper for Recurly. Super Simple Subscription billing.}
|
20
|
-
s.test_files = ["test/account_test.rb", "test/billing_info_test.rb", "test/charge_test.rb", "test/credit_test.rb", "test/plan_test.rb", "test/subscription_test.rb", "test/test_helper.rb", "test/transaction_test.rb"]
|
21
|
-
|
22
|
-
if s.respond_to? :specification_version then
|
23
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
-
s.specification_version = 3
|
25
|
-
|
26
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
-
else
|
28
|
-
end
|
29
|
-
else
|
30
|
-
end
|
31
|
-
end
|
data/test/account_test.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class AccountTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_create
|
6
|
-
account = create_account('create')
|
7
|
-
assert_not_nil account.created_at
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_get_account
|
11
|
-
account = create_account('get')
|
12
|
-
|
13
|
-
get_acct = Recurly::Account.find(account.account_code)
|
14
|
-
assert_not_nil get_acct
|
15
|
-
assert_not_nil get_acct.created_at
|
16
|
-
assert_equal account.account_code, get_acct.account_code
|
17
|
-
assert_equal account.email, get_acct.email
|
18
|
-
assert_equal account.first_name, get_acct.first_name
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_update_account
|
22
|
-
orig_account = create_account('update')
|
23
|
-
|
24
|
-
account = Recurly::Account.find(orig_account.account_code)
|
25
|
-
account.last_name = 'Update Test'
|
26
|
-
account.company_name = 'Recurly Ruby Gem -- Update'
|
27
|
-
account.save
|
28
|
-
|
29
|
-
updated_acct = Recurly::Account.find(orig_account.account_code)
|
30
|
-
assert_equal account.email, updated_acct.email
|
31
|
-
assert_not_equal orig_account.last_name, updated_acct.last_name
|
32
|
-
assert_not_equal orig_account.company_name, updated_acct.company_name
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_close_account
|
36
|
-
account = create_account('close')
|
37
|
-
|
38
|
-
account.close_account
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
data/test/billing_info_test.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class BillingInfoTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_update_billing_info
|
6
|
-
account = create_account('billing')
|
7
|
-
|
8
|
-
billing_info = Recurly::BillingInfo.create(
|
9
|
-
:account_code => account.account_code,
|
10
|
-
:first_name => account.first_name,
|
11
|
-
:last_name => account.last_name,
|
12
|
-
:address1 => '123 Test St',
|
13
|
-
:city => 'San Francisco',
|
14
|
-
:state => 'CA',
|
15
|
-
:zip => '94115',
|
16
|
-
:credit_card => {
|
17
|
-
:number => '1',
|
18
|
-
:year => Time.now.year + 1,
|
19
|
-
:month => Time.now.month,
|
20
|
-
:verification_value => '123'
|
21
|
-
}
|
22
|
-
)
|
23
|
-
|
24
|
-
assert_instance_of Recurly::BillingInfo, billing_info
|
25
|
-
assert_not_nil billing_info.updated_at
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
data/test/charge_test.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class ChargeTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_charge_account
|
6
|
-
account = create_account('charge')
|
7
|
-
|
8
|
-
charge = Recurly::Charge.create(
|
9
|
-
:account_code => account.account_code,
|
10
|
-
:amount => 9.50
|
11
|
-
)
|
12
|
-
|
13
|
-
assert_not_nil charge.id
|
14
|
-
assert_equal charge.amount_in_cents, 950
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_list_charges
|
18
|
-
account = create_account('charge-list')
|
19
|
-
|
20
|
-
charge = Recurly::Charge.create(
|
21
|
-
:account_code => account.account_code,
|
22
|
-
:amount => 9.23
|
23
|
-
)
|
24
|
-
|
25
|
-
charge_list = Recurly::Charge.list(account.account_code)
|
26
|
-
assert_not_nil charge_list
|
27
|
-
assert_instance_of Array, charge_list
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
data/test/credit_test.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class CreditTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_credit_account
|
6
|
-
account = create_account('credit')
|
7
|
-
|
8
|
-
credit = Recurly::Credit.create(
|
9
|
-
:account_code => account.account_code,
|
10
|
-
:amount => 9.50
|
11
|
-
)
|
12
|
-
|
13
|
-
assert_not_nil credit.id
|
14
|
-
assert_equal credit.amount_in_cents, -950 # Credits are negative
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_list_credits
|
18
|
-
account = create_account('credit-list')
|
19
|
-
|
20
|
-
credit = Recurly::Credit.create(
|
21
|
-
:account_code => account.account_code,
|
22
|
-
:amount => 9.23
|
23
|
-
)
|
24
|
-
|
25
|
-
credit_list = Recurly::Credit.list(account.account_code)
|
26
|
-
assert_not_nil credit_list
|
27
|
-
assert_instance_of Array, credit_list
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
data/test/plan_test.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class PlanTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_list_plans
|
6
|
-
plans = Recurly::Plan.find(:all)
|
7
|
-
|
8
|
-
assert_not_nil plans
|
9
|
-
assert_instance_of Array, plans
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_get_plan
|
13
|
-
plan = Recurly::Plan.find(TEST_PLAN_CODE)
|
14
|
-
assert_not_nil plan
|
15
|
-
assert_not_nil plan.name
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|