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
}

Class Method Summary collapse

Class Method Details

.cleanup!Object



26
27
28
# File 'lib/mimic.rb', line 26

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

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



16
17
18
19
20
21
22
23
24
# File 'lib/mimic.rb', line 16

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

  host = FakeHost.new(options[:hostname], options[:remote_configuration_path]).tap do |host|
    host.instance_eval(&block) if block_given?
    Server.instance.serve(host, options[:port], options[:fork])
  end
  add_host(host)
end

.reset_all!Object



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

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