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.
19 20 21 22 23 |
# File 'lib/hyperion_test/fake_server.rb', line 19 def initialize(port) @port = port @kim = Kim.new(port: port) @kim.start end |
Instance Attribute Details
#port ⇒ Object
Returns the value of attribute port.
17 18 19 |
# File 'lib/hyperion_test/fake_server.rb', line 17 def port @port end |
Instance Method Details
#clear_routes ⇒ Object
37 38 39 |
# File 'lib/hyperion_test/fake_server.rb', line 37 def clear_routes @kim.clear_handlers end |
#configure(&configure_routes) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/hyperion_test/fake_server.rb', line 25 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
41 42 43 |
# File 'lib/hyperion_test/fake_server.rb', line 41 def teardown @kim.stop end |