Class: CypressOnRails::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



42
43
44
# File 'lib/cypress_on_rails/configuration.rb', line 42

def initialize
  reset
end

Instance Attribute Details

#after_server_startObject

Returns the value of attribute after_server_start.



16
17
18
# File 'lib/cypress_on_rails/configuration.rb', line 16

def after_server_start
  @after_server_start
end

#after_state_resetObject

Returns the value of attribute after_state_reset.



18
19
20
# File 'lib/cypress_on_rails/configuration.rb', line 18

def after_state_reset
  @after_state_reset
end

#after_transaction_startObject

Returns the value of attribute after_transaction_start.



17
18
19
# File 'lib/cypress_on_rails/configuration.rb', line 17

def after_transaction_start
  @after_transaction_start
end

#api_prefixObject

Returns the value of attribute api_prefix.



5
6
7
# File 'lib/cypress_on_rails/configuration.rb', line 5

def api_prefix
  @api_prefix
end

#before_requestObject

Returns the value of attribute before_request.



10
11
12
# File 'lib/cypress_on_rails/configuration.rb', line 10

def before_request
  @before_request
end

#before_server_startObject

Server hooks for managing test lifecycle



15
16
17
# File 'lib/cypress_on_rails/configuration.rb', line 15

def before_server_start
  @before_server_start
end

#before_server_stopObject

Returns the value of attribute before_server_stop.



19
20
21
# File 'lib/cypress_on_rails/configuration.rb', line 19

def before_server_stop
  @before_server_stop
end

#install_folderObject

Returns the value of attribute install_folder.



6
7
8
# File 'lib/cypress_on_rails/configuration.rb', line 6

def install_folder
  @install_folder
end

#loggerObject

Returns the value of attribute logger.



11
12
13
# File 'lib/cypress_on_rails/configuration.rb', line 11

def logger
  @logger
end

#server_hostObject

Server configuration



22
23
24
# File 'lib/cypress_on_rails/configuration.rb', line 22

def server_host
  @server_host
end

#server_portObject

Returns the value of attribute server_port.



23
24
25
# File 'lib/cypress_on_rails/configuration.rb', line 23

def server_port
  @server_port
end

#server_readiness_pathObject

HTTP path to check for server readiness (default: '/') Can be set via CYPRESS_RAILS_READINESS_PATH environment variable



27
28
29
# File 'lib/cypress_on_rails/configuration.rb', line 27

def server_readiness_path
  @server_readiness_path
end

#server_readiness_timeoutObject

Timeout in seconds for individual HTTP readiness checks (default: 5) Can be set via CYPRESS_RAILS_READINESS_TIMEOUT environment variable



30
31
32
# File 'lib/cypress_on_rails/configuration.rb', line 30

def server_readiness_timeout
  @server_readiness_timeout
end

#transactional_serverObject

Returns the value of attribute transactional_server.



24
25
26
# File 'lib/cypress_on_rails/configuration.rb', line 24

def transactional_server
  @transactional_server
end

#use_middlewareObject Also known as: use_middleware?

Returns the value of attribute use_middleware.



7
8
9
# File 'lib/cypress_on_rails/configuration.rb', line 7

def use_middleware
  @use_middleware
end

#use_vcr_middlewareObject Also known as: use_vcr_middleware?

Returns the value of attribute use_vcr_middleware.



8
9
10
# File 'lib/cypress_on_rails/configuration.rb', line 8

def use_vcr_middleware
  @use_vcr_middleware
end

#use_vcr_use_cassette_middlewareObject Also known as: use_vcr_use_cassette_middleware?

Returns the value of attribute use_vcr_use_cassette_middleware.



9
10
11
# File 'lib/cypress_on_rails/configuration.rb', line 9

def use_vcr_use_cassette_middleware
  @use_vcr_use_cassette_middleware
end

#vcr_optionsObject

Returns the value of attribute vcr_options.



12
13
14
# File 'lib/cypress_on_rails/configuration.rb', line 12

def vcr_options
  @vcr_options
end

Instance Method Details

#cypress_folderObject

Attributes for backwards compatibility



33
34
35
36
# File 'lib/cypress_on_rails/configuration.rb', line 33

def cypress_folder
  warn "cypress_folder is deprecated, please use install_folder"
  install_folder
end

#cypress_folder=(v) ⇒ Object



37
38
39
40
# File 'lib/cypress_on_rails/configuration.rb', line 37

def cypress_folder=(v)
  warn "cypress_folder= is deprecated, please use install_folder"
  self.install_folder = v
end

#resetObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/cypress_on_rails/configuration.rb', line 50

def reset
  self.api_prefix = ''
  self.install_folder = 'spec/e2e'
  self.use_middleware = true
  self.use_vcr_middleware = false
  self.use_vcr_use_cassette_middleware = false
  self.before_request = -> (request) {}
  self.logger = Logger.new(STDOUT)
  self.vcr_options = {}
  
  # Server hooks
  self.before_server_start = nil
  self.after_server_start = nil
  self.after_transaction_start = nil
  self.after_state_reset = nil
  self.before_server_stop = nil
  
  # Server configuration
  self.server_host = ENV.fetch('CYPRESS_RAILS_HOST', 'localhost')
  self.server_port = ENV.fetch('CYPRESS_RAILS_PORT', nil)
  self.transactional_server = true
  self.server_readiness_path = ENV.fetch('CYPRESS_RAILS_READINESS_PATH', '/')
  self.server_readiness_timeout = ENV.fetch('CYPRESS_RAILS_READINESS_TIMEOUT', '5').to_i
end

#tagged_loggedObject



75
76
77
78
79
80
81
# File 'lib/cypress_on_rails/configuration.rb', line 75

def tagged_logged
  if logger.respond_to?(:tagged)
    logger.tagged('CY_DEV') { yield }
  else
    yield
  end
end