Sha256: 9b26a7607b796a94eb894573e38337c3664865d88db4733d9ee08f7705ed79f5

Contents?: true

Size: 842 Bytes

Versions: 7

Compression:

Stored size: 842 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(route.method, route.uri.path, route_headers(route), handler, route)
        else
          method, path, headers = args
          headers ||= {}
          Rule.new(method, path, headers, handler, nil)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hyperion_http-0.6.0 lib/hyperion_test/fake_server/config.rb
hyperion_http-0.5.0 lib/hyperion_test/fake_server/config.rb
hyperion_http-0.3.0 lib/hyperion_test/fake_server/config.rb
hyperion_http-0.2.4 lib/hyperion_test/fake_server/config.rb
hyperion_http-0.2.3 lib/hyperion_test/fake_server/config.rb
hyperion_http-0.2.2 lib/hyperion_test/fake_server/config.rb
hyperion_http-0.2.1 lib/hyperion_test/fake_server/config.rb