Class: VCR::Middleware::Rack
- Inherits:
-
Object
- Object
- VCR::Middleware::Rack
- Includes:
- VariableArgsBlockCaller
- Defined in:
- lib/vcr/middleware/rack.rb
Overview
Note:
This will record/replay outbound HTTP requests made by your rack app.
Rack middleware that uses a VCR cassette for each incoming HTTP request.
Instance Method Summary collapse
-
#call(env) ⇒ Array(Integer, Hash, #each)
Implements the rack middleware interface.
-
#initialize(app) {|cassette, env| ... } ⇒ Rack
constructor
Constructs a new instance of VCR’s rack middleware.
Methods included from VariableArgsBlockCaller
Constructor Details
#initialize(app) {|cassette, env| ... } ⇒ Rack
Constructs a new instance of VCR’s rack middleware.
53 54 55 56 |
# File 'lib/vcr/middleware/rack.rb', line 53 def initialize(app, &block) raise ArgumentError.new("You must provide a block to set the cassette options") unless block @app, @cassette_arguments_block, @mutex = app, block, Mutex.new end |
Instance Method Details
#call(env) ⇒ Array(Integer, Hash, #each)
Implements the rack middleware interface.
62 63 64 65 66 67 68 |
# File 'lib/vcr/middleware/rack.rb', line 62 def call(env) @mutex.synchronize do VCR.use_cassette(*cassette_arguments(env)) do @app.call(env) end end end |