method
requests
![Moderate documentation Importance_2](https://d2vfyqvduarcvs.cloudfront.net/images/importance_2.png?1349367920)
v3.2.8 -
Show latest stable
-
0 notes -
Class: ActiveResource::HttpMock
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3 (0)
- 2.1.0 (38)
- 2.2.1 (-1)
- 2.3.8 (0)
- 3.0.0 (-1)
- 3.0.9 (-2)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- 7.1.3.4
- What's this?
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