Module: Faraday::Adapter::MockRequest

Extended by:
Connection::Options
Includes:
Error
Included in:
TestConnection
Defined in:
lib/faraday/adapter/mock_request.rb

Defined Under Namespace

Classes: Stub, Stubs

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Connection::Options

load_error, load_error=, loaded?, supports_async, supports_async=

Class Method Details

.loaded?Boolean


5
# File 'lib/faraday/adapter/mock_request.rb', line 5

def self.loaded?() false end

Instance Method Details

#_get(uri, headers) ⇒ Object

Raises:


58
59
60
61
62
63
64
65
66
67
68
# File 'lib/faraday/adapter/mock_request.rb', line 58

def _get(uri, headers)
  raise ConnectionFailed, "no stubbed requests" if stubs.empty?
  if stub = @stubs.match(:get, uri.path, headers)
    response_class.new do |resp|
      resp.headers = stub.response_headers
      resp.process stub.body
    end
  else
    nil
  end
end

#configure {|stubs| ... } ⇒ Object

Yields:


50
51
52
# File 'lib/faraday/adapter/mock_request.rb', line 50

def configure
  yield stubs
end

#initialize(&block) ⇒ Object


45
46
47
48
# File 'lib/faraday/adapter/mock_request.rb', line 45

def initialize &block
  super nil
  configure(&block) if block
end

#stubsObject


54
55
56
# File 'lib/faraday/adapter/mock_request.rb', line 54

def stubs
  @stubs ||= Stubs.new
end