Module: Skooma::Matchers::Wrapper::DefaultHelperMethods

Defined in:
lib/skooma/matchers/wrapper.rb

Instance Method Summary collapse

Instance Method Details

#mapped_response(with_response: true, with_request: true) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/skooma/matchers/wrapper.rb', line 16

def mapped_response(with_response: true, with_request: true)
  Skooma::EnvMapper.call(
    request_object.env,
    response_object,
    with_response: with_response,
    with_request: with_request
  )
end

#request_objectObject



25
26
27
28
29
30
31
32
# File 'lib/skooma/matchers/wrapper.rb', line 25

def request_object
  # `rails` integration
  return @request if defined?(::ActionDispatch) && @request.is_a?(::ActionDispatch::Request)
  # `rack-test` integration
  return last_request if defined?(::Rack::Test) && defined?(:last_request)

  raise "Request object not found"
end

#response_objectObject



34
35
36
37
38
39
40
41
# File 'lib/skooma/matchers/wrapper.rb', line 34

def response_object
  # `rails` integration
  return @response if defined?(::ActionDispatch) && @response.is_a?(::ActionDispatch::Response)
  # `rack-test` integration
  return last_response if defined?(::Rack::Test) && defined?(:last_response)

  raise "Response object not found"
end

#skooma_openapi_schemaObject



43
44
45
# File 'lib/skooma/matchers/wrapper.rb', line 43

def skooma_openapi_schema
  skooma.schema
end