Module: DnsMock

Defined in:
lib/dns_mock.rb,
lib/dns_mock/core.rb,
lib/dns_mock/server.rb,
lib/dns_mock/version.rb,
lib/dns_mock/error/helper.rb,
lib/dns_mock/response/answer.rb,
lib/dns_mock/record/builder/a.rb,
lib/dns_mock/record/factory/a.rb,
lib/dns_mock/response/message.rb,
lib/dns_mock/error/port_in_use.rb,
lib/dns_mock/error/record_type.rb,
lib/dns_mock/record/builder/mx.rb,
lib/dns_mock/record/builder/ns.rb,
lib/dns_mock/record/factory/mx.rb,
lib/dns_mock/record/factory/ns.rb,
lib/dns_mock/record/builder/ptr.rb,
lib/dns_mock/record/builder/soa.rb,
lib/dns_mock/record/builder/srv.rb,
lib/dns_mock/record/builder/txt.rb,
lib/dns_mock/record/factory/ptr.rb,
lib/dns_mock/record/factory/soa.rb,
lib/dns_mock/record/factory/srv.rb,
lib/dns_mock/record/factory/txt.rb,
lib/dns_mock/error/argument_type.rb,
lib/dns_mock/record/builder/aaaa.rb,
lib/dns_mock/record/builder/base.rb,
lib/dns_mock/record/factory/aaaa.rb,
lib/dns_mock/record/factory/base.rb,
lib/dns_mock/error/record_context.rb,
lib/dns_mock/record/builder/cname.rb,
lib/dns_mock/record/factory/cname.rb,
lib/dns_mock/representer/punycode.rb,
lib/dns_mock/error/random_free_port.rb,
lib/dns_mock/error/record_host_type.rb,
lib/dns_mock/error/record_not_found.rb,
lib/dns_mock/representer/rdns_lookup.rb,
lib/dns_mock/error/record_context_type.rb,
lib/dns_mock/test_framework/rspec/helper.rb,
lib/dns_mock/test_framework/rspec/interface.rb,
lib/dns_mock/server/records_dictionary_builder.rb

Defined Under Namespace

Modules: Error, Record, Representer, Response, TestFramework Classes: Server

Constant Summary collapse

AVAILABLE_DNS_RECORD_TYPES =
%i[a aaaa cname mx ns ptr soa srv txt].freeze
VERSION =
'1.7.4'

Class Method Summary collapse

Class Method Details

.running_serversObject



11
12
13
# File 'lib/dns_mock.rb', line 11

def running_servers
  ::ObjectSpace.each_object(DnsMock::Server).select(&:alive?)
end

.start_server(server = DnsMock::Server, records: {}, port: nil, exception_if_not_found: false) ⇒ Object



7
8
9
# File 'lib/dns_mock.rb', line 7

def start_server(server = DnsMock::Server, records: {}, port: nil, exception_if_not_found: false)
  server.new(records: records, port: port, exception_if_not_found: exception_if_not_found)
end

.stop_running_servers!Object



15
16
17
# File 'lib/dns_mock.rb', line 15

def stop_running_servers!
  running_servers.all?(&:stop!)
end