Class: CypressOnRails::Vcr::InsertEjectMiddleware
- Inherits:
-
Object
- Object
- CypressOnRails::Vcr::InsertEjectMiddleware
- Includes:
- MiddlewareHelpers
- Defined in:
- lib/cypress_on_rails/vcr/insert_eject_middleware.rb
Overview
Middleware to handle vcr with insert/eject endpoints
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, vcr = nil) ⇒ InsertEjectMiddleware
constructor
A new instance of InsertEjectMiddleware.
Methods included from MiddlewareHelpers
Constructor Details
#initialize(app, vcr = nil) ⇒ InsertEjectMiddleware
Returns a new instance of InsertEjectMiddleware.
9 10 11 12 13 |
# File 'lib/cypress_on_rails/vcr/insert_eject_middleware.rb', line 9 def initialize(app, vcr = nil) @app = app @vcr = vcr @first_call = false end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cypress_on_rails/vcr/insert_eject_middleware.rb', line 15 def call(env) request = Rack::Request.new(env) if request.path.start_with?('/__e2e__/vcr/insert') configuration.tagged_logged { handle_insert(request) } elsif request.path.start_with?('/__e2e__/vcr/eject') configuration.tagged_logged { handle_eject } else do_first_call unless @first_call @app.call(env) end end |