Sha256: 7ee1576e559d9dc6c2fbaf7f350b1633d94c75182f8190e3ef6f3782076f705b
Contents?: true
Size: 1.04 KB
Versions: 15
Compression:
Stored size: 1.04 KB
Contents
module RspecApiDocs module Dsl # Used to store request/response pairs. class RequestStore attr_reader :metadata def initialize(example) @metadata = example.metadata end # Only needed if you need to store multiple requests for a single example. # # Usage: # # it 'stores the requests a character' do # doc do # explanation 'Creating and requesting a character' # end # # post '/characters', {name: 'Finn The Human'} # # doc << [last_request, last_response] # # get '/characters/1' # # # The last request/response pair is stored automatically # end # # @param value [Array<Rack::Request, Rack::Response>] an array of a request and response object # @return [void] def <<(value) metadata[METADATA_NAMESPACE][:requests] ||= [] metadata[METADATA_NAMESPACE][:requests] << value.sort_by { |v| v.class.name }.reverse end end end end
Version data entries
15 entries across 15 versions & 1 rubygems