Sha256: 868256c9b1152ee8b1d1eeb97e1de9676ef95513dd5ca4082eeeed36a9125c34

Contents?: true

Size: 737 Bytes

Versions: 8

Compression:

Stored size: 737 Bytes

Contents

module Esplanade
  class Response
    class Doc
      def initialize(request, raw)
        @request = request
        @raw = raw
      end

      def tomogram
        @tomogram ||= @request.doc.responses.find_all { |response| response['status'] == @raw.status }
        raise NotDocumented, message if @tomogram == []
        @tomogram
      end

      def json_schemas
        @json_schemas ||= tomogram.map { |action| action['body'] }
      end

      def status
        @status ||= tomogram['status']
      end

      private

      def message
        {
          request: {
            method: @request.raw.method,
            path: @request.raw.path
          },
          status: @raw.status
        }
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
esplanade-1.3.0 lib/esplanade/response/doc.rb
esplanade-1.2.1 lib/esplanade/response/doc.rb
esplanade-1.2.0 lib/esplanade/response/doc.rb
esplanade-1.1.2 lib/esplanade/response/doc.rb
esplanade-1.1.1 lib/esplanade/response/doc.rb
esplanade-1.1.0 lib/esplanade/response/doc.rb
esplanade-1.0.1 lib/esplanade/response/doc.rb
esplanade-1.0.0 lib/esplanade/response/doc.rb