Class: Hyperion::FakeServer
- Inherits:
-
Object
- Object
- Hyperion::FakeServer
- Includes:
- Formats, Headers, Kim::Matchers
- Defined in:
- lib/hyperion_test/fake_server.rb,
lib/hyperion_test/fake_server/types.rb,
lib/hyperion_test/fake_server/config.rb
Defined Under Namespace
Constant Summary collapse
- Request =
ImmutableStruct.new(:body)
Constants included from Headers
Instance Attribute Summary collapse
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
- #clear_routes ⇒ Object
- #configure(&configure_routes) ⇒ Object
-
#initialize(port) ⇒ FakeServer
constructor
A new instance of FakeServer.
- #teardown ⇒ Object
Methods included from Formats
Methods included from Logger
#log_result, #log_stub, #logger, #with_request_logging
Methods included from Headers
#content_type_for, #format_for, #route_headers, #short_mimetype
Methods included from Kim::Matchers
#req_headers, #req_params, #res, #verb
Constructor Details
#initialize(port) ⇒ FakeServer
Returns a new instance of FakeServer.
20 21 22 23 24 |
# File 'lib/hyperion_test/fake_server.rb', line 20 def initialize(port) @port = port @kim = Kim.new(port: port) @kim.start end |
Instance Attribute Details
#port ⇒ Object
Returns the value of attribute port.
18 19 20 |
# File 'lib/hyperion_test/fake_server.rb', line 18 def port @port end |
Instance Method Details
#clear_routes ⇒ Object
38 39 40 |
# File 'lib/hyperion_test/fake_server.rb', line 38 def clear_routes @kim.clear_handlers end |
#configure(&configure_routes) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/hyperion_test/fake_server.rb', line 26 def configure(&configure_routes) config = Config.new configure_routes.call(config) config.rules.each do |rule| matcher = Kim::Matcher.and(verb(rule.verb), res(rule.path), req_headers(rule.headers)) handler = wrap(rule.handler, rule.rest_route) @kim.add_handler(matcher, &handler) end end |
#teardown ⇒ Object
42 43 44 |
# File 'lib/hyperion_test/fake_server.rb', line 42 def teardown @kim.stop end |