--- !ruby/object:RI::ClassDescription 
attributes: []

class_methods: 
- !ruby/object:RI::MethodSummary 
  name: requests
- !ruby/object:RI::MethodSummary 
  name: reset!
- !ruby/object:RI::MethodSummary 
  name: respond_to
- !ruby/object:RI::MethodSummary 
  name: responses
comment: 
- !ruby/struct:SM::Flow::P 
  body: One thing that has always been a pain with remote web services is testing. The HttpMock class makes it easy to test your Active Resource models by creating a set of mock responses to specific requests.
- !ruby/struct:SM::Flow::P 
  body: "To test your Active Resource model, you simply call the ActiveResource::HttpMock.respond_to method with an attached block. The block declares a set of URIs with expected input, and the output each request should return. The passed in block has any number of entries in the following generalized format:"
- !ruby/struct:SM::Flow::VERB 
  body: "  mock.http_method(path, request_headers = {}, body = nil, status = 200, response_headers = {})\n"
- !ruby/object:SM::Flow::LIST 
  contents: 
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: <tt>http_method</tt> - The HTTP method to listen for. This can be <tt>get</tt>, <tt>post</tt>, <tt>put</tt>, <tt>delete</tt> or <tt>head</tt>.
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: <tt>path</tt> - A string, starting with a &quot;/&quot;, defining the URI that is expected to be called.
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: <tt>request_headers</tt> - Headers that are expected along with the request. This argument uses a hash format, such as <tt>{ &quot;Content-Type&quot; =&gt; &quot;application/xml&quot; }</tt>. This mock will only trigger if your tests sends a request with identical headers.
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: <tt>body</tt> - The data to be returned. This should be a string of Active Resource parseable content, such as XML.
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: <tt>status</tt> - The HTTP response code, as an integer, to return with the response.
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: <tt>response_headers</tt> - Headers to be returned with the response. Uses the same hash format as <tt>request_headers</tt> listed above.
  type: :BULLET
- !ruby/struct:SM::Flow::P 
  body: In order for a mock to deliver its content, the incoming request must match by the <tt>http_method</tt>, <tt>path</tt> and <tt>request_headers</tt>. If no match is found an InvalidRequestError exception will be raised letting you know you need to create a new mock for that request.
- !ruby/struct:SM::Flow::H 
  level: 4
  text: Example
- !ruby/struct:SM::Flow::VERB 
  body: "  def setup\n    @matz  = { :id =&gt; 1, :name =&gt; &quot;Matz&quot; }.to_xml(:root =&gt; &quot;person&quot;)\n    ActiveResource::HttpMock.respond_to do |mock|\n      mock.post   &quot;/people.xml&quot;,   {}, @matz, 201, &quot;Location&quot; =&gt; &quot;/people/1.xml&quot;\n      mock.get    &quot;/people/1.xml&quot;, {}, @matz\n      mock.put    &quot;/people/1.xml&quot;, {}, nil, 204\n      mock.delete &quot;/people/1.xml&quot;, {}, nil, 200\n    end\n  end\n\n  def test_get_matz\n    person = Person.find(1)\n    assert_equal &quot;Matz&quot;, person.name\n  end\n"
constants: []

full_name: ActiveResource::HttpMock
includes: []

instance_methods: []

name: HttpMock
superclass: Object
