kookaburra 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/kookaburra.gemspec +4 -4
- data/lib/kookaburra.rb +115 -14
- data/lib/kookaburra/api_driver.rb +2 -0
- data/lib/kookaburra/test_data.rb +2 -0
- data/lib/kookaburra/ui_driver/mixins/has_strategies.rb +2 -0
- data/lib/requires.rb +0 -2
- data/test/helper.rb +1 -0
- data/test/kookaburra_test.rb +111 -0
- metadata +5 -5
- data/lib/kookaburra/world_setup.rb +0 -12
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/kookaburra.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "kookaburra"
|
8
|
-
s.version = "0.0
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Renewable Funding, LLC"]
|
12
|
-
s.date = "2012-01-
|
12
|
+
s.date = "2012-01-16"
|
13
13
|
s.description = "Cucumber + Capybara = Kookaburra? It made sense at the time."
|
14
14
|
s.email = "devteam@renewfund.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -38,9 +38,9 @@ Gem::Specification.new do |s|
|
|
38
38
|
"lib/kookaburra/ui_driver/mixins/has_subcomponents.rb",
|
39
39
|
"lib/kookaburra/ui_driver/mixins/has_ui_component.rb",
|
40
40
|
"lib/kookaburra/ui_driver/ui_component.rb",
|
41
|
-
"lib/kookaburra/world_setup.rb",
|
42
41
|
"lib/requires.rb",
|
43
|
-
"test/helper.rb"
|
42
|
+
"test/helper.rb",
|
43
|
+
"test/kookaburra_test.rb"
|
44
44
|
]
|
45
45
|
s.homepage = "http://github.com/projectdx/kookaburra"
|
46
46
|
s.licenses = ["MIT"]
|
data/lib/kookaburra.rb
CHANGED
@@ -1,19 +1,120 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), *%w[requires])
|
2
2
|
|
3
|
+
# Kookaburra is a framework for implementing the WindowDriver pattern in order
|
4
|
+
# to keep acceptance tests maintainable.
|
5
|
+
#
|
6
|
+
# For RSpec integration tests, just add the following to
|
7
|
+
# `spec/support/kookaburra.rb`:
|
8
|
+
#
|
9
|
+
# RSpec.configure do |c|
|
10
|
+
# c.include(Kookaburra, :type => :request)
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# That will make #given, #api and #ui entry-points available to your examples,
|
14
|
+
# e.g.:
|
15
|
+
#
|
16
|
+
# describe "Widget Management" do
|
17
|
+
# describe "viewing a list of widgets" do
|
18
|
+
# example "when there are no widgets" do
|
19
|
+
# given.there_is_a_user(:bob)
|
20
|
+
# given.user_has_no_widgets(:bob)
|
21
|
+
#
|
22
|
+
# ui.log_in_as(:bob)
|
23
|
+
# ui.navigate_to(:list_of_widgets)
|
24
|
+
#
|
25
|
+
# ui.list_of_widgets.should be_visible
|
26
|
+
# ui.list_of_widgets.should be_empty
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# For Cucumber, add the following to `features/support/kookaburra_setup.rb`:
|
32
|
+
#
|
33
|
+
# Kookaburra.adapter = Capybara
|
34
|
+
# World(Kookaburra)
|
35
|
+
#
|
36
|
+
# Before do
|
37
|
+
# kookaburra_reset!
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# After doing to, the #api, #given and #ui methods will be available in your
|
41
|
+
# Cucumber step definitions.
|
42
|
+
#
|
43
|
+
# (Obviously, the specific methods on #given and #ui are something that will be
|
44
|
+
# unique to your application's domain.)
|
3
45
|
module Kookaburra
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
46
|
+
class << self
|
47
|
+
# Provides the default adapter for the Kookaburra library. In most cases,
|
48
|
+
# this will probably be the `Capybara` class:
|
49
|
+
#
|
50
|
+
# Kookaburra.adapter = Capybara
|
51
|
+
#
|
52
|
+
# We allow this to be passed in, so that we can avoid a hard-coded
|
53
|
+
# dependency on Capybara in this gem.
|
54
|
+
attr_accessor :adapter
|
55
|
+
end
|
56
|
+
|
57
|
+
# Whatever was set in `Kookaburra.adapter can be overriden in the mixin
|
58
|
+
# context. For example, in an RSpec example:
|
59
|
+
#
|
60
|
+
# describe "Something" do
|
61
|
+
# it "does something" do
|
62
|
+
# self.kookaburra_adapter = CapybaraLikeThing
|
63
|
+
# ...
|
64
|
+
# end
|
65
|
+
# end
|
66
|
+
#
|
67
|
+
attr_accessor :kookaburra_adapter
|
68
|
+
|
69
|
+
def kookaburra_adapter #:nodoc:
|
70
|
+
@kookaburra_adapter ||= Kookaburra.adapter
|
71
|
+
end
|
72
|
+
|
73
|
+
# Returns a configured instance of the `Kookaburra::APIDriver`
|
74
|
+
def api
|
75
|
+
kookaburra_drivers[:api] ||= Kookaburra::APIDriver.new(
|
76
|
+
:app => kookaburra_adapter.app,
|
77
|
+
:test_data => kookaburra_test_data)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Returns a configured instance of the `Kookaburra::GivenDriver`
|
81
|
+
def given
|
82
|
+
kookaburra_drivers[:given] ||= Kookaburra::GivenDriver.new(:api_driver => api)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Returns a configured instance of the `Kookaburra::UIDriver`
|
86
|
+
def ui
|
87
|
+
kookaburra_drivers[:ui] ||= Kookaburra::UIDriver.new(
|
88
|
+
:browser => kookaburra_adapter.current_session,
|
89
|
+
:test_data => kookaburra_test_data)
|
90
|
+
end
|
91
|
+
|
92
|
+
# This method causes new instances of all the Kookaburra drivers to be created
|
93
|
+
# the next time they are used, and, in particular, resets the state of any
|
94
|
+
# test data that is shared between the various drivers. This is necessary when
|
95
|
+
# Kookaburra is mixed in to Cucumber's World, because World does not get a new
|
96
|
+
# instance for each scenario. Instead, just be sure to call this method from a
|
97
|
+
# `Before` block in your cucumber setup, i.e.:
|
98
|
+
#
|
99
|
+
# Before do
|
100
|
+
# kookaburra_reset!
|
101
|
+
# end
|
102
|
+
def kookaburra_reset!
|
103
|
+
@kookaburra_drivers = {}
|
104
|
+
end
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
# The Kookaburra::TestData instance should not be used directly, but all of
|
109
|
+
# the drivers should reference the same instance.
|
110
|
+
def kookaburra_test_data
|
111
|
+
kookaburra_drivers[:test_data] ||= Kookaburra::TestData.new
|
112
|
+
end
|
113
|
+
|
114
|
+
# Holds references to all drivers in a single hash, so that
|
115
|
+
# Kookaburra#kookaburra_reset! can easily clear all Kookaburra state on the
|
116
|
+
# instance of the including class.
|
117
|
+
def kookaburra_drivers
|
118
|
+
@kookaburra_drivers ||= {}
|
18
119
|
end
|
19
120
|
end
|
data/lib/kookaburra/test_data.rb
CHANGED
data/lib/requires.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Kookaburra do
|
4
|
+
describe 'as a mixin' do
|
5
|
+
let(:mixer_class) do
|
6
|
+
Class.new do
|
7
|
+
include Kookaburra
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:mixer) do
|
12
|
+
mixer_class.new.tap do |m|
|
13
|
+
m.kookaburra_adapter = adapter
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:mixer2) do
|
18
|
+
mixer_class.new.tap do |m|
|
19
|
+
m.kookaburra_adapter = adapter
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:adapter) do
|
24
|
+
capybara_like_thing = Class.new do
|
25
|
+
def app
|
26
|
+
:an_application
|
27
|
+
end
|
28
|
+
|
29
|
+
def current_session
|
30
|
+
:a_current_session
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
capybara_like_thing.new
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#kookaburra_adapter' do
|
38
|
+
it 'is a read/write attribute' do
|
39
|
+
mixer = mixer_class.new
|
40
|
+
assert_nil mixer.kookaburra_adapter
|
41
|
+
mixer.kookaburra_adapter = :probably_Capybara
|
42
|
+
assert_equal :probably_Capybara, mixer.kookaburra_adapter
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#api' do
|
47
|
+
it 'is an instance of Kookaburra::APIDriver' do
|
48
|
+
assert_kind_of(Kookaburra::APIDriver, mixer.api)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'only creates a new one once for an instance of the including class' do
|
52
|
+
assert_same(mixer.api, mixer.api)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'is a different instance of APIDriver for each instance of the including class' do
|
56
|
+
refute_same mixer.api, mixer2.api
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#given' do
|
61
|
+
it 'is an instance of Kookaburra::GivenDriver' do
|
62
|
+
assert_kind_of(Kookaburra::GivenDriver, mixer.given)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'only creates a new one once for an instance of the including class' do
|
66
|
+
assert_same(mixer.given, mixer.given)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'is a different instance of GivenDriver for each instance of the including class' do
|
70
|
+
refute_same mixer.given, mixer2.given
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#ui' do
|
75
|
+
it 'is an instance of Kookaburra::UIDriver' do
|
76
|
+
assert_kind_of(Kookaburra::UIDriver, mixer.ui)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'only creates a new one once for an instance of the including class' do
|
80
|
+
assert_same(mixer.ui, mixer.ui)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'is a different instance of UIDriver for each instance of the including class' do
|
84
|
+
refute_same mixer.ui, mixer2.ui
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe '#kookaburra_reset!' do
|
89
|
+
it 'resets the api driver' do
|
90
|
+
api = mixer.api
|
91
|
+
mixer.kookaburra_reset!
|
92
|
+
api2 = mixer.api
|
93
|
+
refute_same api, api2
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'resets the given driver' do
|
97
|
+
given = mixer.given
|
98
|
+
mixer.kookaburra_reset!
|
99
|
+
given2 = mixer.given
|
100
|
+
refute_same given, given2
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'resets the ui driver' do
|
104
|
+
ui = mixer.ui
|
105
|
+
mixer.kookaburra_reset!
|
106
|
+
ui2 = mixer.ui
|
107
|
+
refute_same ui, ui2
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kookaburra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.4
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Renewable Funding, LLC
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-01-
|
18
|
+
date: 2012-01-16 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
@@ -183,9 +183,9 @@ files:
|
|
183
183
|
- lib/kookaburra/ui_driver/mixins/has_subcomponents.rb
|
184
184
|
- lib/kookaburra/ui_driver/mixins/has_ui_component.rb
|
185
185
|
- lib/kookaburra/ui_driver/ui_component.rb
|
186
|
-
- lib/kookaburra/world_setup.rb
|
187
186
|
- lib/requires.rb
|
188
187
|
- test/helper.rb
|
188
|
+
- test/kookaburra_test.rb
|
189
189
|
homepage: http://github.com/projectdx/kookaburra
|
190
190
|
licenses:
|
191
191
|
- MIT
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# Can't use a custom World class, because cucumber-rails is already doing that
|
2
|
-
module Kookaburra
|
3
|
-
module WorldSetup
|
4
|
-
def ui; @drivers[:ui_driver ]; end
|
5
|
-
def api; @drivers[:api_driver ]; end
|
6
|
-
def given; @drivers[:given_driver]; end
|
7
|
-
|
8
|
-
def kookaburra_world_setup
|
9
|
-
@drivers = Kookaburra.drivers
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|