kookaburra 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/VERSION +1 -1
- data/kookaburra.gemspec +5 -1
- data/lib/kookaburra/ui_driver/mixins/has_browser.rb +2 -2
- data/lib/kookaburra/ui_driver/mixins/has_ui_component.rb +4 -0
- data/lib/kookaburra/ui_driver/ui_component.rb +14 -8
- data/lib/kookaburra/ui_driver.rb +12 -2
- data/test/kookaburra/ui_driver_test.rb +55 -0
- metadata +33 -18
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -4,6 +4,7 @@ GEM
|
|
4
4
|
activesupport (3.1.3)
|
5
5
|
multi_json (~> 1.0)
|
6
6
|
git (1.2.5)
|
7
|
+
i18n (0.6.0)
|
7
8
|
jeweler (1.6.4)
|
8
9
|
bundler (~> 1.0)
|
9
10
|
git (>= 1.2.5)
|
@@ -33,6 +34,7 @@ PLATFORMS
|
|
33
34
|
DEPENDENCIES
|
34
35
|
activesupport (>= 3.0)
|
35
36
|
bundler (~> 1.0.0)
|
37
|
+
i18n
|
36
38
|
jeweler (~> 1.6.4)
|
37
39
|
minitest
|
38
40
|
rack-test
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/kookaburra.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "kookaburra"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.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"]
|
@@ -40,6 +40,7 @@ Gem::Specification.new do |s|
|
|
40
40
|
"lib/kookaburra/ui_driver/ui_component.rb",
|
41
41
|
"lib/requires.rb",
|
42
42
|
"test/helper.rb",
|
43
|
+
"test/kookaburra/ui_driver_test.rb",
|
43
44
|
"test/kookaburra_test.rb"
|
44
45
|
]
|
45
46
|
s.homepage = "http://github.com/projectdx/kookaburra"
|
@@ -52,6 +53,7 @@ Gem::Specification.new do |s|
|
|
52
53
|
s.specification_version = 3
|
53
54
|
|
54
55
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
56
|
+
s.add_runtime_dependency(%q<i18n>, [">= 0"])
|
55
57
|
s.add_runtime_dependency(%q<activesupport>, [">= 3.0"])
|
56
58
|
s.add_runtime_dependency(%q<rack-test>, [">= 0"])
|
57
59
|
s.add_development_dependency(%q<minitest>, [">= 0"])
|
@@ -61,6 +63,7 @@ Gem::Specification.new do |s|
|
|
61
63
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
62
64
|
s.add_development_dependency(%q<reek>, ["~> 1.2.8"])
|
63
65
|
else
|
66
|
+
s.add_dependency(%q<i18n>, [">= 0"])
|
64
67
|
s.add_dependency(%q<activesupport>, [">= 3.0"])
|
65
68
|
s.add_dependency(%q<rack-test>, [">= 0"])
|
66
69
|
s.add_dependency(%q<minitest>, [">= 0"])
|
@@ -71,6 +74,7 @@ Gem::Specification.new do |s|
|
|
71
74
|
s.add_dependency(%q<reek>, ["~> 1.2.8"])
|
72
75
|
end
|
73
76
|
else
|
77
|
+
s.add_dependency(%q<i18n>, [">= 0"])
|
74
78
|
s.add_dependency(%q<activesupport>, [">= 3.0"])
|
75
79
|
s.add_dependency(%q<rack-test>, [">= 0"])
|
76
80
|
s.add_dependency(%q<minitest>, [">= 0"])
|
@@ -6,11 +6,11 @@ module Kookaburra
|
|
6
6
|
# This will fail if the options hash does not include a value for the key :browser
|
7
7
|
def initialize(options = {})
|
8
8
|
super()
|
9
|
-
@
|
9
|
+
@opts = options
|
10
10
|
end
|
11
11
|
|
12
12
|
def browser
|
13
|
-
@
|
13
|
+
@browser ||= @opts.fetch(:browser)
|
14
14
|
end
|
15
15
|
|
16
16
|
def visit(*args)
|
@@ -1,6 +1,10 @@
|
|
1
|
+
require 'active_support/core_ext/string/inflections'
|
2
|
+
|
1
3
|
module Kookaburra
|
2
4
|
class UIDriver
|
3
5
|
module HasUIComponent
|
6
|
+
UIComponentNotFound = Class.new(StandardError)
|
7
|
+
|
4
8
|
module ClassMethods
|
5
9
|
def ui_component(component_name)
|
6
10
|
self.ui_component_names << component_name
|
@@ -34,23 +34,28 @@ module Kookaburra
|
|
34
34
|
|
35
35
|
##### Instance methods #####
|
36
36
|
|
37
|
+
# Returns the CSS locator used to locate the component in the DOM
|
38
|
+
def component_locator
|
39
|
+
raise "You must define component_locator in subclasses of UIComponent!"
|
40
|
+
end
|
41
|
+
|
37
42
|
def visible!
|
38
43
|
raise "#{self.class} not currently visible!" unless visible?
|
39
44
|
end
|
40
45
|
|
41
46
|
def visible?
|
42
47
|
no_500_error!
|
43
|
-
_visible?
|
44
|
-
end
|
45
|
-
|
46
|
-
def _visible?
|
47
48
|
component_visible?
|
48
49
|
end
|
49
|
-
private :_visible?
|
50
50
|
|
51
|
+
# Default implementation navigates directly to this UIComponent's
|
52
|
+
# #component_path. If +opts[:query_params] is set to a Hash, the request
|
53
|
+
# will be made with the resulting querystring on the URL.
|
51
54
|
def show(opts = {})
|
55
|
+
unless respond_to?(:component_path)
|
56
|
+
raise "You must either set component_path or redefine the #show method in UIComponent subclasses!"
|
57
|
+
end
|
52
58
|
return if visible?
|
53
|
-
raise "Subclass responsibility!" unless self.respond_to?(:component_path)
|
54
59
|
path = component_path
|
55
60
|
path << ( '?' + opts[:query_params].map{|kv| "%s=%s" % kv}.join('&') ) if opts[:query_params]
|
56
61
|
visit path
|
@@ -66,11 +71,12 @@ module Kookaburra
|
|
66
71
|
end
|
67
72
|
|
68
73
|
def at_path?
|
69
|
-
(component_path
|
74
|
+
(Array(component_path) + Array(alternate_paths)).include?(browser.current_path)
|
70
75
|
end
|
71
76
|
|
72
77
|
def component_visible?
|
73
|
-
|
78
|
+
return false if respond_to?(:component_path) && !at_path?
|
79
|
+
browser.has_css?(component_locator)
|
74
80
|
end
|
75
81
|
|
76
82
|
def alternate_paths
|
data/lib/kookaburra/ui_driver.rb
CHANGED
@@ -3,11 +3,21 @@ module Kookaburra
|
|
3
3
|
include HasBrowser
|
4
4
|
include HasUIComponent
|
5
5
|
|
6
|
-
|
6
|
+
def test_data
|
7
|
+
@test_data ||= @opts.fetch(:test_data)
|
8
|
+
end
|
7
9
|
|
8
10
|
def initialize(opts = {})
|
9
11
|
super
|
10
|
-
@
|
12
|
+
@opts = opts
|
13
|
+
end
|
14
|
+
|
15
|
+
def navigate_to(component_id, parameters = {})
|
16
|
+
if ui_component_names.include?(component_id)
|
17
|
+
self.send(component_id).show!(parameters)
|
18
|
+
else
|
19
|
+
raise UIComponentNotFound, "The #{component_id} component is not registered"
|
20
|
+
end
|
11
21
|
end
|
12
22
|
end
|
13
23
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Kookaburra::UIDriver do
|
4
|
+
describe '#navigate_to' do
|
5
|
+
it 'raises a UIComponentNotFound if the specified UIComponent is not registered' do
|
6
|
+
ui = Kookaburra::UIDriver.new
|
7
|
+
assert_raises Kookaburra::UIDriver::UIComponentNotFound do
|
8
|
+
ui.navigate_to(:nonexistent_component)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Foo = Class.new do
|
13
|
+
@@last_instance = nil
|
14
|
+
|
15
|
+
def self.was_shown
|
16
|
+
@@last_instance.was_shown
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.params
|
20
|
+
@@last_instance.params
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(options)
|
24
|
+
@@last_instance = self
|
25
|
+
end
|
26
|
+
|
27
|
+
def show!(params = {})
|
28
|
+
@was_shown = true
|
29
|
+
@params = params
|
30
|
+
end
|
31
|
+
attr_reader :was_shown, :params
|
32
|
+
end
|
33
|
+
|
34
|
+
let(:ui_class) do
|
35
|
+
Class.new(Kookaburra::UIDriver) do
|
36
|
+
def browser; end
|
37
|
+
def test_data; end
|
38
|
+
|
39
|
+
ui_component :foo
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'delegates to the UIComponent#show! method' do
|
44
|
+
ui = ui_class.new
|
45
|
+
ui.navigate_to :foo
|
46
|
+
assert Foo.was_shown, "#show! was never called on the Foo component"
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'passed any additional options to the UIComponent#show! method' do
|
50
|
+
ui = ui_class.new
|
51
|
+
ui.navigate_to :foo, :bar => :baz
|
52
|
+
assert_equal({:bar => :baz}, Foo.params)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
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: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Renewable Funding, LLC
|
@@ -19,6 +19,20 @@ date: 2012-01-17 00:00:00 Z
|
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 3
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
name: i18n
|
31
|
+
prerelease: false
|
32
|
+
type: :runtime
|
33
|
+
requirement: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
22
36
|
none: false
|
23
37
|
requirements:
|
24
38
|
- - ">="
|
@@ -31,9 +45,9 @@ dependencies:
|
|
31
45
|
name: activesupport
|
32
46
|
prerelease: false
|
33
47
|
type: :runtime
|
34
|
-
requirement: *
|
48
|
+
requirement: *id002
|
35
49
|
- !ruby/object:Gem::Dependency
|
36
|
-
version_requirements: &
|
50
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
37
51
|
none: false
|
38
52
|
requirements:
|
39
53
|
- - ">="
|
@@ -45,9 +59,9 @@ dependencies:
|
|
45
59
|
name: rack-test
|
46
60
|
prerelease: false
|
47
61
|
type: :runtime
|
48
|
-
requirement: *
|
62
|
+
requirement: *id003
|
49
63
|
- !ruby/object:Gem::Dependency
|
50
|
-
version_requirements: &
|
64
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
51
65
|
none: false
|
52
66
|
requirements:
|
53
67
|
- - ">="
|
@@ -59,9 +73,9 @@ dependencies:
|
|
59
73
|
name: minitest
|
60
74
|
prerelease: false
|
61
75
|
type: :development
|
62
|
-
requirement: *
|
76
|
+
requirement: *id004
|
63
77
|
- !ruby/object:Gem::Dependency
|
64
|
-
version_requirements: &
|
78
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
65
79
|
none: false
|
66
80
|
requirements:
|
67
81
|
- - ~>
|
@@ -75,9 +89,9 @@ dependencies:
|
|
75
89
|
name: yard
|
76
90
|
prerelease: false
|
77
91
|
type: :development
|
78
|
-
requirement: *
|
92
|
+
requirement: *id005
|
79
93
|
- !ruby/object:Gem::Dependency
|
80
|
-
version_requirements: &
|
94
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
81
95
|
none: false
|
82
96
|
requirements:
|
83
97
|
- - ~>
|
@@ -91,9 +105,9 @@ dependencies:
|
|
91
105
|
name: bundler
|
92
106
|
prerelease: false
|
93
107
|
type: :development
|
94
|
-
requirement: *
|
108
|
+
requirement: *id006
|
95
109
|
- !ruby/object:Gem::Dependency
|
96
|
-
version_requirements: &
|
110
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
97
111
|
none: false
|
98
112
|
requirements:
|
99
113
|
- - ~>
|
@@ -107,9 +121,9 @@ dependencies:
|
|
107
121
|
name: jeweler
|
108
122
|
prerelease: false
|
109
123
|
type: :development
|
110
|
-
requirement: *
|
124
|
+
requirement: *id007
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
|
-
version_requirements: &
|
126
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
113
127
|
none: false
|
114
128
|
requirements:
|
115
129
|
- - ">="
|
@@ -121,9 +135,9 @@ dependencies:
|
|
121
135
|
name: rcov
|
122
136
|
prerelease: false
|
123
137
|
type: :development
|
124
|
-
requirement: *
|
138
|
+
requirement: *id008
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
|
-
version_requirements: &
|
140
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
127
141
|
none: false
|
128
142
|
requirements:
|
129
143
|
- - ~>
|
@@ -137,7 +151,7 @@ dependencies:
|
|
137
151
|
name: reek
|
138
152
|
prerelease: false
|
139
153
|
type: :development
|
140
|
-
requirement: *
|
154
|
+
requirement: *id009
|
141
155
|
description: Cucumber + Capybara = Kookaburra? It made sense at the time.
|
142
156
|
email: devteam@renewfund.com
|
143
157
|
executables: []
|
@@ -171,6 +185,7 @@ files:
|
|
171
185
|
- lib/kookaburra/ui_driver/ui_component.rb
|
172
186
|
- lib/requires.rb
|
173
187
|
- test/helper.rb
|
188
|
+
- test/kookaburra/ui_driver_test.rb
|
174
189
|
- test/kookaburra_test.rb
|
175
190
|
homepage: http://github.com/projectdx/kookaburra
|
176
191
|
licenses:
|