mousetrap 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/lib/mousetrap/customer.rb +4 -2
- data/mousetrap.gemspec +7 -7
- data/spec/integration/spike.rb +18 -0
- data/spec/mousetrap/customer_spec.rb +28 -5
- metadata +4 -4
data/Rakefile
CHANGED
@@ -12,8 +12,8 @@ begin
|
|
12
12
|
gem.authors = ["Jon Larkowski", "Sandro Turriate", "Wolfram Arnold", "Corey Grusden"]
|
13
13
|
gem.add_dependency 'httparty', '>= 0.4.2'
|
14
14
|
gem.add_development_dependency "activesupport", '>= 2.3.3'
|
15
|
-
gem.add_development_dependency "rspec", '>= 1.2.
|
16
|
-
gem.add_development_dependency '
|
15
|
+
gem.add_development_dependency "rspec", '>= 1.2.9'
|
16
|
+
gem.add_development_dependency 'factory_girl', '>= 1.2.3'
|
17
17
|
end
|
18
18
|
rescue LoadError
|
19
19
|
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
data/lib/mousetrap/customer.rb
CHANGED
@@ -138,10 +138,12 @@ module Mousetrap
|
|
138
138
|
|
139
139
|
def update
|
140
140
|
if subscription
|
141
|
-
self.class.put_resource 'customers', 'edit', code, attributes_for_api_with_subscription
|
141
|
+
response = self.class.put_resource 'customers', 'edit', code, attributes_for_api_with_subscription
|
142
142
|
else
|
143
|
-
self.class.put_resource 'customers', 'edit-customer', code, attributes_for_api
|
143
|
+
response = self.class.put_resource 'customers', 'edit-customer', code, attributes_for_api
|
144
144
|
end
|
145
|
+
|
146
|
+
raise response['error'] if response['error']
|
145
147
|
end
|
146
148
|
end
|
147
149
|
end
|
data/mousetrap.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mousetrap}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jon Larkowski", "Sandro Turriate", "Wolfram Arnold", "Corey Grusden"]
|
@@ -68,18 +68,18 @@ Gem::Specification.new do |s|
|
|
68
68
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
69
69
|
s.add_runtime_dependency(%q<httparty>, [">= 0.4.2"])
|
70
70
|
s.add_development_dependency(%q<activesupport>, [">= 2.3.3"])
|
71
|
-
s.add_development_dependency(%q<rspec>, [">= 1.2.
|
72
|
-
s.add_development_dependency(%q<
|
71
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
72
|
+
s.add_development_dependency(%q<factory_girl>, [">= 1.2.3"])
|
73
73
|
else
|
74
74
|
s.add_dependency(%q<httparty>, [">= 0.4.2"])
|
75
75
|
s.add_dependency(%q<activesupport>, [">= 2.3.3"])
|
76
|
-
s.add_dependency(%q<rspec>, [">= 1.2.
|
77
|
-
s.add_dependency(%q<
|
76
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
77
|
+
s.add_dependency(%q<factory_girl>, [">= 1.2.3"])
|
78
78
|
end
|
79
79
|
else
|
80
80
|
s.add_dependency(%q<httparty>, [">= 0.4.2"])
|
81
81
|
s.add_dependency(%q<activesupport>, [">= 2.3.3"])
|
82
|
-
s.add_dependency(%q<rspec>, [">= 1.2.
|
83
|
-
s.add_dependency(%q<
|
82
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
83
|
+
s.add_dependency(%q<factory_girl>, [">= 1.2.3"])
|
84
84
|
end
|
85
85
|
end
|
data/spec/integration/spike.rb
CHANGED
@@ -40,6 +40,24 @@ end
|
|
40
40
|
#create_customer
|
41
41
|
|
42
42
|
destroy_all_customers
|
43
|
+
customer = Factory :new_customer
|
44
|
+
customer.save
|
45
|
+
api_customer = Mousetrap::Customer[customer.code]
|
46
|
+
puts api_customer.to_yaml
|
47
|
+
puts '-' * 80
|
48
|
+
|
49
|
+
customer_only_fields = Mousetrap::Customer.new \
|
50
|
+
:first_name => 'first',
|
51
|
+
:last_name => 'last',
|
52
|
+
:company => 'company',
|
53
|
+
:email => 'random@example.com',
|
54
|
+
:code => customer.code
|
55
|
+
|
56
|
+
customer_only_fields.save
|
57
|
+
|
58
|
+
api_customer = Mousetrap::Customer[customer.code]
|
59
|
+
puts api_customer.to_yaml
|
60
|
+
|
43
61
|
|
44
62
|
#code = "rvhljmvenp@example.com"
|
45
63
|
#api_customer = Mousetrap::Customer[code]
|
@@ -188,8 +188,7 @@ describe Mousetrap::Customer do
|
|
188
188
|
# We don't send code for existing API resources.
|
189
189
|
attributes_for_api.delete(:code)
|
190
190
|
|
191
|
-
@customer.class.should_receive(:put_resource).with(
|
192
|
-
'customers', 'edit', @customer.code, attributes_for_api)
|
191
|
+
@customer.class.should_receive(:put_resource).with('customers', 'edit', @customer.code, attributes_for_api).and_return({:id => 'some_id'})
|
193
192
|
@customer.save
|
194
193
|
end
|
195
194
|
end
|
@@ -204,8 +203,7 @@ describe Mousetrap::Customer do
|
|
204
203
|
attributes_for_api.delete(:subscription)
|
205
204
|
@customer.subscription = nil
|
206
205
|
|
207
|
-
@customer.class.should_receive(:put_resource).with(
|
208
|
-
'customers', 'edit-customer', @customer.code, attributes_for_api)
|
206
|
+
@customer.class.should_receive(:put_resource).with('customers', 'edit-customer', @customer.code, attributes_for_api).and_return({:id => 'some_id'})
|
209
207
|
@customer.save
|
210
208
|
end
|
211
209
|
end
|
@@ -251,7 +249,7 @@ describe Mousetrap::Customer do
|
|
251
249
|
@customer.send :create
|
252
250
|
end
|
253
251
|
|
254
|
-
it "raises error
|
252
|
+
it "raises error if CheddarGetter reports one" do
|
255
253
|
@customer.class.stub :post_resource => {'error' => 'some error message'}
|
256
254
|
expect { @customer.send(:create) }.to raise_error('some error message')
|
257
255
|
end
|
@@ -275,6 +273,31 @@ describe Mousetrap::Customer do
|
|
275
273
|
@customer.send(:create).should == { :some => :response }
|
276
274
|
end
|
277
275
|
end
|
276
|
+
|
277
|
+
describe "#update" do
|
278
|
+
context "when there's a subscription instance" do
|
279
|
+
let(:customer) { Mousetrap::Customer.new :code => 'some code' }
|
280
|
+
|
281
|
+
it "puts the customer with subscription when there's a subscription instance" do
|
282
|
+
customer.stub :subscription => stub
|
283
|
+
customer.stub :attributes_for_api_with_subscription => 'some attributes with subscription'
|
284
|
+
customer.class.should_receive(:put_resource).with('customers', 'edit', 'some code', 'some attributes with subscription').and_return({:id => 'some_id'})
|
285
|
+
customer.send :update
|
286
|
+
end
|
287
|
+
|
288
|
+
it "puts just the customer when no subscription instance" do
|
289
|
+
customer.stub :subscription => nil
|
290
|
+
customer.stub :attributes_for_api => 'some attributes'
|
291
|
+
customer.class.should_receive(:put_resource).with('customers', 'edit-customer', 'some code', 'some attributes').and_return({:id => 'some_id'})
|
292
|
+
customer.send :update
|
293
|
+
end
|
294
|
+
|
295
|
+
it "raises error if CheddarGetter reports one" do
|
296
|
+
customer.class.stub :put_resource => {'error' => 'some error message'}
|
297
|
+
expect { customer.send(:update) }.to raise_error('some error message')
|
298
|
+
end
|
299
|
+
end
|
300
|
+
end
|
278
301
|
end
|
279
302
|
end
|
280
303
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mousetrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Larkowski
|
@@ -43,17 +43,17 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.2.
|
46
|
+
version: 1.2.9
|
47
47
|
version:
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
|
-
name:
|
49
|
+
name: factory_girl
|
50
50
|
type: :development
|
51
51
|
version_requirement:
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 1.2.
|
56
|
+
version: 1.2.3
|
57
57
|
version:
|
58
58
|
description: CheddarGetter API Client in Ruby
|
59
59
|
email: jonlarkowski@gmail.com
|