Class: MockHttpSend
- Inherits:
-
Object
- Object
- MockHttpSend
- Defined in:
- lib/mock_http_send.rb
Instance Method Summary collapse
-
#initialize(mockfile) ⇒ MockHttpSend
constructor
A new instance of MockHttpSend.
- #send(url, method, headers = nil, body = nil) ⇒ Object
Constructor Details
#initialize(mockfile) ⇒ MockHttpSend
Returns a new instance of MockHttpSend.
2 3 4 |
# File 'lib/mock_http_send.rb', line 2 def initialize(mockfile) @mock_results = JSON.parse(File.open(mockfile).read) end |
Instance Method Details
#send(url, method, headers = nil, body = nil) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/mock_http_send.rb', line 6 def send(url, method, headers=nil, body = nil) @mock_results.each { |result| if result["url"] == url && result["method"] == method.to_s return result["response_code"], result["response_body"] end } return -1, "unable to find match for #{url},#{method} in mock file" end |