<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,7 @@
 desc &quot;Run all specs&quot;
 task :spec do
-  require 'spec/all.rb'
+  dir = File.expand_path(File.dirname(__FILE__) + '/spec')
+  Dir[File.expand_path(&quot;#{dir}/**/*.rb&quot;)].uniq.each do |file|
+    require file unless file.include?(&quot;helper&quot;)
+  end
 end
\ No newline at end of file</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,7 @@ require 'builder'
 require 'design'
 require 'net/http'
 require 'uri'
+require 'hpricot'
 
 module Moo
   class Order &lt; OptionsStruct.create(:api_key, :designs)
@@ -23,15 +24,33 @@ module Moo
     end
     
     def to_xml(xml=nil)
-      xml = Builder::XmlMarkup.new(:target =&gt; (@xml_s ||= &quot;&quot;)) unless xml
+      xml = Builder::XmlMarkup.new(:target =&gt; (@xml_string ||= &quot;&quot;)) unless xml
       eval File.open(File.expand_path(File.dirname(__FILE__) + &quot;/template.xml.builder&quot;)).read
       xml.target!
     end
     
+    attr_accessor :raw_response, :error_string, :error_code, :session_id, :start_url
     def submit
       res = Net::HTTP.post_form(URI.parse('http://www.moo.com/api/api.php'),
                                     {'xml'=&gt;self.to_xml, 'method'=&gt;'direct'})
-      puts res.body
+      @raw_response = res.body
+      process_response
+      !@error
+    end
+    
+    def process_response
+      @response = Hpricot(raw_response)
+      if error?
+        @error_string = @response.search('error_string').inner_html
+        @error_code = @response.search('error_code').inner_html
+      else
+        @session_id = @response.search('session_id').inner_html
+        @start_url = @response.search('start_url').inner_html
+      end
+    end
+    
+    def error?
+      @error ||= (@response.search('error').inner_html == &quot;true&quot;)
     end
   end
   </diff>
      <filename>lib/moo.rb</filename>
    </modified>
    <modified>
      <diff>@@ -41,4 +41,45 @@ describe &quot;a moo order with a minicard&quot; do
   it &quot;should include the xml for the minicard&quot; do
     @moo.to_xml.should include(@minicard.to_xml)
   end
+end
+
+describe &quot;processing an XML response for failure&quot; do
+  before :each do
+    @moo = Moo::Order.new :api_key =&gt; &quot;TESTAPIKEY&quot;
+    @moo.stub!(:raw_response).and_return('&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;moo&gt;  &lt;response&gt;  &lt;call&gt;build&lt;/call&gt;  &lt;error&gt;true&lt;/error&gt;  &lt;/response&gt;  &lt;payload&gt;  &lt;error_code&gt;1&lt;/error_code&gt;  &lt;error_string&gt;Error importing XML document&lt;/error_string&gt;  &lt;/payload&gt; &lt;/moo&gt;')
+    @moo.process_response
+  end
+  
+  it &quot;should set error? as true&quot; do
+    @moo.error?.should be_true
+  end
+  
+  it &quot;should set error_string correctly&quot; do
+    @moo.error_string.should == &quot;Error importing XML document&quot;
+  end
+  
+  it &quot;should set error_code correctly&quot; do
+    @moo.error_code.should == &quot;1&quot;
+  end
+end
+
+
+describe &quot;processing an XML response for success&quot; do
+  before :each do
+    @moo = Moo::Order.new :api_key =&gt; &quot;TESTAPIKEY&quot;
+    @moo.stub!(:raw_response).and_return('&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;moo&gt; &lt;response&gt; &lt;call&gt;build&lt;/call&gt; &lt;api_key&gt;3ddbe3c0-17ac-c0a802d2-47bafd19-2473&lt;/api_key&gt; &lt;/response&gt; &lt;payload&gt; &lt;session_id&gt;d4c7a6d179fca910d67221a57a1bf966&lt;/session_id&gt; &lt;start_url&gt;http://www.moo.com/make/designback.php?bid=1&amp;pid=115&amp;SID=d4c7a6d179fca910d67221a57a1bf966&lt;/start_url&gt; &lt;/payload&gt; &lt;/moo&gt;')
+    @moo.process_response
+  end
+  
+  it &quot;should set error? as false&quot; do
+    @moo.error?.should be_false
+  end
+  
+  it &quot;should set start_url correctly&quot; do
+    @moo.start_url.should == &quot;http://www.moo.com/make/designback.php?bid=1&amp;pid=115&amp;SID=d4c7a6d179fca910d67221a57a1bf966&quot;
+  end
+  
+  it &quot;should set session_id correctly&quot; do
+    @moo.session_id.should == &quot;d4c7a6d179fca910d67221a57a1bf966&quot;
+  end
 end
\ No newline at end of file</diff>
      <filename>spec/moo_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,4 @@
 $:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
-$:.unshift File.expand_path(File.dirname(__FILE__))
 
 require 'rubygems'
 require 'spec'</diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>spec/all.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>176b4dae17df68d946dd27b7d7f9cf542b3c4c64</id>
    </parent>
  </parents>
  <author>
    <name>James Darling</name>
    <email>abscond@Sam.local</email>
  </author>
  <url>http://github.com/infovore/ruminant/commit/9f678aa4e9119e391e4876fee279c4fa094bd075</url>
  <id>9f678aa4e9119e391e4876fee279c4fa094bd075</id>
  <committed-date>2008-08-25T13:26:15-07:00</committed-date>
  <authored-date>2008-08-25T13:26:15-07:00</authored-date>
  <message>posting!</message>
  <tree>e2c3488f87100790622b4fe6565318e8e4c83237</tree>
  <committer>
    <name>James Darling</name>
    <email>abscond@Sam.local</email>
  </committer>
</commit>
