class NEC::MockServer::Server

Server class. Represent main class of module #MockServe

Attributes

app[R]
router[R]

Public Class Methods

new(router, application_opts = {}) click to toggle source

The method creates new instance of Rack::Server

@param [MockServer::Router] router @param [Hash] application_opts @option application_opts [String] :application_name @option opts [Regexp] :matcher Define how to split parts of all request URL. Default is to #MATCHERS @option opts [Boolean] :only_registered_awid If set to true all requests that wasn't call on registered awid (by sys/iniAppWorkspace) will be rejected @option opts [Hash{TID => Array<AWID>}] :awids @option opts [Hash{TID => Array<ASIDS>}] :asids

# File lib/nec_mock_server/mock_server.rb, line 23
def initialize(router, application_opts = {})
  @router = (router || Router).new(application_opts[:application_name])
  @app = Application.new(@router, application_opts)
end

Public Instance Methods

run!(port, host = 'localhost') click to toggle source

The method stars server of instance

@param [Numeric] port @param [String] host Default to 'localhost'

# File lib/nec_mock_server/mock_server.rb, line 33
def run!(port, host = 'localhost')
  @server = Rack::Server.start(app: @app, Port: port, Host: host)
end