Sha256: 38d2f2a5f52f4af6d809b70ca7b325148ae49981236abeeee91d58e8e0687f5e

Contents?: true

Size: 489 Bytes

Versions: 2

Compression:

Stored size: 489 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 = {})
      # construct
      clazz = self
      response = clazz.new('1.1', '200', 'OK')

      # inject
      response.instance_variable_set :@body, body

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

      response
    end
  end
end
# rubocop:enable Style/EvalWithLocation

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
evostream-event-1.0.2.pre.75 lib/evostream/event/response/mock.rb
evostream-event-1.0.2.pre.74 lib/evostream/event/response/mock.rb