Class: Kookaburra::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/kookaburra/configuration.rb,
lib/kookaburra/configuration/proxy.rb

Overview

Provides access to the configuration data used throughout Kookaburra

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_driver_classObject

The class to use as your APIDriver

Raises:

  • (Kookaburra::ConfigurationError)

    if you try to read this attribute without it having been set



17
# File 'lib/kookaburra/configuration.rb', line 17

dependency_accessor :api_driver_class

#app_hostObject

This is the root URL of your running application, including the port number if necessary. (e.g. "http://my.example.com:12345")

Raises:

  • (Kookaburra::ConfigurationError)

    if you try to read this attribute without it having been set



41
# File 'lib/kookaburra/configuration.rb', line 41

dependency_accessor :app_host

#browserObject

This object is used by UIDriver::UIComponent to interface with the web browser. Typically it should be an instance of Capybara::Session

Raises:

  • (Kookaburra::ConfigurationError)

    if you try to read this attribute without it having been set



33
# File 'lib/kookaburra/configuration.rb', line 33

dependency_accessor :browser

#loggerObject

This is the logger to which Kookaburra will send various messages about its operation. This would generally be used to allow UIDriver subclasses to provide detailed failure information.



48
# File 'lib/kookaburra/configuration.rb', line 48

dependency_accessor :logger

#mental_modelObject

This is the MentalModel that is shared between your APIDriver and your UIDriver. This attribute is managed by Kookaburra, so you shouldn't need to change it yourself.



84
85
86
# File 'lib/kookaburra/configuration.rb', line 84

def mental_model
  @mental_model ||= MentalModel.new
end

#ui_driver_classObject

The class to use as your UIDriver

Raises:

  • (Kookaburra::ConfigurationError)

    if you try to read this attribute without it having been set



24
# File 'lib/kookaburra/configuration.rb', line 24

dependency_accessor :ui_driver_class

Instance Method Details

#app_host_uriURI

The parsed version of the #app_host

This is useful if, for example, you are testing a multi-host application and need to change the hostname that will be accessed but want to keep the originally-specified port

Returns:

  • (URI)

    A URI object created from the #app_host string



77
78
79
# File 'lib/kookaburra/configuration.rb', line 77

def app_host_uri
  URI.parse(app_host)
end

#application(name, &block) ⇒ Object



90
91
92
93
94
# File 'lib/kookaburra/configuration.rb', line 90

def application(name, &block)
  proxy = Proxy.new(name: name, basis: self)
  block.call(proxy) if block_given?
  applications[name] = Kookaburra.new(proxy)
end

#applicationsObject



96
97
98
# File 'lib/kookaburra/configuration.rb', line 96

def applications
  @applications ||= {}
end

#has_named_applications?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/kookaburra/configuration.rb', line 100

def has_named_applications?
  !applications.empty?
end

#server_error_detection { ... } ⇒ Object

Specify a function that can be used to determine if a server error has occured within your application.

If the function returns true, then Kookaburra will assume that the application has responded with an error.

Examples:

If the page title is "Internal Server Error"

config.server_error_detection { |browser|
  browser.has_css?('head title', :text => 'Internal Server Error')
}

Yields:

  • whichever object was assigned to #browser



62
63
64
65
66
67
68
# File 'lib/kookaburra/configuration.rb', line 62

def server_error_detection(&blk)
  if block_given?
    @server_error_detection = blk
  else
    @server_error_detection
  end
end