Class: Kookaburra::UIDriver Abstract

Inherits:
Object
  • Object
show all
Extended by:
Forwardable, HasUIComponents
Includes:
Assertion
Defined in:
lib/kookaburra/ui_driver.rb,
lib/kookaburra/ui_driver/ui_component.rb,
lib/kookaburra/ui_driver/scoped_browser.rb,
lib/kookaburra/ui_driver/has_ui_components.rb,
lib/kookaburra/ui_driver/ui_component/address_bar.rb

Overview

This class is abstract.

Subclass and implement your UI testing DSL

You UIDriver subclass is where you define the DSL for testing your application via its user interface. Methods defined in your DSL should represent business actions rather than user interface manipulations. A good test of this is whether the names of your methods would need to change significantly if the application needed to be implemented in a vastly different manner (a text-only terminal app vs. a web app, for instance).

With larger applications, it may be beneficial to break down your business actions into multiple classes. The top-level UIDriver can have sub-drivers associated with it (and those can have sub-drivers, too; but let's not get carried away, eh?):

class AccountManagementDriver < Kookaburra::UIDriver ui_component :account_list, AccountList # ... end

class MyUIDriver < Kookaburra::UIDriver ui_driver :account_management, AccountManagementDriver # ... end

In your test implementation, you can then do (among other things):

ui.account_management.account_list.should be_visible

Examples:

UIDriver subclass

module MyApp
  module Kookaburra
    class UIDriver < ::Kookaburra::UIDriver
      ui_component :widget_list, WidgetList
      ui_component :questionnaire, Questionnaire

      def view_the_widgets
        address_bar.go_to(widget_list)
      end

      def view_all_of_the_widgets
        address_bar.go_to(widget_list.url(:include_hidden => true))
      end

      def complete_the_widget_questionnaire(answers = {})
        address_bar.go_to(questionnaire)
        questionnaire.page_1.submit(answers[:page_1])
        questionnaire.page_2.submit(answers[:page_2])
        questionnaire.page_3.submit(answers[:page_3])
        questionnaire.submit
      end
    end
  end
end

Defined Under Namespace

Modules: HasUIComponents Classes: ScopedBrowser, UIComponent

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasUIComponents

ui_component

Methods included from Assertion

#assert

Constructor Details

#initialize(configuration) ⇒ UIDriver

It is unlikely that you would instantiate your UIDriver on your own; the object is configured for you when you call Kookaburra#ui.

Parameters:



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

def initialize(configuration)
  @configuration = configuration
end

Instance Attribute Details

#address_barKookaburra::UIComponent::UIComponent::AddressBar (readonly, protected)

Returns:

  • (Kookaburra::UIComponent::UIComponent::AddressBar)


101
# File 'lib/kookaburra/ui_driver.rb', line 101

ui_component :address_bar, UIComponent::AddressBar

#configurationObject (readonly, protected)

Returns the value of attribute configuration.



111
112
113
# File 'lib/kookaburra/ui_driver.rb', line 111

def configuration
  @configuration
end

#loggerObject (readonly, protected)

Returns:

  • (Object)


109
# File 'lib/kookaburra/ui_driver.rb', line 109

def_delegator :configuration, :logger

#mental_modelKookaburra::MentalModel (readonly, protected)



105
# File 'lib/kookaburra/ui_driver.rb', line 105

def_delegator :configuration, :mental_model

Class Method Details

.ui_driver(driver_name, driver_class) ⇒ Object

Tells the UIDriver about sub-drivers (other Kookaburra::UIDriver subclasses).

Parameters:

  • driver_name (Symbol)

    Will create an instance method of this name that returns an instance of the driver_class

  • driver_class (Class)

    The Kookaburra::UIDriver subclass that defines this driver.



73
74
75
76
77
# File 'lib/kookaburra/ui_driver.rb', line 73

def ui_driver(driver_name, driver_class)
  define_method(driver_name) do
    driver_class.new(@configuration)
  end
end

Instance Method Details

#urlObject

Returns the URL for this Kookaburra::UIDriver.

This implementation simply returns the Configuration#app_host, but you might override it if you are using sub-drivers (see ui_driver) and want them to be addressable.



93
94
95
# File 'lib/kookaburra/ui_driver.rb', line 93

def url
  @configuration.app_host
end