Class: MockServer::MockServerClient
- Inherits:
-
AbstractClient
- Object
- AbstractClient
- MockServer::MockServerClient
- Includes:
- Model, UtilityMethods
- Defined in:
- lib/mockserver/mock_server_client.rb
Overview
The client used to interact with the mock server.
Constant Summary
Constants included from Model
MockServer::Model::DEFAULT_MISSING_INDEX
Instance Attribute Summary
Attributes inherited from AbstractClient
Instance Method Summary collapse
-
#register(expectation) ⇒ Object
Registers an expectation with the mockserver.
Methods included from UtilityMethods
#camelize, #camelized_hash, #parse_string_to_json, #symbolize_keys
Methods inherited from AbstractClient
#clear, #dump_log, #initialize, #reset, #retrieve, #verify
Methods included from MockServer::Model::DSL
#at_least, #body, #decode, #delay_by, #exact, #exactly, #expectation, #expectation_from_json, #forward, #once, #parameter, #parameterized, #regex, #request, #response, #times, #unlimited, #xpath
Constructor Details
This class inherits a constructor from MockServer::AbstractClient
Instance Method Details
#register(expectation) ⇒ Object
Registers an expectation with the mockserver
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mockserver/mock_server_client.rb', line 21 def register(expectation) fail 'Expectation passed in is not valid type' unless expectation.is_a?(Expectation) request = create_expectation_request(expectation) logger.debug('Registering new expectation') logger.debug("URL: #{EXPECTATION_ENDPOINT} Payload: #{request.to_hash}") response = @base[EXPECTATION_ENDPOINT].put(request.to_json, content_type: :json) logger.debug("Got register response: #{response.code}") parse_string_to_json(response) end |