<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -90,6 +90,12 @@ module Mousetrap
       customer
     end
 
+    def self.update(customer_code, attributes)
+      customer = new(attributes)
+      customer.code = customer_code
+      customer.send :update
+    end
+
 
     protected
 </diff>
      <filename>lib/mousetrap/customer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -137,6 +137,82 @@ describe &quot;The Wrapper Gem&quot; do
       end
     end
 
+    describe &quot;.update&quot; do
+      describe &quot;Given a customer&quot; do
+        before :all do
+          @customer = Factory :new_customer
+          @api_customer = nil
+
+          # TODO: figure out why multiple records are being created even though
+          # we use &quot;before :all&quot;.  Until then, here's the kludge...
+          if Mousetrap::Customer.all.size == 1
+            @api_customer = Mousetrap::Customer.all.first
+            @customer = @api_customer
+          else
+            @customer.save
+            @api_customer = Mousetrap::Customer[@customer.code]
+          end
+        end
+
+        describe &quot;When I update the customer, with only customer attributes&quot; do
+          before :all do
+            @api_customer = Mousetrap::Customer[@customer.code]
+
+            updated_attributes = {
+              :first_name =&gt; 'new_first',
+              :last_name =&gt; 'new_last',
+              :email =&gt; 'new_email@example.com',
+              :company =&gt; 'new_company'
+            }
+
+            @customer = Mousetrap::Customer.new updated_attributes
+            @customer.code = @api_customer.code
+            @customer.id = @api_customer.id
+
+            Mousetrap::Customer.update(@api_customer.code, updated_attributes)
+          end
+
+          it_should_behave_like &quot;a Customer record from CheddarGetter&quot;
+        end
+
+        describe &quot;When I update the customer, with customer and subscription attributes&quot; do
+          before :all do
+            @api_customer = Mousetrap::Customer[@customer.code]
+
+            updated_attributes = {
+              :first_name =&gt; 'new_first',
+              :last_name =&gt; 'new_last',
+              :email =&gt; 'new_email@example.com',
+              :company =&gt; 'new_company',
+              :subscription_attributes =&gt; {
+                :plan_code                    =&gt; 'TEST',
+                :billing_first_name           =&gt; 'new_billing_first',
+                :billing_last_name            =&gt; 'new_billing_last',
+                :credit_card_number           =&gt; '5555555555554444',
+                :credit_card_expiration_month =&gt; '01',
+                :credit_card_expiration_year  =&gt; '2013',
+                :billing_zip_code             =&gt; '12345'
+              }
+            }
+
+            @credit_card_type = 'mc'
+
+            @customer = Mousetrap::Customer.new updated_attributes
+
+            # set up our test comparison objects as if they came from API gets
+            @customer.code = @api_customer.code
+            @customer.id = @api_customer.id
+            @customer.subscription.send(:id=, @api_customer.subscription.id)
+
+            Mousetrap::Customer.update(@api_customer.code, updated_attributes)
+          end
+
+          it_should_behave_like &quot;a Customer record from CheddarGetter&quot;
+          it_should_behave_like &quot;an active Subscription record from CheddarGetter&quot;
+        end
+      end
+    end
+
     describe &quot;#cancel&quot; do
       describe &quot;Given a customer&quot; do
         before :all do</diff>
      <filename>spec/integration/smoke_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -114,6 +114,32 @@ describe Mousetrap::Customer do
     end
   end
 
+  describe '.update' do
+    def do_update
+      Mousetrap::Customer.update('some customer code', 'some attributes')
+    end
+
+    it &quot;makes a new customer from the attributes&quot; do
+      Mousetrap::Customer.should_receive(:new).with('some attributes').and_return(stub(:null_object =&gt; true))
+      do_update
+    end
+
+    it &quot;sets the new customer code to the argument&quot; do
+      customer = mock
+      customer.stub :update
+      Mousetrap::Customer.stub :new =&gt; customer
+      customer.should_receive(:code=).with('some customer code')
+      do_update
+    end
+
+    it &quot;calls #update&quot; do
+      customer = mock(:null_object =&gt; true)
+      Mousetrap::Customer.stub :new =&gt; customer
+      customer.should_receive :update
+      do_update
+    end
+  end
+
   describe '#cancel' do
     context &quot;for existing records&quot; do
       it 'cancels' do</diff>
      <filename>spec/mousetrap/customer_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>838bce6754aceaf82331371b196f069efd5998fd</id>
    </parent>
  </parents>
  <author>
    <name>Jon Larkowski</name>
    <email>jonlarkowski@gmail.com</email>
  </author>
  <url>http://github.com/hashrocket/mousetrap/commit/4e71052f5d5e001d96a33522e62b5a94569e76c5</url>
  <id>4e71052f5d5e001d96a33522e62b5a94569e76c5</id>
  <committed-date>2009-10-25T20:11:22-07:00</committed-date>
  <authored-date>2009-10-25T20:11:22-07:00</authored-date>
  <message>Add Customer.update functionality</message>
  <tree>6cd920d96c165d80f2720f72679f6c9cb525e869</tree>
  <committer>
    <name>Jon Larkowski</name>
    <email>jonlarkowski@gmail.com</email>
  </committer>
</commit>
