jsmestad-chargify 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -4,16 +4,17 @@ group :runtime do
4
4
  gem 'httparty', '~> 0.6.1'
5
5
  gem 'hashie', '~> 0.1.8'
6
6
  gem 'json'
7
+ gem 'activesupport', '~> 3.0.0', :require => 'active_support/all'
8
+ gem 'i18n'
7
9
  end
8
10
 
9
11
  group :test do
10
12
  gem 'jeweler'
11
13
  gem 'rake'
12
- gem 'bundler', '~> 0.9.26'
13
14
  gem 'fakeweb', '>= 1.2.5'
14
15
  gem 'mocha', '~> 0.9.8'
15
- gem 'rspec', '~> 2.0.0.beta.17'
16
- gem 'activesupport', '~> 3.0.0.beta.4', :require => 'active_support'
16
+ gem 'rspec', '~> 2.0.0.beta.22'
17
+
17
18
  gem 'autotest'
18
19
  end
19
20
 
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (3.0.0)
5
+ autotest (4.3.2)
6
+ crack (0.1.8)
7
+ diff-lcs (1.1.2)
8
+ fakeweb (1.3.0)
9
+ gemcutter (0.6.1)
10
+ git (1.2.5)
11
+ hashie (0.1.8)
12
+ httparty (0.6.1)
13
+ crack (= 0.1.8)
14
+ i18n (0.4.1)
15
+ jeweler (1.4.0)
16
+ gemcutter (>= 0.1.0)
17
+ git (>= 1.2.5)
18
+ rubyforge (>= 2.0.0)
19
+ json (1.4.6)
20
+ json_pure (1.4.6)
21
+ mocha (0.9.8)
22
+ rake
23
+ rake (0.8.7)
24
+ rspec (2.0.0.beta.22)
25
+ rspec-core (= 2.0.0.beta.22)
26
+ rspec-expectations (= 2.0.0.beta.22)
27
+ rspec-mocks (= 2.0.0.beta.22)
28
+ rspec-core (2.0.0.beta.22)
29
+ rspec-expectations (2.0.0.beta.22)
30
+ diff-lcs (>= 1.1.2)
31
+ rspec-mocks (2.0.0.beta.22)
32
+ rspec-core (= 2.0.0.beta.22)
33
+ rspec-expectations (= 2.0.0.beta.22)
34
+ rubyforge (2.0.4)
35
+ json_pure (>= 1.1.7)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ activesupport (~> 3.0.0)
42
+ autotest
43
+ fakeweb (>= 1.2.5)
44
+ hashie (~> 0.1.8)
45
+ httparty (~> 0.6.1)
46
+ i18n
47
+ jeweler
48
+ json
49
+ mocha (~> 0.9.8)
50
+ rake
51
+ rspec (~> 2.0.0.beta.22)
data/Rakefile CHANGED
@@ -12,6 +12,7 @@ begin
12
12
  gem.add_dependency('httparty', '~> 0.6.1')
13
13
  gem.add_dependency('hashie', '~> 0.1.8')
14
14
  gem.add_dependency('json')
15
+ gem.add_dependency('active_support', '>= 3.0.0')
15
16
  end
16
17
  Jeweler::GemcutterTasks.new
17
18
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{jsmestad-chargify}
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Wynn Netherland", "Justin Smestad"]
12
- s.date = %q{2010-07-21}
12
+ s.date = %q{2010-09-21}
13
13
  s.email = %q{justin.smestad@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  ".gitignore",
20
20
  ".rspec",
21
21
  "Gemfile",
22
+ "Gemfile.lock",
22
23
  "LICENSE",
23
24
  "README.markdown",
24
25
  "Rakefile",
@@ -83,15 +84,18 @@ Gem::Specification.new do |s|
83
84
  s.add_runtime_dependency(%q<httparty>, ["~> 0.6.1"])
84
85
  s.add_runtime_dependency(%q<hashie>, ["~> 0.1.8"])
85
86
  s.add_runtime_dependency(%q<json>, [">= 0"])
87
+ s.add_runtime_dependency(%q<active_support>, [">= 3.0.0"])
86
88
  else
87
89
  s.add_dependency(%q<httparty>, ["~> 0.6.1"])
88
90
  s.add_dependency(%q<hashie>, ["~> 0.1.8"])
89
91
  s.add_dependency(%q<json>, [">= 0"])
92
+ s.add_dependency(%q<active_support>, [">= 3.0.0"])
90
93
  end
91
94
  else
92
95
  s.add_dependency(%q<httparty>, ["~> 0.6.1"])
93
96
  s.add_dependency(%q<hashie>, ["~> 0.1.8"])
94
97
  s.add_dependency(%q<json>, [">= 0"])
98
+ s.add_dependency(%q<active_support>, [">= 3.0.0"])
95
99
  end
96
100
  end
97
101
 
@@ -59,6 +59,13 @@ module Chargify
59
59
  rescue Chargify::Error::Base => e
60
60
  return false
61
61
  end
62
+
63
+ def find_or_create(info={})
64
+ info.symbolize_keys!
65
+ self.lookup!(info[:reference])
66
+ rescue Chargify::Error::NotFound => e
67
+ self.create!(info)
68
+ end
62
69
 
63
70
  #
64
71
  # * first_name (Required)
@@ -112,6 +112,33 @@ describe Chargify::Customer do
112
112
  end
113
113
 
114
114
  end
115
+
116
+ describe '.find_or_create' do
117
+ it "should create a user if none is found" do
118
+ stub_get "https://OU812:x@pengwynn.chargify.com/customers/lookup.json?reference=bradleyjoyce", "", 404
119
+ info = {
120
+ :first_name => "Wynn",
121
+ :last_name => "Netherland",
122
+ :email => "wynn@example.com",
123
+ :reference => "bradleyjoyce"
124
+ }
125
+ Chargify::Customer.should_receive(:create!)
126
+ Chargify::Customer.find_or_create(info)
127
+ end
128
+
129
+ it "should return the found customer if one exists with the same reference" do
130
+ stub_get "https://OU812:x@pengwynn.chargify.com/customers/lookup.json?reference=bradleyjoyce", "customer.json"
131
+ info = {
132
+ :first_name => "Wynn",
133
+ :last_name => "Netherland",
134
+ :email => "wynn@example.com",
135
+ :reference => "bradleyjoyce"
136
+ }
137
+ Chargify::Customer.should_not_receive(:create!)
138
+ Chargify::Customer.find_or_create(info)
139
+ end
140
+
141
+ end
115
142
 
116
143
  describe '.update!' do
117
144
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsmestad-chargify
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Wynn Netherland
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-07-21 00:00:00 -06:00
19
+ date: 2010-09-21 00:00:00 -06:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -65,6 +65,22 @@ dependencies:
65
65
  version: "0"
66
66
  type: :runtime
67
67
  version_requirements: *id003
68
+ - !ruby/object:Gem::Dependency
69
+ name: active_support
70
+ prerelease: false
71
+ requirement: &id004 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 7
77
+ segments:
78
+ - 3
79
+ - 0
80
+ - 0
81
+ version: 3.0.0
82
+ type: :runtime
83
+ version_requirements: *id004
68
84
  description:
69
85
  email: justin.smestad@gmail.com
70
86
  executables: []
@@ -78,6 +94,7 @@ files:
78
94
  - .gitignore
79
95
  - .rspec
80
96
  - Gemfile
97
+ - Gemfile.lock
81
98
  - LICENSE
82
99
  - README.markdown
83
100
  - Rakefile