Sha256: 0d525c771e28ad9da456442888cf80d03d04bebe1cc8fb3d76795044b4385e5d

Contents?: true

Size: 907 Bytes

Versions: 8

Compression:

Stored size: 907 Bytes

Contents

class Hyperion
  class FakeServer
    class Config
      # this is passed to the block to allow the caller to configure the fake server

      include Hyperion::Headers
      include Hyperion::Logger

      def rules
        @rules ||= []
      end

      # allow(route)
      # allow(method, path, headers={})
      def allow(*args, &handler)
        rule = allowed_rule(args, handler)
        rules << rule
        log_stub(rule)
      end

      private

      def allowed_rule(args, handler)
        if args.size == 1 && args.first.is_a?(RestRoute)
          route = args.first
          Rule.new(MimicRoute.new(route.method, route.uri.path), route_headers(route), handler, route)
        else
          # TODO: deprecate this
          method, path, headers = args
          headers ||= {}
          Rule.new(MimicRoute.new(method, path), headers, handler, nil)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hyperion_http-0.1.9 lib/hyperion_test/fake_server/config.rb
hyperion_http-0.1.8 lib/hyperion_test/fake_server/config.rb
hyperion_http-0.1.7 lib/hyperion_test/fake_server/config.rb
hyperion_http-0.1.6 lib/hyperion_test/fake_server/config.rb
hyperion_http-0.1.5 lib/hyperion_test/fake_server/config.rb
hyperion_http-0.1.4 lib/hyperion_test/fake_server/config.rb
hyperion_http-0.1.3 lib/hyperion_test/fake_server/config.rb
hyperion_http-0.1.2 lib/hyperion_test/fake_server/config.rb