spreedly 1.3.5 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +15 -0
  2. data/{History.txt → HISTORY.md} +24 -16
  3. data/{vendor/httparty/MIT-LICENSE → LICENSE.txt} +10 -8
  4. data/README.md +42 -0
  5. data/lib/spreedly.rb +28 -26
  6. data/lib/spreedly/version.rb +1 -1
  7. metadata +44 -116
  8. data/.gemtest +0 -0
  9. data/Manifest.txt +0 -68
  10. data/README.txt +0 -67
  11. data/Rakefile +0 -49
  12. data/TODO +0 -0
  13. data/test/spreedly_gem_test.rb +0 -319
  14. data/test/test_site.yml +0 -2
  15. data/vendor/httparty/History +0 -108
  16. data/vendor/httparty/Manifest +0 -55
  17. data/vendor/httparty/README +0 -35
  18. data/vendor/httparty/Rakefile +0 -47
  19. data/vendor/httparty/bin/httparty +0 -98
  20. data/vendor/httparty/cucumber.yml +0 -1
  21. data/vendor/httparty/examples/aaws.rb +0 -32
  22. data/vendor/httparty/examples/basic.rb +0 -11
  23. data/vendor/httparty/examples/delicious.rb +0 -37
  24. data/vendor/httparty/examples/google.rb +0 -16
  25. data/vendor/httparty/examples/rubyurl.rb +0 -14
  26. data/vendor/httparty/examples/twitter.rb +0 -31
  27. data/vendor/httparty/examples/whoismyrep.rb +0 -10
  28. data/vendor/httparty/features/basic_authentication.feature +0 -20
  29. data/vendor/httparty/features/command_line.feature +0 -7
  30. data/vendor/httparty/features/deals_with_http_error_codes.feature +0 -26
  31. data/vendor/httparty/features/handles_multiple_formats.feature +0 -34
  32. data/vendor/httparty/features/steps/env.rb +0 -15
  33. data/vendor/httparty/features/steps/httparty_response_steps.rb +0 -26
  34. data/vendor/httparty/features/steps/httparty_steps.rb +0 -15
  35. data/vendor/httparty/features/steps/mongrel_helper.rb +0 -55
  36. data/vendor/httparty/features/steps/remote_service_steps.rb +0 -47
  37. data/vendor/httparty/features/supports_redirection.feature +0 -22
  38. data/vendor/httparty/httparty.gemspec +0 -37
  39. data/vendor/httparty/lib/core_extensions.rb +0 -189
  40. data/vendor/httparty/lib/httparty.rb +0 -201
  41. data/vendor/httparty/lib/httparty/cookie_hash.rb +0 -9
  42. data/vendor/httparty/lib/httparty/exceptions.rb +0 -7
  43. data/vendor/httparty/lib/httparty/logging.rb +0 -35
  44. data/vendor/httparty/lib/httparty/module_inheritable_attributes.rb +0 -25
  45. data/vendor/httparty/lib/httparty/parsers.rb +0 -4
  46. data/vendor/httparty/lib/httparty/parsers/json.rb +0 -74
  47. data/vendor/httparty/lib/httparty/parsers/xml.rb +0 -209
  48. data/vendor/httparty/lib/httparty/request.rb +0 -169
  49. data/vendor/httparty/lib/httparty/response.rb +0 -17
  50. data/vendor/httparty/lib/httparty/version.rb +0 -3
  51. data/vendor/httparty/setup.rb +0 -1585
  52. data/vendor/httparty/spec/fixtures/delicious.xml +0 -23
  53. data/vendor/httparty/spec/fixtures/empty.xml +0 -0
  54. data/vendor/httparty/spec/fixtures/google.html +0 -3
  55. data/vendor/httparty/spec/fixtures/twitter.json +0 -1
  56. data/vendor/httparty/spec/fixtures/twitter.xml +0 -403
  57. data/vendor/httparty/spec/fixtures/undefined_method_add_node_for_nil.xml +0 -2
  58. data/vendor/httparty/spec/hash_spec.rb +0 -49
  59. data/vendor/httparty/spec/httparty/cookie_hash_spec.rb +0 -38
  60. data/vendor/httparty/spec/httparty/parsers/json_spec.rb +0 -44
  61. data/vendor/httparty/spec/httparty/parsers/xml_spec.rb +0 -454
  62. data/vendor/httparty/spec/httparty/request_spec.rb +0 -203
  63. data/vendor/httparty/spec/httparty/response_spec.rb +0 -53
  64. data/vendor/httparty/spec/httparty_spec.rb +0 -259
  65. data/vendor/httparty/spec/spec.opts +0 -3
  66. data/vendor/httparty/spec/spec_helper.rb +0 -21
  67. data/vendor/httparty/spec/string_spec.rb +0 -29
  68. data/vendor/httparty/website/css/common.css +0 -47
  69. data/vendor/httparty/website/index.html +0 -74
data/.gemtest DELETED
File without changes
data/Manifest.txt DELETED
@@ -1,68 +0,0 @@
1
- History.txt
2
- Manifest.txt
3
- README.txt
4
- Rakefile
5
- TODO
6
- lib/spreedly.rb
7
- lib/spreedly/common.rb
8
- lib/spreedly/mock.rb
9
- lib/spreedly/test_hacks.rb
10
- lib/spreedly/version.rb
11
- test/spreedly_gem_test.rb
12
- test/test_site.yml
13
- vendor/httparty/History
14
- vendor/httparty/MIT-LICENSE
15
- vendor/httparty/Manifest
16
- vendor/httparty/README
17
- vendor/httparty/Rakefile
18
- vendor/httparty/bin/httparty
19
- vendor/httparty/cucumber.yml
20
- vendor/httparty/examples/aaws.rb
21
- vendor/httparty/examples/basic.rb
22
- vendor/httparty/examples/delicious.rb
23
- vendor/httparty/examples/google.rb
24
- vendor/httparty/examples/rubyurl.rb
25
- vendor/httparty/examples/twitter.rb
26
- vendor/httparty/examples/whoismyrep.rb
27
- vendor/httparty/features/basic_authentication.feature
28
- vendor/httparty/features/command_line.feature
29
- vendor/httparty/features/deals_with_http_error_codes.feature
30
- vendor/httparty/features/handles_multiple_formats.feature
31
- vendor/httparty/features/steps/env.rb
32
- vendor/httparty/features/steps/httparty_response_steps.rb
33
- vendor/httparty/features/steps/httparty_steps.rb
34
- vendor/httparty/features/steps/mongrel_helper.rb
35
- vendor/httparty/features/steps/remote_service_steps.rb
36
- vendor/httparty/features/supports_redirection.feature
37
- vendor/httparty/httparty.gemspec
38
- vendor/httparty/lib/core_extensions.rb
39
- vendor/httparty/lib/httparty.rb
40
- vendor/httparty/lib/httparty/cookie_hash.rb
41
- vendor/httparty/lib/httparty/exceptions.rb
42
- vendor/httparty/lib/httparty/logging.rb
43
- vendor/httparty/lib/httparty/module_inheritable_attributes.rb
44
- vendor/httparty/lib/httparty/parsers.rb
45
- vendor/httparty/lib/httparty/parsers/json.rb
46
- vendor/httparty/lib/httparty/parsers/xml.rb
47
- vendor/httparty/lib/httparty/request.rb
48
- vendor/httparty/lib/httparty/response.rb
49
- vendor/httparty/lib/httparty/version.rb
50
- vendor/httparty/setup.rb
51
- vendor/httparty/spec/fixtures/delicious.xml
52
- vendor/httparty/spec/fixtures/empty.xml
53
- vendor/httparty/spec/fixtures/google.html
54
- vendor/httparty/spec/fixtures/twitter.json
55
- vendor/httparty/spec/fixtures/twitter.xml
56
- vendor/httparty/spec/fixtures/undefined_method_add_node_for_nil.xml
57
- vendor/httparty/spec/hash_spec.rb
58
- vendor/httparty/spec/httparty/cookie_hash_spec.rb
59
- vendor/httparty/spec/httparty/parsers/json_spec.rb
60
- vendor/httparty/spec/httparty/parsers/xml_spec.rb
61
- vendor/httparty/spec/httparty/request_spec.rb
62
- vendor/httparty/spec/httparty/response_spec.rb
63
- vendor/httparty/spec/httparty_spec.rb
64
- vendor/httparty/spec/spec.opts
65
- vendor/httparty/spec/spec_helper.rb
66
- vendor/httparty/spec/string_spec.rb
67
- vendor/httparty/website/css/common.css
68
- vendor/httparty/website/index.html
data/README.txt DELETED
@@ -1,67 +0,0 @@
1
- = Spreedly-Gem
2
-
3
- * http://github.com/spreedly/spreedly-gem
4
-
5
- == DESCRIPTION:
6
-
7
- The Spreedly gem provides a convenient Ruby wrapper for the Spreedly
8
- Subscriptions API.
9
-
10
- == FEATURES:
11
-
12
- * Makes it easy to get started.
13
- * Fully tested.
14
- * (Mostly) fully substitutable mock implementation for fast tests.
15
- * Great example code.
16
-
17
- == SYNOPSIS:
18
-
19
- # For real
20
- require 'spreedly'
21
- Spreedly.configure('site short name', 'crazy hash token')
22
- url = Spreedly.subscribe_url('customer id', 'plan id')
23
- subscriber = Spreedly::Subscriber.find('customer id')
24
- subscriber.active?
25
-
26
- # For fast tests
27
- require 'spreedly/mock'
28
- Spreedly.configure('site short name', 'crazy hash token')
29
- url = Spreedly.subscribe_url('customer id', 'plan id')
30
- subscriber = Spreedly::Subscriber.find('customer id')
31
- subscriber.active?
32
-
33
- Yup, they're exactly the same except for the require and the speed!
34
-
35
- == REQUIREMENTS:
36
-
37
- * A (free) Spreedly Subscriptions account.
38
- * HTTParty (vendored for now).
39
-
40
- == INSTALL:
41
-
42
- `sudo gem install spreedly`
43
-
44
- == LICENSE:
45
-
46
- (The MIT License)
47
-
48
- Copyright (c) 2009-2012 Spreedly, Inc.. All Rights Reserved.
49
-
50
- Permission is hereby granted, free of charge, to any person obtaining
51
- a copy of this software and associated documentation files (the
52
- 'Software'), to deal in the Software without restriction, including
53
- without limitation the rights to use, copy, modify, merge, publish,
54
- distribute, sublicense, and/or sell copies of the Software, and to
55
- permit persons to whom the Software is furnished to do so, subject to
56
- the following conditions:
57
-
58
- The above copyright notice and this permission notice shall be
59
- included in all copies or substantial portions of the Software.
60
-
61
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
62
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
63
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
64
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
65
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
66
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
67
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile DELETED
@@ -1,49 +0,0 @@
1
- require 'hoe'
2
- require './lib/spreedly/version.rb'
3
-
4
- ENV["COPYFILE_DISABLE"] = "true" # Lose all the fugly ._ files when tar'ing
5
-
6
- hoe = Hoe.spec('spreedly') do
7
- developer('Nathaniel Talbott', 'nathaniel@spreedly.com')
8
- self.test_globs = ["test/**/*_test.rb"]
9
- self.extra_dev_deps << ["shoulda"]
10
- self.extra_dev_deps << ["mechanize"]
11
- end
12
-
13
- def remove_task(*task_names)
14
- task_names.each do |task_name|
15
- Rake.application.instance_eval{@tasks.delete(task_name.to_s)}
16
- end
17
- end
18
-
19
- def replace_task(task_name, *args, &block)
20
- name = (task_name.is_a?(Hash) ? task_name.keys.first : task_name)
21
- remove_task(name)
22
- task(task_name, *args, &block)
23
- end
24
-
25
- desc "Run tests with and without mocking."
26
- replace_task :test do
27
- ruby hoe.make_test_cmd
28
-
29
- ENV["SPREEDLY_TEST"] = "REAL"
30
- ruby hoe.make_test_cmd
31
- end
32
-
33
- desc "Run only mock tests."
34
- task :test_mock do
35
- ruby hoe.make_test_cmd
36
- end
37
-
38
- desc "Run only real tests."
39
- task :test_real do
40
- ENV["SPREEDLY_TEST"] = "REAL"
41
- ruby hoe.make_test_cmd
42
- end
43
-
44
- desc "Run both sets of tests under multiruby"
45
- replace_task :multi do
46
- ruby hoe.make_test_cmd(:multi)
47
- ENV["SPREEDLY_TEST"] = "REAL"
48
- ruby hoe.make_test_cmd(:multi)
49
- end
data/TODO DELETED
File without changes
@@ -1,319 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
- require 'yaml'
5
- require 'pp'
6
-
7
- if ENV["SPREEDLY_TEST"] == "REAL"
8
- require 'spreedly'
9
- require 'spreedly/test_hacks'
10
- else
11
- require 'spreedly/mock'
12
- end
13
-
14
- test_site = YAML.load(File.read(File.dirname(__FILE__) + '/test_site.yml'))
15
- Spreedly.configure(test_site['name'], test_site['token'])
16
-
17
-
18
- class SpreedlyGemTest < Test::Unit::TestCase
19
- def self.only_real
20
- yield if ENV["SPREEDLY_TEST"] == "REAL"
21
- end
22
-
23
- context "A Spreedly site" do
24
- setup do
25
- Spreedly::Subscriber.wipe!
26
- end
27
-
28
- should "delete a subscriber" do
29
- one = create_subscriber
30
- two = create_subscriber
31
- subscribers = Spreedly::Subscriber.all
32
- assert subscribers.size == 2
33
- Spreedly::Subscriber.delete!(one.id)
34
- subscribers = Spreedly::Subscriber.all
35
- assert subscribers.size == 1
36
- assert_equal two.id, subscribers.first.id
37
- end
38
-
39
- context "adding a subscriber" do
40
- should "generate a token" do
41
- subscriber = Spreedly::Subscriber.create!('joe')
42
- assert_not_nil subscriber.token
43
- assert_equal subscriber.token, Spreedly::Subscriber.find('joe').token
44
- end
45
-
46
- should "accept email address as an argument" do
47
- subscriber = Spreedly::Subscriber.create!('joe', 'a@b.cd')
48
- assert_equal 'a@b.cd', Spreedly::Subscriber.find('joe').email
49
- end
50
-
51
- should "accept screen name as an argument" do
52
- subscriber = Spreedly::Subscriber.create!('joe', 'a@b.cd', 'tuna')
53
- assert_equal 'tuna', Spreedly::Subscriber.find('joe').screen_name
54
- end
55
-
56
- should "accept optional arguments: like billing first name" do
57
- subscriber = Spreedly::Subscriber.create!('joe', {:billing_first_name => 'Joe'})
58
- assert_equal 'Joe', Spreedly::Subscriber.find('joe').billing_first_name
59
- end
60
- end # adding a subscriber
61
-
62
- should "update subscriber" do
63
- subscriber = Spreedly::Subscriber.create!('joe', :screen_name => "big-joe")
64
- assert_equal "big-joe", Spreedly::Subscriber.find(subscriber.id).screen_name
65
- subscriber.update(:screen_name => "small-joe")
66
- assert_equal "small-joe", Spreedly::Subscriber.find(subscriber.id).screen_name
67
- end
68
-
69
- should "get a subscriber" do
70
- id = create_subscriber.id
71
- subscriber = Spreedly::Subscriber.find(id)
72
- assert_nil subscriber.active_until
73
- end
74
-
75
- should "return nil when getting a subscriber that does NOT exist" do
76
- assert_nil Spreedly::Subscriber.find("junk")
77
- end
78
-
79
- should "expose and parse attributes" do
80
- subscriber = create_subscriber('bob')
81
- assert_kind_of Time, subscriber.created_at
82
- assert !subscriber.active
83
- assert !subscriber.recurring
84
- assert_equal BigDecimal('0.0'), subscriber.store_credit
85
- end
86
-
87
- should "raise error if subscriber exists" do
88
- create_subscriber('bob')
89
- ex = assert_raise(RuntimeError) do
90
- create_subscriber('bob')
91
- end
92
- assert_match(/exists/i, ex.message)
93
- end
94
-
95
- should "raise error if subscriber is invalid" do
96
- ex = assert_raise(RuntimeError) do
97
- create_subscriber('')
98
- end
99
- assert_match(/customer id can't be blank/i, ex.message)
100
- end
101
-
102
- should "create with additional params" do
103
- subscriber = create_subscriber("fred", "fred@example.com", "FREDDY")
104
- assert_equal "FREDDY", subscriber.screen_name
105
- assert_equal "fred@example.com", subscriber.email
106
- end
107
-
108
- should "return all subscribers" do
109
- one = create_subscriber
110
- two = create_subscriber
111
- subscribers = Spreedly::Subscriber.all
112
- assert subscribers.size >= 2
113
- assert subscribers.detect{|e| e.id == one.id}
114
- assert subscribers.detect{|e| e.id == two.id}
115
- end
116
-
117
- should "generate a subscribe url" do
118
- assert_equal "https://spreedly.com/#{Spreedly.site_name}/subscribers/joe/subscribe/1/Joe%20Bob",
119
- Spreedly.subscribe_url('joe', '1', :screen_name => "Joe Bob")
120
- assert_equal "https://spreedly.com/#{Spreedly.site_name}/subscribers/joe/subscribe/1",
121
- Spreedly.subscribe_url('joe', '1')
122
- end
123
-
124
- should "generate a pre-populated subscribe url" do
125
- assert_equal "https://spreedly.com/#{Spreedly.site_name}/subscribers/joe/subscribe/1?email=joe.bob@test.com&first_name=Joe&last_name=Bob",
126
- Spreedly.subscribe_url('joe', '1', :email => "joe.bob@test.com", :first_name => "Joe", :last_name => "Bob")
127
- assert_equal "https://spreedly.com/#{Spreedly.site_name}/subscribers/joe/subscribe/1?first_name=Joe&last_name=Bob",
128
- Spreedly.subscribe_url('joe', '1', :first_name => "Joe", :last_name => "Bob")
129
- assert_equal "https://spreedly.com/#{Spreedly.site_name}/subscribers/joe/subscribe/1?return_url=http://stuffo.example.com",
130
- Spreedly.subscribe_url('joe', '1', :return_url => 'http://stuffo.example.com')
131
- end
132
-
133
- should "generate an edit subscriber url" do
134
- assert_equal "https://spreedly.com/#{Spreedly.site_name}/subscriber_accounts/zetoken",
135
- Spreedly.edit_subscriber_url('zetoken')
136
- assert_equal "https://spreedly.com/#{Spreedly.site_name}/subscriber_accounts/zetoken?return_url=http://stuffo.example.com",
137
- Spreedly.edit_subscriber_url('zetoken', 'http://stuffo.example.com')
138
- end
139
-
140
- should "comp an inactive subscriber" do
141
- sub = create_subscriber
142
- assert !sub.active?
143
- assert_nil sub.active_until
144
- assert_equal "", sub.feature_level
145
- sub.comp(1, 'days', 'Sweet!')
146
- sub = Spreedly::Subscriber.find(sub.id)
147
- assert_not_nil sub.active_until
148
- assert_equal 'Sweet!', sub.feature_level
149
- assert sub.active?
150
- end
151
-
152
- should "comp an active subscriber" do
153
- sub = create_subscriber
154
- assert !sub.active?
155
- sub.comp(1, 'days', 'Sweet!')
156
-
157
- sub = Spreedly::Subscriber.find(sub.id)
158
- assert sub.active?
159
- old_active_until = sub.active_until
160
- sub.comp(1, 'days')
161
-
162
- sub = Spreedly::Subscriber.find(sub.id)
163
- assert sub.active?
164
- assert old_active_until < sub.active_until
165
- end
166
-
167
- should "throw an error if comp is against unknown subscriber" do
168
- sub = create_subscriber
169
- Spreedly::Subscriber.wipe!
170
- ex = assert_raise(RuntimeError) do
171
- sub.comp(1, 'days', 'bogus')
172
- end
173
- assert_match(/exists/i, ex.message)
174
- end
175
-
176
- should "throw an error if comp is invalid" do
177
- sub = create_subscriber
178
- ex = assert_raise(RuntimeError) do
179
- sub.comp(nil, nil, 'bogus')
180
- end
181
- assert_match(/validation/i, ex.message)
182
- assert_raise(RuntimeError){sub.comp(1, nil)}
183
- assert_raise(RuntimeError){sub.comp(nil, 'days')}
184
- end
185
-
186
- should "return subscription plans" do
187
- assert !Spreedly::SubscriptionPlan.all.empty?
188
- assert_not_nil Spreedly::SubscriptionPlan.all.first.name
189
- end
190
-
191
- should "return the subscription plan id" do
192
- plan = Spreedly::SubscriptionPlan.all.first
193
- assert_not_equal plan.id, plan.object_id
194
- end
195
-
196
- should "be able to find an individual subscription plan" do
197
- plan = Spreedly::SubscriptionPlan.all.first
198
- assert_equal plan.name, Spreedly::SubscriptionPlan.find(plan.id).name
199
- end
200
-
201
- context "with a Free Trial plan" do
202
- setup do
203
- @trial = Spreedly::SubscriptionPlan.all.detect{|e| e.name == "Test Free Trial Plan" && e.trial?}
204
- assert @trial, "For this test to pass in REAL mode you must have a trial plan in your Spreedly test site with the name \"Test Free Trial Plan\"."
205
- end
206
-
207
- should "be able to activate free trial" do
208
- sub = create_subscriber
209
- assert !sub.active?
210
- assert !sub.on_trial?
211
-
212
- sub.activate_free_trial(@trial.id)
213
- sub = Spreedly::Subscriber.find(sub.id)
214
- assert sub.active?
215
- assert sub.on_trial?
216
- end
217
-
218
- should "throw an error if a second trial is activated" do
219
- sub = create_subscriber
220
- sub.activate_free_trial(@trial.id)
221
- ex = assert_raise(RuntimeError){sub.activate_free_trial(@trial.id)}
222
- assert_match %r{not eligible}, ex.message
223
- end
224
-
225
- should "allow second trial if 'allow_free_trial' is excecuted" do
226
- sub = create_subscriber
227
- sub.activate_free_trial(@trial.id)
228
- sub.allow_free_trial
229
- sub.activate_free_trial(@trial.id)
230
- sub = Spreedly::Subscriber.find(sub.id)
231
- assert sub.active?
232
- assert sub.on_trial?
233
- end
234
-
235
- should "throw errors on invalid free trial activation" do
236
- sub = create_subscriber
237
-
238
- ex = assert_raise(RuntimeError){sub.activate_free_trial(0)}
239
- assert_match %r{no longer exists}, ex.message
240
-
241
- ex = assert_raise(RuntimeError){sub.activate_free_trial(nil)}
242
- assert_match %r{missing}, ex.message
243
- end
244
- end
245
-
246
- context "with a Regular plan" do
247
- setup do
248
- @regular_plan = Spreedly::SubscriptionPlan.all.detect{|e| e.name == "Test Regular Plan"}
249
- assert @regular_plan, "For this test to pass in REAL mode you must have a regular plan in your Spreedly test site with the name \"Test Regular Plan\". It must be an auto-recurring plan."
250
- end
251
-
252
- should "stop auto renew for subscriber" do
253
- subscriber = create_subscriber
254
- subscriber.subscribe(@regular_plan.id)
255
-
256
- subscriber = Spreedly::Subscriber.find(subscriber.id)
257
- assert subscriber.active?
258
- assert subscriber.recurring
259
-
260
- subscriber.stop_auto_renew
261
- subscriber = Spreedly::Subscriber.find(subscriber.id)
262
- assert subscriber.active?
263
- assert !subscriber.recurring
264
- end
265
- end
266
-
267
- context "adding fees" do
268
-
269
- setup do
270
- @regular_plan = Spreedly::SubscriptionPlan.all.detect{|e| e.name == "Test Regular Plan"}
271
- assert @regular_plan, "For this test to pass in REAL mode you must have a regular plan in your Spreedly test site with the name \"Test Regular Plan\". It must be an auto-recurring plan."
272
- end
273
-
274
- should "be able to add fee to user" do
275
- sub = create_subscriber
276
- sub.subscribe(@regular_plan.id)
277
- sub.add_fee(:name => "Daily Bandwidth Charge", :amount => "2.34", :description => "313 MB used", :group => "Traffic Fees")
278
- end
279
-
280
- should "throw an error when add fee to not active user" do
281
- sub = create_subscriber
282
- ex = assert_raise(RuntimeError) do
283
- sub.add_fee(:name => "Daily Bandwidth Charge", :amount => "2.34", :description => "313 MB used", :group => "Traffic Fees")
284
- end
285
- assert_match %r{Unprocessable Entity}, ex.message
286
- end
287
-
288
- should "throw an error when add fee with incomplete arguments" do
289
- sub = create_subscriber
290
- sub.subscribe(@regular_plan.id)
291
- ex = assert_raise(RuntimeError) do
292
- sub.add_fee(:name => "Daily Bandwidth Charge", :description => "313 MB used", :group => "Traffic Fees")
293
- end
294
- assert_match %r{Unprocessable Entity}, ex.message
295
- end
296
- end
297
-
298
- should "throw an error if stopping auto renew on a non-existent subscriber" do
299
- sub = Spreedly::Subscriber.new('customer_id' => 'bogus')
300
- ex = assert_raise(RuntimeError){sub.stop_auto_renew}
301
- assert_match %r{does not exist}, ex.message
302
- end
303
-
304
- only_real do
305
- should "throw an error if comp is wrong type" do
306
- sub = create_subscriber
307
- sub.comp(1, 'days', 'something')
308
- ex = assert_raise(RuntimeError) do
309
- sub.comp(1, 'days', 'something')
310
- end
311
- assert_match(/invalid/i, ex.message)
312
- end
313
- end
314
- end
315
-
316
- def create_subscriber(id=(rand*100000000).to_i, email=nil, screen_name=nil)
317
- Spreedly::Subscriber.create!(id, email, screen_name)
318
- end
319
- end