Class: Kookaburra

Inherits:
Object
  • Object
show all
Defined in:
lib/kookaburra.rb,
lib/kookaburra/version.rb,
lib/kookaburra/assertion.rb,
lib/kookaburra/ui_driver.rb,
lib/kookaburra/api_driver.rb,
lib/kookaburra/exceptions.rb,
lib/kookaburra/given_driver.rb,
lib/kookaburra/mental_model.rb,
lib/kookaburra/test_helpers.rb,
lib/kookaburra/configuration.rb,
lib/kookaburra/dependency_accessor.rb,
lib/kookaburra/mental_model_matcher.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

Kookaburra provides the top-level API that you will access in your test implementation, namely the #given, #ui, and the #get_data methods.

The Kookaburra object ensures that your GivenDriver and UIDriver share the same state with regard to any MentalModel data that is created during your test run. As such, it is important to ensure that a new instance of Kookaburra is created for each individual test, otherwise you may wind up with test state bleeding over from one test to the next. The TestHelpers module is intended to be mixed in to your testing context for this purpose.

See Also:

Defined Under Namespace

Modules: Assertion, TestHelpers Classes: APIDriver, Configuration, GivenDriver, MentalModel, RackAppServer, UIDriver

Constant Summary collapse

VERSION =
"1.3.1"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration = Kookaburra.configuration) ⇒ Kookaburra

Returns a new Kookaburra instance that wires together your application's GivenDriver and UIDriver with a shared MentalModel.

Parameters:



41
42
43
44
45
46
# File 'lib/kookaburra.rb', line 41

def initialize(configuration = Kookaburra.configuration)
  @configuration = configuration
  @configuration.mental_model = MentalModel.new
  @given_driver_class = configuration.given_driver_class
  @ui_driver_class = configuration.ui_driver_class
end

Class Method Details

.configurationKookaburra::Configuration

Stores the configuration object that is used by default when creating new instances of Kookaburra

Returns:



25
26
27
# File 'lib/kookaburra.rb', line 25

def configuration
  @configuration ||= Configuration.new
end

.configure {|Kookaburra::Configuration| ... } ⇒ Object

Yields the current configuration so that it can be modified



32
33
34
# File 'lib/kookaburra.rb', line 32

def configure(&blk)
  blk.call(configuration)
end

Instance Method Details

#get_data(collection_name) ⇒ Kookaburra::MentalModel::Collection

Returns a deep-dup of the specified Kookaburra::MentalModel::Collection.

This access is provided so that you can reference the current mental model within your test implementation and make assertions about the state of your application's interface.

Examples:

given.a_widget(:foo)
ui.create_a_new_widget(:bar)
ui.widget_list.widgets.should == k.get_data(:widgets).values_at(:foo, :bar)

Returns:



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

def get_data(collection_name)
  @configuration.mental_model.send(collection_name).dup
end

#givenKookaburra::GivenDriver

Returns an instance of your GivenDriver class configured to share test fixture data with the UIDriver



52
53
54
# File 'lib/kookaburra.rb', line 52

def given
  @given ||= @given_driver_class.new(@configuration)
end

#uiKookaburra::UIDriver

Returns an instance of your UIDriver class configured to share test fixture data with the GivenDriver and to use the browser driver you specified in #initialize



61
62
63
# File 'lib/kookaburra.rb', line 61

def ui
  @ui ||= @ui_driver_class.new(@configuration)
end