module TestsDoc::RecordSpecHelper

Public Instance Methods

delete(*) click to toggle source
Calls superclass method
# File lib/tests_doc/record_spec_helper.rb, line 26
def delete(*)
  record_interaction { super }
end
get(*) click to toggle source
Calls superclass method
# File lib/tests_doc/record_spec_helper.rb, line 14
def get(*)
  record_interaction { super }
end
post(*) click to toggle source
Calls superclass method
# File lib/tests_doc/record_spec_helper.rb, line 18
def post(*)
  record_interaction { super }
end
put(*) click to toggle source
Calls superclass method
# File lib/tests_doc/record_spec_helper.rb, line 22
def put(*)
  record_interaction { super }
end
recording_api_interaction(path: nil, key: nil, description: nil, whitelist: nil) { |interaction_options| ... } click to toggle source
# File lib/tests_doc/record_spec_helper.rb, line 5
def recording_api_interaction(path: nil, key: nil, description: nil, whitelist: nil)
  TestsDoc.recorded_api_interaction = true
  TestsDoc.interaction_options      = OpenStruct.new(path: path, key: key, description: description, whitelist: whitelist)

  yield TestsDoc.interaction_options
ensure
  TestsDoc.interaction_options = nil
end

Private Instance Methods

record_interaction() { || ... } click to toggle source
# File lib/tests_doc/record_spec_helper.rb, line 32
def record_interaction
  result = yield

  if TestsDoc.interaction_options
    TestsDoc::Interaction.new(
      RSpec.respond_to?(:current_example) ? RSpec.current_example : example,
      request,
      response,
      TestsDoc.interaction_options
    ).record
  end

  result
end