Class: Faraday::Adapter::ActionDispatch
- Inherits:
-
Middleware
- Object
- Middleware
- Faraday::Adapter::ActionDispatch
- Defined in:
- lib/faraday/adapter/action_dispatch.rb
Instance Attribute Summary collapse
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, session) ⇒ ActionDispatch
constructor
Initializes a new middleware instance for each request.
Methods inherited from Middleware
#create_form_params, #full_path_for, loaded?, #process_body_for_request, setup_parallel_manager
Constructor Details
#initialize(app, session) ⇒ ActionDispatch
Initializes a new middleware instance for each request. Instead of initiating an HTTP request with a web server, this adapter calls a Rails 3 app using integration tests.
app - The current Faraday request. session - An ActionDispatch::Integration::Session instance.
Returns nothing.
14 15 16 17 18 |
# File 'lib/faraday/adapter/action_dispatch.rb', line 14 def initialize(app, session) super(app) @session = session @session.reset! end |
Instance Attribute Details
#session ⇒ Object (readonly)
Returns the value of attribute session.
4 5 6 |
# File 'lib/faraday/adapter/action_dispatch.rb', line 4 def session @session end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/faraday/adapter/action_dispatch.rb', line 20 def call(env) process_body_for_request(env) full_path = full_path_for(env[:url].path, env[:url].query, env[:url].fragment) @session.__send__(env[:method], full_path, env[:body], env[:request_headers]) resp = @session.response env.update \ :status => resp.status, :response_headers => resp.headers, :body => resp.body @app.call env end |