Class: Faraday::Adapter::Test
- Inherits:
-
Middleware
- Object
- Middleware
- Faraday::Adapter::Test
- Defined in:
- lib/faraday/adapter/test.rb
Overview
Defined Under Namespace
Instance Attribute Summary collapse
-
#stubs ⇒ Object
Returns the value of attribute stubs.
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
- #configure {|stubs| ... } ⇒ Object
- #create_multipart(env, params, boundary = nil) ⇒ Object
-
#initialize(app, stubs = nil, &block) ⇒ Test
constructor
A new instance of Test.
Methods inherited from Middleware
Constructor Details
Instance Attribute Details
#stubs ⇒ Object
Returns the value of attribute stubs.
15 16 17 |
# File 'lib/faraday/adapter/test.rb', line 15 def stubs @stubs end |
Class Method Details
.loaded? ⇒ Boolean
17 |
# File 'lib/faraday/adapter/test.rb', line 17 def self.loaded?() false end |
Instance Method Details
#call(env) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/faraday/adapter/test.rb', line 107 def call(env) normalized_path = Faraday::Utils.normalize_path(env[:url]) if stub = stubs.match(env[:method], normalized_path, env[:body]) status, headers, body = stub.block.call(env) env.update \ :status => status, :response_headers => headers, :body => body else raise "no stubbed request for #{env[:method]} #{normalized_path} #{env[:body]}" end @app.call(env) end |
#configure {|stubs| ... } ⇒ Object
103 104 105 |
# File 'lib/faraday/adapter/test.rb', line 103 def configure yield stubs end |
#create_multipart(env, params, boundary = nil) ⇒ Object
122 123 124 125 |
# File 'lib/faraday/adapter/test.rb', line 122 def create_multipart(env, params, boundary = nil) stream = super stream.read end |