kookaburra 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.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.1.1"
8
+ s.version = "0.2.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-16"
12
+ s.date = "2012-01-17"
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 = [
@@ -3,14 +3,12 @@ module Kookaburra
3
3
  module HasUIComponent
4
4
  module ClassMethods
5
5
  def ui_component(component_name)
6
- component_class = component_name.to_s.camelize.constantize
7
-
8
6
  self.ui_component_names << component_name
9
7
 
10
8
  define_method(component_name) do
11
9
  options = { :browser => browser, :test_data => test_data }
12
10
  # TODO: memoize the following line?
13
- component_class.new(options)
11
+ component_class(component_name).new(options)
14
12
  end
15
13
 
16
14
  define_method("has_#{component_name}?") do
@@ -23,6 +21,10 @@ module Kookaburra
23
21
  def ui_components
24
22
  ui_component_names.map { |name| self.send(name) }
25
23
  end
24
+
25
+ def component_class(component_name)
26
+ self.class.const_get(component_name.to_s.camelize)
27
+ end
26
28
  end
27
29
 
28
30
  def self.included(receiver)
data/lib/kookaburra.rb CHANGED
@@ -52,6 +52,33 @@ module Kookaburra
52
52
  # We allow this to be passed in, so that we can avoid a hard-coded
53
53
  # dependency on Capybara in this gem.
54
54
  attr_accessor :adapter
55
+
56
+ # The API Driver that will be used by Kookaburra, typically a subclass of
57
+ # Kookaburra::APIDriver containing the testing DSL for your app. The default
58
+ # is an instance of Kookaburra::APIDriver.
59
+ attr_accessor :api_driver
60
+
61
+ def api_driver
62
+ @api_driver ||= Kookaburra::APIDriver
63
+ end
64
+
65
+ # The Given Driver that will be used by Kookaburra, typically a subclass of
66
+ # Kookaburra::GivenDriver containing the testing DSL for your app. The default
67
+ # is an instance of Kookaburra::GivenDriver.
68
+ attr_accessor :given_driver
69
+
70
+ def given_driver
71
+ @given_driver ||= Kookaburra::GivenDriver
72
+ end
73
+
74
+ # The UI Driver that will be used by Kookaburra, typically a subclass of
75
+ # Kookaburra::UIDriver containing the testing DSL for your app. The default
76
+ # is an instance of Kookaburra::UIDriver.
77
+ attr_accessor :ui_driver
78
+
79
+ def ui_driver
80
+ @ui_driver ||= Kookaburra::UIDriver
81
+ end
55
82
  end
56
83
 
57
84
  # Whatever was set in `Kookaburra.adapter can be overriden in the mixin
@@ -66,25 +93,25 @@ module Kookaburra
66
93
  #
67
94
  attr_accessor :kookaburra_adapter
68
95
 
69
- def kookaburra_adapter #:nodoc:
96
+ def kookaburra_adapter
70
97
  @kookaburra_adapter ||= Kookaburra.adapter
71
98
  end
72
99
 
73
100
  # Returns a configured instance of the `Kookaburra::APIDriver`
74
101
  def api
75
- kookaburra_drivers[:api] ||= Kookaburra::APIDriver.new(
102
+ kookaburra_drivers[:api] ||= Kookaburra.api_driver.new(
76
103
  :app => kookaburra_adapter.app,
77
104
  :test_data => kookaburra_test_data)
78
105
  end
79
106
 
80
107
  # Returns a configured instance of the `Kookaburra::GivenDriver`
81
108
  def given
82
- kookaburra_drivers[:given] ||= Kookaburra::GivenDriver.new(:api_driver => api)
109
+ kookaburra_drivers[:given] ||= Kookaburra.given_driver.new(:api_driver => api)
83
110
  end
84
111
 
85
112
  # Returns a configured instance of the `Kookaburra::UIDriver`
86
113
  def ui
87
- kookaburra_drivers[:ui] ||= Kookaburra::UIDriver.new(
114
+ kookaburra_drivers[:ui] ||= Kookaburra.ui_driver.new(
88
115
  :browser => kookaburra_adapter.current_session,
89
116
  :test_data => kookaburra_test_data)
90
117
  end
@@ -36,16 +36,27 @@ describe Kookaburra do
36
36
 
37
37
  describe '#kookaburra_adapter' do
38
38
  it 'is a read/write attribute' do
39
- mixer = mixer_class.new
40
- assert_nil mixer.kookaburra_adapter
41
39
  mixer.kookaburra_adapter = :probably_Capybara
42
40
  assert_equal :probably_Capybara, mixer.kookaburra_adapter
43
41
  end
42
+
43
+ it 'defaults to the value of Kookaburra.adapter' do
44
+ begin
45
+ old_adapter = Kookaburra.adapter
46
+ Kookaburra.adapter = :global_adapter
47
+ mixer = mixer_class.new
48
+ assert_equal :global_adapter, mixer.kookaburra_adapter
49
+ ensure
50
+ Kookaburra.adapter = old_adapter
51
+ end
52
+ end
44
53
  end
45
54
 
46
55
  describe '#api' do
47
- it 'is an instance of Kookaburra::APIDriver' do
48
- assert_kind_of(Kookaburra::APIDriver, mixer.api)
56
+ it 'is an instance of Kookaburra.api_driver' do
57
+ klass = Class.new(Kookaburra::APIDriver)
58
+ Kookaburra.api_driver = klass
59
+ assert_kind_of(klass, mixer.api)
49
60
  end
50
61
 
51
62
  it 'only creates a new one once for an instance of the including class' do
@@ -58,8 +69,10 @@ describe Kookaburra do
58
69
  end
59
70
 
60
71
  describe '#given' do
61
- it 'is an instance of Kookaburra::GivenDriver' do
62
- assert_kind_of(Kookaburra::GivenDriver, mixer.given)
72
+ it 'is an instance of Kookaburra.given_driver' do
73
+ klass = Class.new(Kookaburra::GivenDriver)
74
+ Kookaburra.given_driver = klass
75
+ assert_kind_of(klass, mixer.given)
63
76
  end
64
77
 
65
78
  it 'only creates a new one once for an instance of the including class' do
@@ -72,8 +85,10 @@ describe Kookaburra do
72
85
  end
73
86
 
74
87
  describe '#ui' do
75
- it 'is an instance of Kookaburra::UIDriver' do
76
- assert_kind_of(Kookaburra::UIDriver, mixer.ui)
88
+ it 'is an instance of Kookaburra.ui_driver' do
89
+ klass = Class.new(Kookaburra::UIDriver)
90
+ Kookaburra.ui_driver = klass
91
+ assert_kind_of(klass, mixer.ui)
77
92
  end
78
93
 
79
94
  it 'only creates a new one once for an instance of the including class' do
@@ -107,5 +122,51 @@ describe Kookaburra do
107
122
  refute_same ui, ui2
108
123
  end
109
124
  end
125
+ end
126
+
127
+ describe 'methods on the Kookaburra object' do
128
+ describe '#adapter' do
129
+ it 'is a read/write attribute' do
130
+ assert_nil Kookaburra.adapter
131
+ Kookaburra.adapter = :probably_Capybara
132
+ assert_equal :probably_Capybara, Kookaburra.adapter
133
+ end
134
+ end
135
+
136
+ describe '#api_driver' do
137
+ it 'is a read/write attribute' do
138
+ Kookaburra.api_driver = :an_api_driver
139
+ assert_equal :an_api_driver, Kookaburra.api_driver
140
+ end
141
+
142
+ it 'defaults to Kookaburra::APIDriver' do
143
+ Kookaburra.api_driver = nil
144
+ assert_equal Kookaburra::APIDriver, Kookaburra.api_driver
145
+ end
146
+ end
147
+
148
+ describe '#given_driver' do
149
+ it 'is a read/write attribute' do
150
+ Kookaburra.given_driver = :a_given_driver
151
+ assert_equal :a_given_driver, Kookaburra.given_driver
152
+ end
153
+
154
+ it 'defaults to Kookaburra::GivenDriver' do
155
+ Kookaburra.given_driver = nil
156
+ assert_equal Kookaburra::GivenDriver, Kookaburra.given_driver
157
+ end
158
+ end
159
+
160
+ describe '#ui_driver' do
161
+ it 'is a read/write attribute' do
162
+ Kookaburra.ui_driver = :a_ui_driver
163
+ assert_equal :a_ui_driver, Kookaburra.ui_driver
164
+ end
165
+
166
+ it 'defaults to Kookaburra::UIDriver' do
167
+ Kookaburra.ui_driver = nil
168
+ assert_equal Kookaburra::UIDriver, Kookaburra.ui_driver
169
+ end
170
+ end
110
171
  end
111
172
  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: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
8
+ - 2
9
+ - 0
10
+ version: 0.2.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-16 00:00:00 Z
18
+ 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