chargify_api_ares 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Chargify API wrapper for Ruby (using ActiveResource)
1
+ Chargify API wrapper for Ruby (using ActiveResource) [![build status](https://secure.travis-ci.org/grasshopperlabs/chargify_api_ares.png)](http://travis-ci.org/grasshopperlabs/chargify_api_ares)
2
2
  ====================================================
3
3
 
4
4
  chargify_api_ares
@@ -62,4 +62,4 @@ Now you'll have access to classes the interact with the Chargify API, such as:
62
62
  `Chargifiy::Subscription`
63
63
 
64
64
  Check out the examples in the `samples` directory. If you're not familiar with how ActiveResource works,
65
- you may be interested in some [ActiveResource Documentation](http://apidock.com/rails/ActiveResource/Base)
65
+ you may be interested in some [ActiveResource Documentation](http://apidock.com/rails/ActiveResource/Base)
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{chargify_api_ares}
3
- s.version = "0.4.0"
3
+ s.version = "0.4.1"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
- s.authors = ["Michael Klett", "Nathan Verni", "Rodrigo Franco"]
7
- s.date = %q{2011-03-02}
6
+ s.authors = ["Michael Klett", "Nathan Verni", "Rodrigo Franco", "Shay Frendt"]
7
+ s.date = %q{2011-10-19}
8
8
  s.description = %q{}
9
9
  s.email = %q{support@chargify.com}
10
10
  s.extra_rdoc_files = [
@@ -60,14 +60,19 @@ module Chargify
60
60
  Base.user = api_key
61
61
  Base.password = 'X'
62
62
  Base.timeout = timeout unless (timeout.blank?)
63
-
64
- self.site ||= "https://#{subdomain}.chargify.com"
65
-
63
+
64
+ if site.to_s != Base.site.to_s
65
+ self.site = site || "https://#{subdomain}.chargify.com"
66
+ else
67
+ self.site = "https://#{subdomain}.chargify.com"
68
+ end
69
+
66
70
  Base.site = site
67
71
  Subscription::Component.site = site + "/subscriptions/:subscription_id"
68
72
  Subscription::Statement.site = site + "/subscriptions/:subscription_id"
69
73
  Subscription::Transaction.site = site + "/subscriptions/:subscription_id"
70
74
  Coupon.site = site + "/product_families/:product_family_id"
75
+ ProductFamily::Component.site = site + "/product_families/:product_family_id"
71
76
  end
72
77
  end
73
78
 
@@ -134,7 +139,7 @@ module Chargify
134
139
  end
135
140
 
136
141
  def payment_profile
137
- credit_card
142
+ self.respond_to?('credit_card') ? credit_card : nil
138
143
  end
139
144
 
140
145
  # Perform a one-time charge on an existing subscription.
@@ -247,6 +252,15 @@ module Chargify
247
252
  def self.find_by_handle(handle, attributes = {})
248
253
  ProductFamily.find(:one, :from => :lookup, :handle => handle)
249
254
  end
255
+
256
+ class Component < Base
257
+ end
258
+
259
+ def components(params = {})
260
+ params.merge!({:product_family_id => self.id})
261
+ ::Chargify::ProductFamily::Component.find(:all, :params => params)
262
+ end
263
+
250
264
  end
251
265
 
252
266
  class Usage < Base
data/spec/base_spec.rb CHANGED
@@ -6,5 +6,35 @@ describe Chargify::Base do
6
6
  Chargify::Base.stub!(:name).and_return("Test::Namespace::ElementName")
7
7
  Chargify::Base.element_name.should eql('element_name')
8
8
  end
9
-
10
- end
9
+
10
+ context 'configuration changes' do
11
+ before do
12
+ @original_subdomain = Chargify.subdomain
13
+ end
14
+
15
+ it "honors changes made after the first configuration" do
16
+ expect do
17
+ Chargify.configure do |c|
18
+ c.subdomain = "something-new"
19
+ end
20
+ end.to change { Chargify::Base.site.to_s }.to("https://something-new.chargify.com")
21
+ end
22
+
23
+ it "honors the site over the subdomain if it is specified" do
24
+ expect do
25
+ Chargify.configure do |c|
26
+ c.subdomain = "crazy-train"
27
+ c.site = "http://test-site.chargify-test.com"
28
+ c.api_key = "abc123"
29
+ end
30
+ end.to change { Chargify::Base.site.to_s }.to("http://test-site.chargify-test.com")
31
+ end
32
+
33
+ after do
34
+ Chargify.configure do |c|
35
+ c.subdomain = @original_subdomain
36
+ end
37
+ end
38
+ end
39
+
40
+ end
@@ -1,6 +1,4 @@
1
1
  # Taken from https://gist.github.com/238158/487a411c392e1fb2a0c00347e32444320f5cdd49
2
- require 'FakeWeb'
3
-
4
2
  module ActiveResource
5
3
 
6
4
  #
@@ -79,4 +77,4 @@ module ActiveResource
79
77
  end
80
78
 
81
79
  end
82
- end
80
+ end
@@ -8,11 +8,8 @@ require 'chargify_api_ares'
8
8
  RSpec.configure do |config|
9
9
  config.before(:all) do
10
10
  Chargify.configure do |c|
11
- c.subdomain = remote_configuration['subdomain']
12
11
  c.api_key = remote_configuration['api_key']
13
- if remote_configuration['site']
14
- c.site = remote_configuration['site']
15
- end
12
+ c.site = remote_configuration['site']
16
13
  end
17
14
  end
18
15
  end
@@ -34,4 +31,4 @@ def load_remote_configuration_file
34
31
  else
35
32
  {}
36
33
  end
37
- end
34
+ end
data/spec/spec_helper.rb CHANGED
@@ -19,6 +19,11 @@ Chargify.configure do |c|
19
19
  end
20
20
 
21
21
  RSpec.configure do |config|
22
+ config.filter_run :focused => true
23
+ config.run_all_when_everything_filtered = true
24
+ config.alias_example_to :fit, :focused => true
25
+ config.color_enabled = true
26
+
22
27
  config.after(:each) do
23
28
  ActiveResource::FakeResource.clean
24
29
  end
metadata CHANGED
@@ -1,36 +1,28 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: chargify_api_ares
3
- version: !ruby/object:Gem::Version
4
- hash: 15
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 4
9
- - 0
10
- version: 0.4.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Michael Klett
14
9
  - Nathan Verni
15
10
  - Rodrigo Franco
11
+ - Shay Frendt
16
12
  autorequire:
17
13
  bindir: bin
18
14
  cert_chain: []
19
-
20
- date: 2011-03-02 00:00:00 -08:00
15
+ date: 2011-10-19 00:00:00.000000000 -04:00
21
16
  default_executable:
22
17
  dependencies: []
23
-
24
- description: ""
18
+ description: ''
25
19
  email: support@chargify.com
26
20
  executables: []
27
-
28
21
  extensions: []
29
-
30
- extra_rdoc_files:
22
+ extra_rdoc_files:
31
23
  - LICENSE.txt
32
24
  - README.md
33
- files:
25
+ files:
34
26
  - .gitignore
35
27
  - LICENSE.txt
36
28
  - README.md
@@ -59,38 +51,30 @@ files:
59
51
  has_rdoc: true
60
52
  homepage: http://github.com/grasshopperlabs/chargify_api_ares
61
53
  licenses: []
62
-
63
54
  post_install_message:
64
- rdoc_options:
55
+ rdoc_options:
65
56
  - --charset=UTF-8
66
- require_paths:
57
+ require_paths:
67
58
  - lib
68
- required_ruby_version: !ruby/object:Gem::Requirement
59
+ required_ruby_version: !ruby/object:Gem::Requirement
69
60
  none: false
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- hash: 3
74
- segments:
75
- - 0
76
- version: "0"
77
- required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
66
  none: false
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- hash: 3
83
- segments:
84
- - 0
85
- version: "0"
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
86
71
  requirements: []
87
-
88
72
  rubyforge_project:
89
73
  rubygems_version: 1.6.2
90
74
  signing_key:
91
75
  specification_version: 3
92
76
  summary: A Chargify API wrapper for Ruby using ActiveResource
93
- test_files:
77
+ test_files:
94
78
  - spec/base_spec.rb
95
79
  - spec/components_spec.rb
96
80
  - spec/customer_spec.rb