MockServer - the Ruby gem for the MockServer API
MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby and a simple REST API (as shown below).
MockServer Proxy is a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding).
Both MockServer and the MockServer Proxy record all received requests so that it is possible to verify exactly what requests have been sent by the system under test.
This SDK is automatically generated by the OpenAPI Generator project:
- API version: 5.13.2
- Package version: 5.13.2
- Build package: org.openapitools.codegen.languages.RubyClientCodegen
To build the Ruby code into a gem:
gem build mockserver-client.gemspec
Then either install the gem locally:
gem install ./mockserver-client-5.13.2.gem
(for development, run gem install --dev ./mockserver-client-5.13.2.gem
to install the development dependencies)
or publish the gem to a gem hosting service, e.g. RubyGems.
Finally add this to the Gemfile:
gem 'mockserver-client', '~> 5.13.2'
If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile:
gem 'mockserver-client', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'
Include the Ruby code directly using -I
as follows:
ruby -Ilib script.rb
Please follow the installation procedure and then run the following code:
# Load the gem
require 'mockserver-client'
api_instance = MockServer::ControlApi.new
ports = MockServer::Ports.new # Ports | list of ports to bind to, where 0 indicates dynamically bind to any available port
begin
#bind additional listening ports
result = api_instance.mockserver_bind_put(ports)
p result
rescue MockServer::ApiError => e
puts "Exception when calling ControlApi->mockserver_bind_put: #{e}"
end
All URIs are relative to http://localhost:1080
Class | Method | HTTP request | Description |
---|---|---|---|
MockServer::ControlApi | mockserver_bind_put | PUT /mockserver/bind | bind additional listening ports |
MockServer::ControlApi | mockserver_clear_put | PUT /mockserver/clear | clears expectations and recorded requests that match the request matcher |
MockServer::ControlApi | mockserver_reset_put | PUT /mockserver/reset | clears all expectations and recorded requests |
MockServer::ControlApi | mockserver_retrieve_put | PUT /mockserver/retrieve | retrieve recorded requests, active expectations, recorded expectations or log messages |
MockServer::ControlApi | mockserver_status_put | PUT /mockserver/status | return listening ports |
MockServer::ControlApi | mockserver_stop_put | PUT /mockserver/stop | stop running process |
MockServer::ExpectationApi | mockserver_expectation_put | PUT /mockserver/expectation | create expectation |
MockServer::ExpectationApi | mockserver_openapi_put | PUT /mockserver/openapi | create expectations from OpenAPI or Swagger |
MockServer::VerifyApi | mockserver_verify_put | PUT /mockserver/verify | verify a request has been received a specific number of times |
MockServer::VerifyApi | mockserver_verify_sequence_put | PUT /mockserver/verifySequence | verify a sequence of request has been received in the specific order |
- MockServer::Body
- MockServer::BodyAnyOf
- MockServer::BodyAnyOf1
- MockServer::BodyAnyOf2
- MockServer::BodyAnyOf3
- MockServer::BodyAnyOf4
- MockServer::BodyAnyOf5
- MockServer::BodyAnyOf6
- MockServer::BodyAnyOf7
- MockServer::BodyAnyOf8
- MockServer::BodyAnyOf9
- MockServer::BodyWithContentType
- MockServer::BodyWithContentTypeAnyOf
- MockServer::BodyWithContentTypeAnyOf1
- MockServer::BodyWithContentTypeAnyOf2
- MockServer::BodyWithContentTypeAnyOf3
- MockServer::ConnectionOptions
- MockServer::Delay
- MockServer::Expectation
- MockServer::ExpectationId
- MockServer::Expectations
- MockServer::HttpClassCallback
- MockServer::HttpError
- MockServer::HttpForward
- MockServer::HttpObjectCallback
- MockServer::HttpOverrideForwardedRequest
- MockServer::HttpOverrideForwardedRequestOneOf
- MockServer::HttpOverrideForwardedRequestOneOf1
- MockServer::HttpOverrideForwardedRequestOneOfRequestModifier
- MockServer::HttpOverrideForwardedRequestOneOfRequestModifierCookies
- MockServer::HttpOverrideForwardedRequestOneOfRequestModifierPath
- MockServer::HttpOverrideForwardedRequestOneOfRequestModifierQueryStringParameters
- MockServer::HttpOverrideForwardedRequestOneOfResponseModifier
- MockServer::HttpRequest
- MockServer::HttpResponse
- MockServer::HttpTemplate
- MockServer::KeyToMultiValue
- MockServer::KeyToMultiValueOneOf
- MockServer::KeyToValue
- MockServer::OpenAPIDefinition
- MockServer::OpenAPIExpectation
- MockServer::OpenAPIExpectations
- MockServer::Ports
- MockServer::PositiveIntegerDefault0
- MockServer::RequestDefinition
- MockServer::Schema
- MockServer::SocketAddress
- MockServer::StringOrJsonSchema
- MockServer::StringOrJsonSchemaOneOf
- MockServer::TimeToLive
- MockServer::Times
- MockServer::Verification
- MockServer::VerificationSequence
- MockServer::VerificationTimes
All endpoints do not require authorization.