Class: CypressOnRails::Middleware

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

Overview

Middleware to handle testing framework 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.



11
12
13
14
15
# File 'lib/cypress_on_rails/middleware.rb', line 11

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

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cypress_on_rails/middleware.rb', line 17

def call(env)
  request = Rack::Request.new(env)
  if request.path.start_with?("#{configuration.api_prefix}/__e2e__/command")
    configuration.tagged_logged { handle_command(request) }
  elsif request.path.start_with?("#{configuration.api_prefix}/__cypress__/command")
    warn "/__cypress__/command is deprecated. Please use the install generator to use /__e2e__/command instead."
    configuration.tagged_logged { handle_command(request) }
  else
    @app.call(env)
  end
end