Top Level Namespace

Defined Under Namespace

Modules: TestFrameworkHooks Classes: BugError, ClientErrorDetail, ClientErrorResponse, Hash, Hyperion, HyperionError, HyperionResult, HyperionUri, Multipart, PayloadDescriptor, ResponseDescriptor, RestRoute

Instance Method Summary collapse

Instance Method Details

#fake_route(route, return_value = nil) {|Hyperion::FakeServer::Request| ... } ⇒ Object

A simple wrapper around Hyperion::fake for the typical use case of one faked route. The return value can either be specified as an argument or as a function of the request (using the block).

The structure of a rack response is specified at rack.github.io Hyperion loosens these requirements a little. For instance, the headers hash may be nil, and the body does not need to be wrapped in an array. See kim_spec.rb for details. The massaging is done in FakeServer#massage_response.

Parameters:

  • route (RestRoute)

    The route to handle

  • return_value (Hash, String, rack_response) (defaults to: nil)

    The data to return in response to a request

Yields:

Yield Returns:

  • (Hash, String, rack_response)

    The data to return in response to a request



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

def fake_route(route, return_value=nil, &block)
  if return_value && block
    fail 'cannot provide both a return_value and block'
  end
  block = block || proc{return_value}
  Hyperion.fake(route.uri.base) do |svr|
    svr.allow(route, &block)
  end
end

#hyperion_raise(msg) ⇒ Object

Raises:



4
5
6
# File 'lib/hyperion/types/hyperion_error.rb', line 4

def hyperion_raise(msg)
  raise HyperionError, msg
end