123456789_123456789_123456789_123456789_123456789_

Class: Capybara::Config

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Forwardable
Inherits: Object
Defined in: lib/capybara/config.rb

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.newConfig

[ GitHub ]

  
# File 'lib/capybara/config.rb', line 22

def initialize
  @session_options = Capybara::SessionConfig.new
  @javascript_driver = nil
end

Instance Attribute Details

#allow_gumbo (rw)

[ GitHub ]

  
# File 'lib/capybara/config.rb', line 99

def allow_gumbo
  deprecate('allow_gumbo', 'use_html5_parsing')
  use_html5_parsing
end

#allow_gumbo=(val) (rw)

[ GitHub ]

  
# File 'lib/capybara/config.rb', line 94

def allow_gumbo=(val)
  deprecate('allow_gumbo=', 'use_html5_parsing=')
  self.use_html5_parsing = val
end

#app (rw)

[ GitHub ]

  
# File 'lib/capybara/config.rb', line 14

attr_accessor :app, :use_html5_parsing

#default_driverSymbol (rw)

Returns:

  • (Symbol)

    The name of the driver to use by default

[ GitHub ]

  
# File 'lib/capybara/config.rb', line 74

def default_driver
  @default_driver || :rack_test
end

#default_driver=(value) (rw)

[ GitHub ]

  
# File 'lib/capybara/config.rb', line 16

attr_writer :default_driver, :javascript_driver

#javascript_driverSymbol (rw)

Returns:

  • (Symbol)

    The name of the driver used when JavaScript is needed

[ GitHub ]

  
# File 'lib/capybara/config.rb', line 82

def javascript_driver
  @javascript_driver || :selenium
end

#javascript_driver=(value) (rw)

[ GitHub ]

  
# File 'lib/capybara/config.rb', line 16

attr_writer :default_driver, :javascript_driver

#reuse_server (rw)

[ GitHub ]

  
# File 'lib/capybara/config.rb', line 15

attr_reader :reuse_server, :threadsafe, :session_options # rubocop:disable Style/BisectedAttrAccessor

#reuse_server=(value) (rw)

[ GitHub ]

  
# File 'lib/capybara/config.rb', line 27

attr_writer :reuse_server # rubocop:disable Style/BisectedAttrAccessor

#server (rw)

Return the proc that ::Capybara will call to run the Rack application. The block returned receives a rack app, port, and host/ip and should run a Rack handler By default, ::Capybara will try to use puma.

[ GitHub ]

  
# File 'lib/capybara/config.rb', line 43

attr_reader :server

#server=(name) (rw) #server=([name, options])

Set the server to use.

Capybara.server = :webrick
Capybara.server = :puma, { Silent: true }
[ GitHub ]

  
# File 'lib/capybara/config.rb', line 59

def server=(name)
  name, options = *name if name.is_a? Array
  @server = if name.respond_to? :call
    name
  elsif options
    proc { |app, port, host| Capybara.servers[name.to_sym].call(app, port, host, **options) }
  else
    Capybara.servers[name.to_sym]
  end
end

#session_options (readonly)

[ GitHub ]

  
# File 'lib/capybara/config.rb', line 15

attr_reader :reuse_server, :threadsafe, :session_options # rubocop:disable Style/BisectedAttrAccessor

#threadsafe (rw)

[ GitHub ]

  
# File 'lib/capybara/config.rb', line 15

attr_reader :reuse_server, :threadsafe, :session_options # rubocop:disable Style/BisectedAttrAccessor

#threadsafe=(bool) (rw)

[ GitHub ]

  
# File 'lib/capybara/config.rb', line 29

def threadsafe=(bool)
  if (bool != threadsafe) && Session.instance_created?
    raise 'Threadsafe setting cannot be changed once a session is created'
  end

  @threadsafe = bool
end

#use_html5_parsing (rw)

[ GitHub ]

  
# File 'lib/capybara/config.rb', line 14

attr_accessor :app, :use_html5_parsing

Instance Method Details

#deprecate(method, alternate_method, once: false)

[ GitHub ]

  
# File 'lib/capybara/config.rb', line 86

def deprecate(method, alternate_method, once: false)
  @deprecation_notified ||= {}
  unless once && @deprecation_notified[method]
    Capybara::Helpers.warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead: #{Capybara::Helpers.filter_backtrace(caller)}"
  end
  @deprecation_notified[method] = true
end