class RspecWebServiceOutputter::Request

Public Class Methods

new(request) click to toggle source
# File lib/rspec-webservice-outputter/base.rb, line 30
def initialize(request)
  @request = request
end

Public Instance Methods

to_s() click to toggle source
# File lib/rspec-webservice-outputter/base.rb, line 34
def to_s
  "REQUEST:\n" \
  "#{@request.method} #{@request.path}#{query_string}\n#{request_body}"
end

Private Instance Methods

query_string() click to toggle source
# File lib/rspec-webservice-outputter/base.rb, line 41
def query_string
  "?#{@request.query_string}" if @request.query_string && !@request.query_string.empty?
end
request_body() click to toggle source
# File lib/rspec-webservice-outputter/base.rb, line 45
def request_body
  request_body = @request.body.read
  return unless request_body && !request_body.empty?
  begin
    JSON.pretty_generate(JSON.parse(@request.body.read))
  rescue
    "[Non-JSON request body]"
  end
end