kookaburra 0.25.0 → 0.26.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -13,4 +13,5 @@ group :development do
13
13
  gem 'jeweler'
14
14
  gem 'reek'
15
15
  gem 'sinatra'
16
+ gem 'find_a_port', '>= 1.0.1'
16
17
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- addressable (2.2.7)
4
+ addressable (2.3.2)
5
5
  capybara (1.1.2)
6
6
  mime-types (>= 1.16)
7
7
  nokogiri (>= 1.3.3)
@@ -9,23 +9,24 @@ GEM
9
9
  rack-test (>= 0.5.4)
10
10
  selenium-webdriver (~> 2.0)
11
11
  xpath (~> 0.1.4)
12
- childprocess (0.3.1)
13
- ffi (~> 1.0.6)
12
+ childprocess (0.3.4)
13
+ ffi (~> 1.0, >= 1.0.6)
14
14
  diff-lcs (1.1.3)
15
- ffi (1.0.11)
15
+ ffi (1.1.0)
16
+ find_a_port (1.0.1)
16
17
  git (1.2.5)
17
- jeweler (1.8.3)
18
+ jeweler (1.8.4)
18
19
  bundler (~> 1.0)
19
20
  git (>= 1.2.5)
20
21
  rake
21
22
  rdoc
22
- json (1.6.6)
23
- json_pure (1.7.3)
24
- libwebsocket (0.1.3)
23
+ json (1.7.4)
24
+ json_pure (1.7.4)
25
+ libwebsocket (0.1.5)
25
26
  addressable
26
- mime-types (1.18)
27
- multi_json (1.2.0)
28
- nokogiri (1.5.2)
27
+ mime-types (1.19)
28
+ multi_json (1.3.6)
29
+ nokogiri (1.5.5)
29
30
  patron (0.4.18)
30
31
  rack (1.4.1)
31
32
  rack-protection (1.2.0)
@@ -36,31 +37,33 @@ GEM
36
37
  rdoc (3.12)
37
38
  json (~> 1.4)
38
39
  redcarpet (1.17.2)
39
- reek (1.2.8)
40
- ruby2ruby (~> 1.2)
40
+ reek (1.2.12)
41
+ ripper_ruby_parser (~> 0.0.7)
42
+ ruby2ruby (~> 1.2.5)
41
43
  ruby_parser (~> 2.0)
42
44
  sexp_processor (~> 3.0)
43
- rspec (2.9.0)
44
- rspec-core (~> 2.9.0)
45
- rspec-expectations (~> 2.9.0)
46
- rspec-mocks (~> 2.9.0)
47
- rspec-core (2.9.0)
48
- rspec-expectations (2.9.1)
45
+ ripper_ruby_parser (0.0.8)
46
+ sexp_processor (~> 3.0)
47
+ rspec (2.11.0)
48
+ rspec-core (~> 2.11.0)
49
+ rspec-expectations (~> 2.11.0)
50
+ rspec-mocks (~> 2.11.0)
51
+ rspec-core (2.11.1)
52
+ rspec-expectations (2.11.2)
49
53
  diff-lcs (~> 1.1.3)
50
- rspec-mocks (2.9.0)
51
- ruby2ruby (1.3.1)
54
+ rspec-mocks (2.11.1)
55
+ ruby2ruby (1.2.5)
52
56
  ruby_parser (~> 2.0)
53
57
  sexp_processor (~> 3.0)
54
58
  ruby_parser (2.3.1)
55
59
  sexp_processor (~> 3.0)
56
- rubyzip (0.9.7)
57
- selenium-webdriver (2.21.0)
60
+ rubyzip (0.9.9)
61
+ selenium-webdriver (2.25.0)
58
62
  childprocess (>= 0.2.5)
59
- ffi (~> 1.0)
60
63
  libwebsocket (~> 0.1.3)
61
64
  multi_json (~> 1.0)
62
65
  rubyzip
63
- sexp_processor (3.1.0)
66
+ sexp_processor (3.2.0)
64
67
  sinatra (1.3.2)
65
68
  rack (~> 1.3, >= 1.3.6)
66
69
  rack-protection (~> 1.2)
@@ -68,13 +71,14 @@ GEM
68
71
  tilt (1.3.3)
69
72
  xpath (0.1.4)
70
73
  nokogiri (~> 1.3)
71
- yard (0.7.5)
74
+ yard (0.8.2.1)
72
75
 
73
76
  PLATFORMS
74
77
  ruby
75
78
 
76
79
  DEPENDENCIES
77
80
  capybara
81
+ find_a_port (>= 1.0.1)
78
82
  jeweler
79
83
  json_pure
80
84
  patron
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.25.0
1
+ 0.26.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.25.0"
8
+ s.version = "0.26.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["John Wilger", "Sam Livingston-Gray", "Ravi Gadad"]
12
- s.date = "2012-07-08"
12
+ s.date = "2012-07-27"
13
13
  s.description = "Cucumber + Capybara = Kookaburra? It made sense at the time."
14
14
  s.email = "johnwilger@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -40,6 +40,7 @@ Gem::Specification.new do |s|
40
40
  "lib/kookaburra/mental_model_matcher.rb",
41
41
  "lib/kookaburra/test_helpers.rb",
42
42
  "lib/kookaburra/ui_driver.rb",
43
+ "lib/kookaburra/ui_driver/has_ui_components.rb",
43
44
  "lib/kookaburra/ui_driver/ui_component.rb",
44
45
  "lib/kookaburra/ui_driver/ui_component/address_bar.rb",
45
46
  "spec/integration/test_a_rack_application_spec.rb",
@@ -53,6 +54,7 @@ Gem::Specification.new do |s|
53
54
  "spec/kookaburra/ui_driver/ui_component_spec.rb",
54
55
  "spec/kookaburra/ui_driver_spec.rb",
55
56
  "spec/kookaburra_spec.rb",
57
+ "spec/support/shared_examples/it_can_have_ui_components.rb",
56
58
  "spec/support/shared_examples/it_can_make_assertions.rb",
57
59
  "spec/support/shared_examples/it_has_a_dependency_accessor.rb"
58
60
  ]
@@ -75,6 +77,7 @@ Gem::Specification.new do |s|
75
77
  s.add_development_dependency(%q<jeweler>, [">= 0"])
76
78
  s.add_development_dependency(%q<reek>, [">= 0"])
77
79
  s.add_development_dependency(%q<sinatra>, [">= 0"])
80
+ s.add_development_dependency(%q<find_a_port>, [">= 1.0.1"])
78
81
  else
79
82
  s.add_dependency(%q<patron>, [">= 0"])
80
83
  s.add_dependency(%q<json_pure>, [">= 0"])
@@ -85,6 +88,7 @@ Gem::Specification.new do |s|
85
88
  s.add_dependency(%q<jeweler>, [">= 0"])
86
89
  s.add_dependency(%q<reek>, [">= 0"])
87
90
  s.add_dependency(%q<sinatra>, [">= 0"])
91
+ s.add_dependency(%q<find_a_port>, [">= 1.0.1"])
88
92
  end
89
93
  else
90
94
  s.add_dependency(%q<patron>, [">= 0"])
@@ -96,6 +100,7 @@ Gem::Specification.new do |s|
96
100
  s.add_dependency(%q<jeweler>, [">= 0"])
97
101
  s.add_dependency(%q<reek>, [">= 0"])
98
102
  s.add_dependency(%q<sinatra>, [">= 0"])
103
+ s.add_dependency(%q<find_a_port>, [">= 1.0.1"])
99
104
  end
100
105
  end
101
106
 
@@ -0,0 +1,28 @@
1
+ class Kookaburra
2
+ class UIDriver
3
+ # Classes that can contain reerences to {UIComponent} instances
4
+ # (i.e. {UIDriver} and {UIDriver::UIComponent} subclasses are
5
+ # extended by this module in order to set up those references.
6
+ # `UIDriver` and `UIComponent` are already extended, so you
7
+ # shouldn't need to do so elsewhere.
8
+ #
9
+ # Instances of the extending class must define a `#configuration`
10
+ # method that returns the current Kookaburra::Configuration
11
+ module HasUIComponents
12
+
13
+ # Tells the extending UIDriver or UIComponent about your {UIComponent} subclasses.
14
+ #
15
+ # @param [Symbol] component_name Will create an instance method of this
16
+ # name that returns an instance of the component_class
17
+ # @param [Class] component_class The {UIComponent} subclass that defines
18
+ # this component.
19
+ # @param [Hash] options An extra options hash that will be passed
20
+ # to the `UIComponent` on initialization.
21
+ def ui_component(component_name, component_class, options = {})
22
+ define_method(component_name) do
23
+ component_class.new(configuration, options)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,5 +1,6 @@
1
1
  require 'kookaburra/exceptions'
2
2
  require 'kookaburra/assertion'
3
+ require 'kookaburra/ui_driver/has_ui_components'
3
4
 
4
5
  class Kookaburra
5
6
  class UIDriver
@@ -67,6 +68,15 @@ class Kookaburra
67
68
  # override the {#component_path} method.
68
69
  class UIComponent
69
70
  include Assertion
71
+ extend HasUIComponents
72
+
73
+ # The {Kookaburra::Configuration} with which the component
74
+ # instance was instantiated.
75
+ attr_reader :configuration
76
+
77
+ # The options Hash with which the component instance was
78
+ # instantiated.
79
+ attr_reader :options
70
80
 
71
81
  # New UIComponent instances are typically created for you by your
72
82
  # {Kookaburra::UIDriver} instance.
@@ -74,7 +84,11 @@ class Kookaburra
74
84
  # @see Kookaburra::UIDriver.ui_component
75
85
  #
76
86
  # @param [Kookaburra::Configuration] configuration
77
- def initialize(configuration)
87
+ # @param [Hash] options An options hash that can be used to
88
+ # further configure a `UIComponent`'s behavior.
89
+ def initialize(configuration, options = {})
90
+ @configuration = configuration
91
+ @options = options
78
92
  @browser = configuration.browser
79
93
  @app_host = configuration.app_host
80
94
  @server_error_detection = configuration.server_error_detection
@@ -1,5 +1,6 @@
1
1
  require 'forwardable'
2
2
  require 'kookaburra/assertion'
3
+ require 'kookaburra/ui_driver/has_ui_components'
3
4
  require 'kookaburra/ui_driver/ui_component'
4
5
  require 'kookaburra/ui_driver/ui_component/address_bar'
5
6
 
@@ -60,20 +61,9 @@ class Kookaburra
60
61
  class UIDriver
61
62
  include Assertion
62
63
  extend Forwardable
64
+ extend HasUIComponents
63
65
 
64
66
  class << self
65
- # Tells the UIDriver about your {UIComponent} subclasses.
66
- #
67
- # @param [Symbol] component_name Will create an instance method of this
68
- # name that returns an instance of the component_class
69
- # @param [Class] component_class The {UIComponent} subclass that defines
70
- # this component.
71
- def ui_component(component_name, component_class)
72
- define_method(component_name) do
73
- component_class.new(@configuration)
74
- end
75
- end
76
-
77
67
  # Tells the UIDriver about sub-drivers (other {UIDriver} subclasses).
78
68
  #
79
69
  # @param [Symbol] driver_name Will create an instance method of this
@@ -2,22 +2,14 @@ require 'kookaburra/test_helpers'
2
2
  require 'kookaburra/json_api_driver'
3
3
  require 'capybara'
4
4
  require 'thwait'
5
+ require 'find_a_port'
5
6
 
6
7
  # These are required for the Rack app used for testing
7
8
  require 'sinatra/base'
8
9
  require 'json'
9
10
 
10
- # You'd think there would be a better way to do this, but if there is, I
11
- # can't find it.
12
- def find_available_port
13
- server = TCPServer.new('127.0.0.1', 0)
14
- server.addr[1]
15
- ensure
16
- server.close if server
17
- end
18
-
19
11
  # The server port to which the application server will attach
20
- APP_PORT = find_available_port
12
+ APP_PORT = FindAPort.available_port
21
13
 
22
14
  describe "testing a Rack application with Kookaburra" do
23
15
  describe "with an HTML interface" do
@@ -234,7 +226,33 @@ describe "testing a Rack application with Kookaburra" do
234
226
  end
235
227
  end
236
228
 
229
+ class WidgetDataContainer
230
+ def initialize(element)
231
+ @element = element
232
+ end
233
+
234
+ def to_hash
235
+ {
236
+ 'id' => @element.find('.id').text,
237
+ 'name' => @element.find('.name').text
238
+ }
239
+ end
240
+ end
241
+
242
+ class LastWidgetCreated < Kookaburra::UIDriver::UIComponent
243
+ def component_locator
244
+ @options[:component_locator]
245
+ end
246
+
247
+ def data
248
+ raise "Foo" unless visible?
249
+ WidgetDataContainer.new(self).to_hash
250
+ end
251
+ end
252
+
237
253
  class WidgetList < Kookaburra::UIDriver::UIComponent
254
+ ui_component :last_widget_created, LastWidgetCreated, :component_locator => '#widget_list .last_widget.created'
255
+
238
256
  def component_path
239
257
  '/widgets'
240
258
  end
@@ -245,15 +263,10 @@ describe "testing a Rack application with Kookaburra" do
245
263
 
246
264
  def widgets
247
265
  all('.widget_summary').map do |el|
248
- extract_widget_data(el)
266
+ WidgetDataContainer.new(el).to_hash
249
267
  end
250
268
  end
251
269
 
252
- def last_widget_created
253
- element = find('.last_widget.created')
254
- extract_widget_data(element)
255
- end
256
-
257
270
  def choose_to_create_new_widget
258
271
  click_on 'New Widget'
259
272
  end
@@ -261,15 +274,6 @@ describe "testing a Rack application with Kookaburra" do
261
274
  def choose_to_delete_widget(widget_data)
262
275
  find("#delete_#{widget_data['id']}").click_button('Delete')
263
276
  end
264
-
265
- private
266
-
267
- def extract_widget_data(element)
268
- {
269
- 'id' => element.find('.id').text,
270
- 'name' => element.find('.name').text
271
- }
272
- end
273
277
  end
274
278
 
275
279
  class WidgetForm < Kookaburra::UIDriver::UIComponent
@@ -301,7 +305,7 @@ describe "testing a Rack application with Kookaburra" do
301
305
  assert widget_list.visible?, "Widget list is not visible!"
302
306
  widget_list.choose_to_create_new_widget
303
307
  widget_form.submit('name' => 'My Widget')
304
- mental_model.widgets[name] = widget_list.last_widget_created
308
+ mental_model.widgets[name] = widget_list.last_widget_created.data
305
309
  end
306
310
 
307
311
  def delete_widget(name)
@@ -352,6 +356,7 @@ describe "testing a Rack application with Kookaburra" do
352
356
 
353
357
  ui.create_new_widget(:widget_c, :name => 'Bar')
354
358
 
359
+
355
360
  # As above, these are equivalent, but the second line is preferred.
356
361
  ui.widget_list.widgets.should == k.get_data(:widgets).values_at(:widget_a, :widget_b, :widget_c)
357
362
  ui.widget_list.widgets.should match_mental_model_of(:widgets)
@@ -50,7 +50,7 @@ describe Kookaburra::JsonApiDriver do
50
50
  end
51
51
 
52
52
  it 'returns the JSON-decoded response body' do
53
- json.post('/foo', 'bar').should == {'foo' => 'bar'}
53
+ json.post('/foo', :bar => :baz).should == {'foo' => 'bar'}
54
54
  end
55
55
  end
56
56
 
@@ -63,7 +63,7 @@ describe Kookaburra::JsonApiDriver do
63
63
  end
64
64
 
65
65
  it 'returns the JSON-decoded response body' do
66
- json.put('/foo', 'bar').should == {'foo' => 'bar'}
66
+ json.put('/foo', :bar => :baz).should == {'foo' => 'bar'}
67
67
  end
68
68
  end
69
69
 
@@ -1,10 +1,13 @@
1
1
  require 'kookaburra/ui_driver/ui_component'
2
2
  require 'support/shared_examples/it_can_make_assertions'
3
+ require 'support/shared_examples/it_can_have_ui_components'
3
4
 
4
5
  describe Kookaburra::UIDriver::UIComponent do
5
6
  let(:configuration) { stub('Configuration', :browser => nil, :app_host => nil, :server_error_detection => nil) }
6
7
  let(:component) { Kookaburra::UIDriver::UIComponent.new(configuration) }
7
8
 
9
+ it_behaves_like :it_can_have_ui_components, Kookaburra::UIDriver::UIComponent
10
+
8
11
  describe '#respond_to?' do
9
12
  let(:component) do
10
13
  klass = Class.new(Kookaburra::UIDriver::UIComponent) do
@@ -1,23 +1,10 @@
1
1
  require 'kookaburra/ui_driver'
2
2
  require 'support/shared_examples/it_has_a_dependency_accessor'
3
3
  require 'support/shared_examples/it_can_make_assertions'
4
+ require 'support/shared_examples/it_can_have_ui_components'
4
5
 
5
6
  describe Kookaburra::UIDriver do
6
- describe '.ui_component' do
7
- it 'adds an accessor method for the named component that defaults to an instance of the specified class' do
8
- foo_component_class = mock(Class)
9
- foo_component_class.should_receive(:new) \
10
- .with(:configuration) \
11
- .and_return(:a_foo_component)
12
-
13
- ui_driver_class = Class.new(Kookaburra::UIDriver) do
14
- ui_component :foo, foo_component_class
15
- end
16
-
17
- ui = ui_driver_class.new(:configuration)
18
- ui.foo.should == :a_foo_component
19
- end
20
- end
7
+ it_behaves_like :it_can_have_ui_components, Kookaburra::UIDriver
21
8
 
22
9
  describe '.ui_driver' do
23
10
  it 'adds an accessor method for the named driver that defaults to an instance of the specified class' do
@@ -0,0 +1,18 @@
1
+ shared_examples_for :it_can_have_ui_components do |subject_class|
2
+ describe '.ui_component' do
3
+ it 'adds an accessor method for the named component that defaults to an instance of the specified class' do
4
+ configuration = stub('Kookaburra::Configuration').as_null_object
5
+ foo_component_class = mock(Class)
6
+ foo_component_class.should_receive(:new) \
7
+ .with(configuration, :option => :value) \
8
+ .and_return(:a_foo_component)
9
+
10
+ component_container_class = Class.new(subject_class) do
11
+ ui_component :foo, foo_component_class, :option => :value
12
+ end
13
+
14
+ component_container = component_container_class.new(configuration)
15
+ component_container.foo.should == :a_foo_component
16
+ end
17
+ end
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kookaburra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.0
4
+ version: 0.26.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-07-08 00:00:00.000000000 Z
14
+ date: 2012-07-27 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: patron
@@ -157,6 +157,22 @@ dependencies:
157
157
  - - ! '>='
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
+ - !ruby/object:Gem::Dependency
161
+ name: find_a_port
162
+ requirement: !ruby/object:Gem::Requirement
163
+ none: false
164
+ requirements:
165
+ - - ! '>='
166
+ - !ruby/object:Gem::Version
167
+ version: 1.0.1
168
+ type: :development
169
+ prerelease: false
170
+ version_requirements: !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: 1.0.1
160
176
  description: Cucumber + Capybara = Kookaburra? It made sense at the time.
161
177
  email: johnwilger@gmail.com
162
178
  executables: []
@@ -188,6 +204,7 @@ files:
188
204
  - lib/kookaburra/mental_model_matcher.rb
189
205
  - lib/kookaburra/test_helpers.rb
190
206
  - lib/kookaburra/ui_driver.rb
207
+ - lib/kookaburra/ui_driver/has_ui_components.rb
191
208
  - lib/kookaburra/ui_driver/ui_component.rb
192
209
  - lib/kookaburra/ui_driver/ui_component/address_bar.rb
193
210
  - spec/integration/test_a_rack_application_spec.rb
@@ -201,6 +218,7 @@ files:
201
218
  - spec/kookaburra/ui_driver/ui_component_spec.rb
202
219
  - spec/kookaburra/ui_driver_spec.rb
203
220
  - spec/kookaburra_spec.rb
221
+ - spec/support/shared_examples/it_can_have_ui_components.rb
204
222
  - spec/support/shared_examples/it_can_make_assertions.rb
205
223
  - spec/support/shared_examples/it_has_a_dependency_accessor.rb
206
224
  homepage: http://github.com/projectdx/kookaburra
@@ -218,7 +236,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
218
236
  version: '0'
219
237
  segments:
220
238
  - 0
221
- hash: -3008907103704146289
239
+ hash: -40301256200075417
222
240
  required_rubygems_version: !ruby/object:Gem::Requirement
223
241
  none: false
224
242
  requirements: