Sha256: df9a708d2520179a15399cf28daa8d7c4e2b36c7e49892bbd4ab19439749126e

Contents?: true

Size: 505 Bytes

Versions: 20

Compression:

Stored size: 505 Bytes

Contents

# frozen_string_literal: true

# rubocop:disable Style/EvalWithLocation
module Net
  # Override Net::HTTPResponse for create response with body
  class HTTPResponse
    def self.mock(body = {}.to_json)
      # construct
      clazz = self
      response = clazz.new('1.1', '200', 'OK')

      # inject
      response.instance_variable_set :@body, body

      # mockulate
      response.instance_eval 'def body; @body.to_json; end'

      response
    end
  end
end
# rubocop:enable Style/EvalWithLocation

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
evostream-event-2.0.3 lib/evostream/event/response/mock.rb
evostream-event-2.0.3.pre.1265906291 lib/evostream/event/response/mock.rb
evostream-event-2.0.3.pre.1265756691 lib/evostream/event/response/mock.rb
evostream-event-2.0.3.pre.1265752332 lib/evostream/event/response/mock.rb
evostream-event-2.0.2 lib/evostream/event/response/mock.rb
evostream-event-2.0.2.pre.994185738 lib/evostream/event/response/mock.rb
evostream-event-2.0.0.pre.994170151 lib/evostream/event/response/mock.rb
evostream-event-2.0.0.pre.994165179 lib/evostream/event/response/mock.rb
evostream-event-2.0.0.pre.994159616 lib/evostream/event/response/mock.rb
evostream-event-2.0.0.pre.856454391 lib/evostream/event/response/mock.rb
evostream-event-2.0.0.pre.856447460 lib/evostream/event/response/mock.rb
evostream-event-2.0.0.pre.856441003 lib/evostream/event/response/mock.rb
evostream-event-2.0.0.pre.816370746 lib/evostream/event/response/mock.rb
evostream-event-2.0.0.pre.809444619 lib/evostream/event/response/mock.rb
evostream-event-1.0.3 lib/evostream/event/response/mock.rb
evostream-event-1.0.3.pre.95 lib/evostream/event/response/mock.rb
evostream-event-1.0.3.pre.93 lib/evostream/event/response/mock.rb
evostream-event-1.0.3.pre.91 lib/evostream/event/response/mock.rb
evostream-event-1.0.3.pre.83 lib/evostream/event/response/mock.rb
evostream-event-1.0.2 lib/evostream/event/response/mock.rb