Flowdock
method

requests

Importance_2

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v3.2.13) is shown here.

requests() public

Returns an array of all request objects that have been sent to the mock. You can use this to check if your model actually sent an HTTP request.

Example

def setup
  @matz  = { :person => { :id => 1, :name => "Matz" } }.to_json
  ActiveResource::HttpMock.respond_to do |mock|
    mock.get "/people/1.json", {}, @matz
  end
end

def test_should_request_remote_service
  person = Person.find(1)  # Call the remote service

  # This request object has the same HTTP method and path as declared by the mock
  expected_request = ActiveResource::Request.new(:get, "/people/1.json")

  # Assert that the mock received, and responded to, the expected request from the model
  assert ActiveResource::HttpMock.requests.include?(expected_request)
end
Show source
Register or log in to add new notes.