mousetrap 0.4.4 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/mousetrap/customer.rb +6 -0
- data/mousetrap.gemspec +2 -2
- data/spec/integration/smoke_test.rb +76 -0
- data/spec/mousetrap/customer_spec.rb +26 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/lib/mousetrap/customer.rb
CHANGED
data/mousetrap.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mousetrap}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.5.0"
|
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"]
|
12
|
-
s.date = %q{2009-10-
|
12
|
+
s.date = %q{2009-10-25}
|
13
13
|
s.description = %q{CheddarGetter API Client in Ruby}
|
14
14
|
s.email = %q{jonlarkowski@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -137,6 +137,82 @@ describe "The Wrapper Gem" do
|
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
+
describe ".update" do
|
141
|
+
describe "Given a customer" do
|
142
|
+
before :all do
|
143
|
+
@customer = Factory :new_customer
|
144
|
+
@api_customer = nil
|
145
|
+
|
146
|
+
# TODO: figure out why multiple records are being created even though
|
147
|
+
# we use "before :all". Until then, here's the kludge...
|
148
|
+
if Mousetrap::Customer.all.size == 1
|
149
|
+
@api_customer = Mousetrap::Customer.all.first
|
150
|
+
@customer = @api_customer
|
151
|
+
else
|
152
|
+
@customer.save
|
153
|
+
@api_customer = Mousetrap::Customer[@customer.code]
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
describe "When I update the customer, with only customer attributes" do
|
158
|
+
before :all do
|
159
|
+
@api_customer = Mousetrap::Customer[@customer.code]
|
160
|
+
|
161
|
+
updated_attributes = {
|
162
|
+
:first_name => 'new_first',
|
163
|
+
:last_name => 'new_last',
|
164
|
+
:email => 'new_email@example.com',
|
165
|
+
:company => 'new_company'
|
166
|
+
}
|
167
|
+
|
168
|
+
@customer = Mousetrap::Customer.new updated_attributes
|
169
|
+
@customer.code = @api_customer.code
|
170
|
+
@customer.id = @api_customer.id
|
171
|
+
|
172
|
+
Mousetrap::Customer.update(@api_customer.code, updated_attributes)
|
173
|
+
end
|
174
|
+
|
175
|
+
it_should_behave_like "a Customer record from CheddarGetter"
|
176
|
+
end
|
177
|
+
|
178
|
+
describe "When I update the customer, with customer and subscription attributes" do
|
179
|
+
before :all do
|
180
|
+
@api_customer = Mousetrap::Customer[@customer.code]
|
181
|
+
|
182
|
+
updated_attributes = {
|
183
|
+
:first_name => 'new_first',
|
184
|
+
:last_name => 'new_last',
|
185
|
+
:email => 'new_email@example.com',
|
186
|
+
:company => 'new_company',
|
187
|
+
:subscription_attributes => {
|
188
|
+
:plan_code => 'TEST',
|
189
|
+
:billing_first_name => 'new_billing_first',
|
190
|
+
:billing_last_name => 'new_billing_last',
|
191
|
+
:credit_card_number => '5555555555554444',
|
192
|
+
:credit_card_expiration_month => '01',
|
193
|
+
:credit_card_expiration_year => '2013',
|
194
|
+
:billing_zip_code => '12345'
|
195
|
+
}
|
196
|
+
}
|
197
|
+
|
198
|
+
@credit_card_type = 'mc'
|
199
|
+
|
200
|
+
@customer = Mousetrap::Customer.new updated_attributes
|
201
|
+
|
202
|
+
# set up our test comparison objects as if they came from API gets
|
203
|
+
@customer.code = @api_customer.code
|
204
|
+
@customer.id = @api_customer.id
|
205
|
+
@customer.subscription.send(:id=, @api_customer.subscription.id)
|
206
|
+
|
207
|
+
Mousetrap::Customer.update(@api_customer.code, updated_attributes)
|
208
|
+
end
|
209
|
+
|
210
|
+
it_should_behave_like "a Customer record from CheddarGetter"
|
211
|
+
it_should_behave_like "an active Subscription record from CheddarGetter"
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
140
216
|
describe "#cancel" do
|
141
217
|
describe "Given a customer" do
|
142
218
|
before :all do
|
@@ -114,6 +114,32 @@ describe Mousetrap::Customer do
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
+
describe '.update' do
|
118
|
+
def do_update
|
119
|
+
Mousetrap::Customer.update('some customer code', 'some attributes')
|
120
|
+
end
|
121
|
+
|
122
|
+
it "makes a new customer from the attributes" do
|
123
|
+
Mousetrap::Customer.should_receive(:new).with('some attributes').and_return(stub(:null_object => true))
|
124
|
+
do_update
|
125
|
+
end
|
126
|
+
|
127
|
+
it "sets the new customer code to the argument" do
|
128
|
+
customer = mock
|
129
|
+
customer.stub :update
|
130
|
+
Mousetrap::Customer.stub :new => customer
|
131
|
+
customer.should_receive(:code=).with('some customer code')
|
132
|
+
do_update
|
133
|
+
end
|
134
|
+
|
135
|
+
it "calls #update" do
|
136
|
+
customer = mock(:null_object => true)
|
137
|
+
Mousetrap::Customer.stub :new => customer
|
138
|
+
customer.should_receive :update
|
139
|
+
do_update
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
117
143
|
describe '#cancel' do
|
118
144
|
context "for existing records" do
|
119
145
|
it 'cancels' do
|
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
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Larkowski
|
@@ -12,7 +12,7 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2009-10-
|
15
|
+
date: 2009-10-25 00:00:00 -04:00
|
16
16
|
default_executable:
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|