Module: Mimic

Defined in:
lib/mimic.rb,
lib/mimic/api.rb,
lib/mimic/fake_host.rb

Defined Under Namespace

Classes: API, FakeHost, Server

Constant Summary collapse

MIMIC_DEFAULT_PORT =
11988
MIMIC_DEFAULT_OPTIONS =
{
  :hostname => 'localhost',
  :port => MIMIC_DEFAULT_PORT,
  :remote_configuration_path => nil,
  :fork => true,
  :log => nil,
  :wait_timeout => 5
}

Class Method Summary collapse

Class Method Details

.cleanup!Object


29
30
31
# File 'lib/mimic.rb', line 29

def self.cleanup!
  Mimic::Server.instance.shutdown
end

.mimic(options = {}, &block) ⇒ Object


19
20
21
22
23
24
25
26
27
# File 'lib/mimic.rb', line 19

def self.mimic(options = {}, &block)
  options = MIMIC_DEFAULT_OPTIONS.merge(options)

  host = FakeHost.new(options).tap do |host|
    host.instance_eval(&block) if block_given?
    Server.instance.serve(host, options)
  end
  add_host(host)
end

.reset_all!Object


33
34
35
# File 'lib/mimic.rb', line 33

def self.reset_all!
  @hosts.each { |h| h.clear }
end