Sha256: d3d4871202739e06878b20a37a71a75d929b72770762e94e900acc943f19fdee

Contents?: true

Size: 802 Bytes

Versions: 13

Compression:

Stored size: 802 Bytes

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] 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
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

13 entries across 13 versions & 1 rubygems

Version Path
hyperion_http-0.3.0 lib/hyperion_test/spec_helper.rb
hyperion_http-0.2.4 lib/hyperion_test/spec_helper.rb
hyperion_http-0.2.3 lib/hyperion_test/spec_helper.rb
hyperion_http-0.2.2 lib/hyperion_test/spec_helper.rb
hyperion_http-0.2.1 lib/hyperion_test/spec_helper.rb
hyperion_http-0.1.9 lib/hyperion_test/spec_helper.rb
hyperion_http-0.1.8 lib/hyperion_test/spec_helper.rb
hyperion_http-0.1.7 lib/hyperion_test/spec_helper.rb
hyperion_http-0.1.6 lib/hyperion_test/spec_helper.rb
hyperion_http-0.1.5 lib/hyperion_test/spec_helper.rb
hyperion_http-0.1.4 lib/hyperion_test/spec_helper.rb
hyperion_http-0.1.3 lib/hyperion_test/spec_helper.rb
hyperion_http-0.1.2 lib/hyperion_test/spec_helper.rb