<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -12,8 +12,8 @@ begin
     gem.authors = [&quot;Jon Larkowski&quot;, &quot;Sandro Turriate&quot;, &quot;Wolfram Arnold&quot;, &quot;Corey Grusden&quot;]
     gem.add_dependency 'httparty', '&gt;= 0.4.2'
     gem.add_development_dependency &quot;activesupport&quot;, '&gt;= 2.3.3'
-    gem.add_development_dependency &quot;rspec&quot;, '&gt;= 1.2.8'
-    gem.add_development_dependency 'thoughtbot-factory_girl', '&gt;= 1.2.2'
+    gem.add_development_dependency &quot;rspec&quot;, '&gt;= 1.2.9'
+    gem.add_development_dependency 'factory_girl', '&gt;= 1.2.3'
   end
 rescue LoadError
   puts &quot;Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler&quot;</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -138,10 +138,12 @@ module Mousetrap
 
     def update
       if subscription
-        self.class.put_resource 'customers', 'edit', code, attributes_for_api_with_subscription
+        response = self.class.put_resource 'customers', 'edit', code, attributes_for_api_with_subscription
       else
-        self.class.put_resource 'customers', 'edit-customer', code, attributes_for_api
+        response = self.class.put_resource 'customers', 'edit-customer', code, attributes_for_api
       end
+
+      raise response['error'] if response['error']
     end
   end
 end</diff>
      <filename>lib/mousetrap/customer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -188,8 +188,7 @@ describe Mousetrap::Customer do
           # We don't send code for existing API resources.
           attributes_for_api.delete(:code)
 
-          @customer.class.should_receive(:put_resource).with(
-            'customers', 'edit', @customer.code, attributes_for_api)
+          @customer.class.should_receive(:put_resource).with('customers', 'edit', @customer.code, attributes_for_api).and_return({:id =&gt; 'some_id'})
           @customer.save
         end
       end
@@ -204,8 +203,7 @@ describe Mousetrap::Customer do
           attributes_for_api.delete(:subscription)
           @customer.subscription = nil
 
-          @customer.class.should_receive(:put_resource).with(
-            'customers', 'edit-customer', @customer.code, attributes_for_api)
+          @customer.class.should_receive(:put_resource).with('customers', 'edit-customer', @customer.code, attributes_for_api).and_return({:id =&gt; 'some_id'})
           @customer.save
         end
       end
@@ -251,7 +249,7 @@ describe Mousetrap::Customer do
         @customer.send :create
       end
 
-      it &quot;raises error is CheddarGetter reports one&quot; do
+      it &quot;raises error if CheddarGetter reports one&quot; do
         @customer.class.stub :post_resource =&gt; {'error' =&gt; 'some error message'}
         expect { @customer.send(:create) }.to raise_error('some error message')
       end
@@ -275,6 +273,31 @@ describe Mousetrap::Customer do
         @customer.send(:create).should == { :some =&gt; :response }
       end
     end
+
+    describe &quot;#update&quot; do
+      context &quot;when there's a subscription instance&quot; do
+        let(:customer) { Mousetrap::Customer.new :code =&gt; 'some code' }
+
+        it &quot;puts the customer with subscription when there's a subscription instance&quot; do
+          customer.stub :subscription =&gt; stub
+          customer.stub :attributes_for_api_with_subscription =&gt; 'some attributes with subscription'
+          customer.class.should_receive(:put_resource).with('customers', 'edit', 'some code', 'some attributes with subscription').and_return({:id =&gt; 'some_id'})
+          customer.send :update
+        end
+
+        it &quot;puts just the customer when no subscription instance&quot; do
+          customer.stub :subscription =&gt; nil
+          customer.stub :attributes_for_api =&gt; 'some attributes'
+          customer.class.should_receive(:put_resource).with('customers', 'edit-customer', 'some code', 'some attributes').and_return({:id =&gt; 'some_id'})
+          customer.send :update
+        end
+
+        it &quot;raises error if CheddarGetter reports one&quot; do
+          customer.class.stub :put_resource =&gt; {'error' =&gt; 'some error message'}
+          expect { customer.send(:update) }.to raise_error('some error message')
+        end
+      end
+    end
   end
 end
 </diff>
      <filename>spec/mousetrap/customer_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9852e6adea3b82c6ec471455e295bdaf1a045582</id>
    </parent>
  </parents>
  <author>
    <name>Jon Larkowski</name>
    <email>jonlarkowski@gmail.com</email>
  </author>
  <url>http://github.com/hashrocket/mousetrap/commit/237de86ac4a04e31b3d63d1c2e7bca139d32394c</url>
  <id>237de86ac4a04e31b3d63d1c2e7bca139d32394c</id>
  <committed-date>2009-10-18T18:06:15-07:00</committed-date>
  <authored-date>2009-10-18T18:06:15-07:00</authored-date>
  <message>Add error handling to Customer update

Also, started using newest RSpec and Factory Girl.</message>
  <tree>bcdfdc4fc9f4d414b44470275fbef640369a13cb</tree>
  <committer>
    <name>Jon Larkowski</name>
    <email>jonlarkowski@gmail.com</email>
  </committer>
</commit>
