Class: CypressOnRails::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/cypress_on_rails/middleware.rb

Overview

Middleware to handle cypress commands and eval

Defined Under Namespace

Classes: Command

Instance Method Summary collapse

Constructor Details

#initialize(app, command_executor = CommandExecutor, file = ::File) ⇒ Middleware

Returns a new instance of Middleware.



9
10
11
12
13
# File 'lib/cypress_on_rails/middleware.rb', line 9

def initialize(app, command_executor = CommandExecutor, file = ::File)
  @app = app
  @command_executor = command_executor
  @file = file
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/cypress_on_rails/middleware.rb', line 15

def call(env)
  request = Rack::Request.new(env)
  if request.path.start_with?('/__cypress__/command')
    configuration.tagged_logged { handle_command(request) }
  else
    @app.call(env)
  end
end