Sha256: 9031fc68c10157c2914f11e0082e9b26f955191185016c333712f051d224a1c1
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
require 'hyperion_test' # 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). # # @param [RestRoute] route The route to handle # @param [Hash, String, rack_response] return_value The data to return in response to a request # @yield [Hyperion::FakeServer::Request] Yields a request object containing the deserialized request body # @yieldreturn [Hash, String, rack_response] The data to return in response to a request # # The structure of a rack response is specified at http://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. 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
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hyperion_http-0.6.0 | lib/hyperion_test/spec_helper.rb |
hyperion_http-0.5.0 | lib/hyperion_test/spec_helper.rb |