kookaburra 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.travis.yml +1 -3
  4. data/README.markdown +259 -181
  5. data/Rakefile +11 -2
  6. data/kookaburra.gemspec +1 -0
  7. data/lib/kookaburra.rb +24 -9
  8. data/lib/kookaburra/api_client.rb +1 -1
  9. data/lib/kookaburra/api_driver.rb +1 -1
  10. data/lib/kookaburra/assertion.rb +1 -1
  11. data/lib/kookaburra/configuration.rb +25 -9
  12. data/lib/kookaburra/configuration/proxy.rb +55 -0
  13. data/lib/kookaburra/dependency_accessor.rb +7 -0
  14. data/lib/kookaburra/exceptions.rb +11 -3
  15. data/lib/kookaburra/mental_model.rb +5 -5
  16. data/lib/kookaburra/rack_app_server.rb +3 -12
  17. data/lib/kookaburra/test_helpers.rb +53 -12
  18. data/lib/kookaburra/ui_driver/ui_component.rb +9 -2
  19. data/lib/kookaburra/version.rb +1 -1
  20. data/spec/integration/test_a_rack_application_spec.rb +3 -2
  21. data/spec/integration/test_multiple_applications_spec.rb +96 -0
  22. data/spec/kookaburra/api_client_spec.rb +6 -5
  23. data/spec/kookaburra/api_driver_spec.rb +18 -0
  24. data/spec/kookaburra/configuration/proxy_spec.rb +39 -0
  25. data/spec/kookaburra/configuration_spec.rb +54 -2
  26. data/spec/kookaburra/mental_model_spec.rb +22 -20
  27. data/spec/kookaburra/test_helpers_spec.rb +60 -24
  28. data/spec/kookaburra/ui_driver/scoped_browser_spec.rb +3 -2
  29. data/spec/kookaburra/ui_driver/ui_component/address_bar_spec.rb +2 -1
  30. data/spec/kookaburra/ui_driver/ui_component_spec.rb +48 -14
  31. data/spec/kookaburra/ui_driver_spec.rb +4 -3
  32. data/spec/kookaburra_spec.rb +19 -14
  33. data/spec/spec_helper.rb +79 -0
  34. data/spec/support/shared_examples/it_can_have_ui_components.rb +2 -2
  35. data/spec/support/shared_examples/it_can_make_assertions.rb +3 -3
  36. data/spec/support/shared_examples/it_has_a_dependency_accessor.rb +3 -4
  37. metadata +25 -2
@@ -1,10 +1,11 @@
1
+ require 'spec_helper'
1
2
  require 'kookaburra/ui_driver/scoped_browser'
2
3
 
3
4
  describe Kookaburra::UIDriver::ScopedBrowser do
4
5
  it 'forwards all method calls to the browser but scopes them to the component locator' do
5
6
  browser = double('Browser')
6
- browser.should_receive(:within).with('#a_component_locator').and_yield
7
- browser.should_receive(:some_other_method).with(:foo)
7
+ expect(browser).to receive(:within).with('#a_component_locator').and_yield
8
+ expect(browser).to receive(:some_other_method).with(:foo)
8
9
  subject = Kookaburra::UIDriver::ScopedBrowser.new(browser, lambda { '#a_component_locator' })
9
10
  subject.some_other_method(:foo)
10
11
  end
@@ -1,10 +1,11 @@
1
+ require 'spec_helper'
1
2
  require 'kookaburra/ui_driver/ui_component/address_bar'
2
3
 
3
4
  describe Kookaburra::UIDriver::UIComponent::AddressBar do
4
5
  describe '#go_to' do
5
6
  let(:browser) {
6
7
  double('Capybara::Session', text: '').tap do |b|
7
- b.should_receive(:visit).with('http://site.example.com')
8
+ allow(b).to receive(:visit).with('http://site.example.com')
8
9
  end
9
10
  }
10
11
 
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'kookaburra/ui_driver/ui_component'
2
3
  require 'support/shared_examples/it_can_make_assertions'
3
4
  require 'support/shared_examples/it_can_have_ui_components'
@@ -24,10 +25,10 @@ describe Kookaburra::UIDriver::UIComponent do
24
25
  end
25
26
 
26
27
  it 'returns true if the component_locator is found in the DOM and is visible' do
27
- browser.should_receive(:has_css?) \
28
- .with('#my_component', :visible) \
28
+ expect(browser).to receive(:has_css?) \
29
+ .with('#my_component', visible: true) \
29
30
  .and_return(true)
30
- component.visible?.should == true
31
+ expect(component).to be_visible
31
32
  end
32
33
 
33
34
  context 'when the component_locator is not found in the DOM' do
@@ -35,7 +36,7 @@ describe Kookaburra::UIDriver::UIComponent do
35
36
 
36
37
  context 'and a server error is not detected' do
37
38
  it 'returns false' do
38
- component.visible?.should == false
39
+ expect(component).to_not be_visible
39
40
  end
40
41
  end
41
42
 
@@ -43,35 +44,68 @@ describe Kookaburra::UIDriver::UIComponent do
43
44
  let(:server_error_detection) { ->(browser) { true } }
44
45
 
45
46
  it 'raises UnexpectedResponse' do
46
- lambda { component.visible? } \
47
- .should raise_error(Kookaburra::UnexpectedResponse)
47
+ expect{ component.visible? }.to \
48
+ raise_error(Kookaburra::UnexpectedResponse)
48
49
  end
49
50
 
50
51
  it 'adds the text of the HTTP response to the exception message' do
51
- browser.stub(text: 'This is text from the HTTP response')
52
- lambda { component.visible? } \
53
- .should raise_error(Kookaburra::UnexpectedResponse,
54
- "Server Error Detected:\n" \
55
- + "This is text from the HTTP response")
52
+ allow(browser).to receive(:text) {
53
+ 'This is text from the HTTP response'
54
+ }
55
+
56
+ expect{ component.visible? }.to \
57
+ raise_error(Kookaburra::UnexpectedResponse,
58
+ "Server Error Detected:\n" \
59
+ + "This is text from the HTTP response")
56
60
  end
57
61
  end
58
62
  end
59
63
  end
60
64
 
65
+ describe '#not_visible?' do
66
+ before(:each) do
67
+ def component.component_locator
68
+ '#my_component'
69
+ end
70
+ end
71
+
72
+ it 'returns true if the component_locator is not found in the DOM or is not visible' do
73
+ expect(browser).to receive(:has_no_css?) \
74
+ .with('#my_component', visible: true) \
75
+ .and_return(true)
76
+ expect(component).to be_not_visible
77
+ end
78
+
79
+ it 'returns false if the component_locator is found in the DOM and is visible' do
80
+ expect(browser).to receive(:has_no_css?) \
81
+ .with('#my_component', visible: true) \
82
+ .and_return(false)
83
+ expect(component).to_not be_not_visible
84
+ end
85
+
86
+ context 'when the component_locator is found in the DOM' do
87
+ let(:browser) { double('Browser Driver', has_css?: false, text: '') }
88
+
89
+ it 'returns false' do
90
+ expect(component).to_not be_visible
91
+ end
92
+ end
93
+ end
94
+
61
95
  describe '#url' do
62
96
  it 'returns the app_host + #component_path' do
63
97
  def component.component_path
64
98
  '/foo/bar'
65
99
  end
66
- component.url.should == 'http://my.example.com/foo/bar'
100
+ expect(component.url).to eq 'http://my.example.com/foo/bar'
67
101
  end
68
102
  end
69
103
 
70
104
  describe 'protected methods (for use by subclasses)' do
71
105
  describe '#component_path' do
72
106
  it 'must be defined by subclasses' do
73
- lambda { component.send(:component_path) } \
74
- .should raise_error(Kookaburra::ConfigurationError)
107
+ expect{ component.send(:component_path) }.to \
108
+ raise_error(Kookaburra::ConfigurationError)
75
109
  end
76
110
  end
77
111
 
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'kookaburra/ui_driver'
2
3
  require 'support/shared_examples/it_has_a_dependency_accessor'
3
4
  require 'support/shared_examples/it_can_make_assertions'
@@ -9,7 +10,7 @@ describe Kookaburra::UIDriver do
9
10
  describe '.ui_driver' do
10
11
  it 'adds an accessor method for the named driver that defaults to an instance of the specified class' do
11
12
  foo_driver_class = double(Class)
12
- foo_driver_class.should_receive(:new) \
13
+ expect(foo_driver_class).to receive(:new) \
13
14
  .with(:configuration) \
14
15
  .and_return(:a_foo_driver)
15
16
 
@@ -18,7 +19,7 @@ describe Kookaburra::UIDriver do
18
19
  end
19
20
 
20
21
  ui = ui_driver_class.new(:configuration)
21
- ui.foo.should == :a_foo_driver
22
+ expect(ui.foo).to eq :a_foo_driver
22
23
  end
23
24
  end
24
25
 
@@ -26,7 +27,7 @@ describe Kookaburra::UIDriver do
26
27
  it 'returns the configured app_host' do
27
28
  config = double('Configuration', :app_host => 'http://my.example.com')
28
29
  driver = Kookaburra::UIDriver.new(config)
29
- driver.url.should == 'http://my.example.com'
30
+ expect(driver.url).to eq 'http://my.example.com'
30
31
  end
31
32
  end
32
33
 
@@ -1,8 +1,11 @@
1
+ require 'spec_helper'
1
2
  require 'kookaburra'
2
3
 
3
4
  describe Kookaburra do
4
5
  let(:configuration) {
5
- OpenStruct.new
6
+ double('configuration', :mental_model= => nil,
7
+ ui_driver_class: nil,
8
+ api_driver_class: nil)
6
9
  }
7
10
 
8
11
  let(:k) { Kookaburra.new(configuration) }
@@ -10,53 +13,55 @@ describe Kookaburra do
10
13
  describe '#api' do
11
14
  it 'returns an instance of the configured APIDriver' do
12
15
  my_api_driver_class = double(Class)
13
- my_api_driver_class.should_receive(:new) \
16
+ expect(my_api_driver_class).to receive(:new) \
14
17
  .with(configuration) \
15
18
  .and_return(:an_api_driver)
16
- configuration.stub(:api_driver_class => my_api_driver_class)
17
- k.api.should == :an_api_driver
19
+ allow(configuration).to receive(:api_driver_class) { my_api_driver_class }
20
+ expect(k.api).to eq :an_api_driver
18
21
  end
19
22
  end
20
23
 
21
24
  describe '#ui' do
22
25
  it 'returns an instance of the configured UIDriver' do
23
26
  my_ui_driver_class = double(Class)
24
- my_ui_driver_class.should_receive(:new) \
27
+ expect(my_ui_driver_class).to receive(:new) \
25
28
  .with(configuration) \
26
29
  .and_return(:a_ui_driver)
27
- configuration.stub(:ui_driver_class => my_ui_driver_class)
28
- k.ui.should == :a_ui_driver
30
+ allow(configuration).to receive(:ui_driver_class) { my_ui_driver_class }
31
+ expect(k.ui).to eq :a_ui_driver
29
32
  end
30
33
  end
31
34
 
32
35
  describe '#get_data' do
33
36
  it 'returns a dup of the specified MentalModel::Collection' do
34
37
  collection = double('MentalModel::Collection')
35
- collection.should_receive(:dup) \
38
+ expect(collection).to receive(:dup) \
36
39
  .and_return(:mental_model_collection_dup)
37
- configuration.stub(:mental_model => double(:foos => collection))
38
- k.get_data(:foos).should == :mental_model_collection_dup
40
+ allow(configuration).to receive(:mental_model) {
41
+ double(:foos => collection)
42
+ }
43
+ expect(k.get_data(:foos)).to eq :mental_model_collection_dup
39
44
  end
40
45
  end
41
46
 
42
47
  describe '.configuration' do
43
48
  it 'returns a Kookaburra::Configuration instance' do
44
- Kookaburra.configuration.should be_kind_of(Kookaburra::Configuration)
49
+ expect(Kookaburra.configuration).to be_kind_of(Kookaburra::Configuration)
45
50
  end
46
51
 
47
52
  it 'always returns the same configuration' do
48
53
  x = Kookaburra.configuration
49
54
  y = Kookaburra.configuration
50
55
  x.app_host = 'http://example.com'
51
- y.app_host.should == 'http://example.com'
56
+ expect(y.app_host).to eq 'http://example.com'
52
57
  end
53
58
  end
54
59
 
55
60
  describe '.configure' do
56
61
  it 'yields Kookaburra.configuration' do
57
62
  configuration = double('Kookaburra::Configuration')
58
- configuration.should_receive(:foo=).with(:bar)
59
- Kookaburra.stub(:configuration => configuration)
63
+ expect(configuration).to receive(:foo=).with(:bar)
64
+ allow(Kookaburra).to receive(:configuration) { configuration }
60
65
  Kookaburra.configure do |c|
61
66
  c.foo = :bar
62
67
  end
@@ -0,0 +1,79 @@
1
+ require 'codeclimate-test-reporter'
2
+ CodeClimate::TestReporter.start
3
+
4
+ # This file was generated by the `rspec --init` command. Conventionally, all
5
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
6
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
7
+ # file to always be loaded, without a need to explicitly require it in any files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, make a
13
+ # separate helper file that requires this one and then use it only in the specs
14
+ # that actually need it.
15
+ #
16
+ # The `.rspec` file also contains a few flags that are not defaults but that
17
+ # users commonly want.
18
+ #
19
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
20
+ RSpec.configure do |config|
21
+ # The settings below are suggested to provide a good initial experience
22
+ # with RSpec, but feel free to customize to your heart's content.
23
+ # These two settings work together to allow you to limit a spec run
24
+ # to individual examples or groups you care about by tagging them with
25
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
26
+ # get run.
27
+ config.filter_run :focus
28
+ config.run_all_when_everything_filtered = true
29
+
30
+ # Many RSpec users commonly either run the entire suite or an individual
31
+ # file, and it's useful to allow more verbose output when running an
32
+ # individual spec file.
33
+ if config.files_to_run.one?
34
+ # Use the documentation formatter for detailed output,
35
+ # unless a formatter has already been configured
36
+ # (e.g. via a command-line flag).
37
+ config.default_formatter = 'doc'
38
+ end
39
+
40
+ # Print the 10 slowest examples and example groups at the
41
+ # end of the spec run, to help surface which specs are running
42
+ # particularly slow.
43
+ # config.profile_examples = 10
44
+
45
+ # Run specs in random order to surface order dependencies. If you find an
46
+ # order dependency and want to debug it, you can fix the order by providing
47
+ # the seed, which is printed after each run.
48
+ # --seed 1234
49
+ config.order = :random
50
+
51
+ # Seed global randomization in this process using the `--seed` CLI option.
52
+ # Setting this allows you to use `--seed` to deterministically reproduce
53
+ # test failures related to randomization by passing the same `--seed` value
54
+ # as the one that triggered the failure.
55
+ Kernel.srand config.seed
56
+
57
+ # rspec-expectations config goes here. You can use an alternate
58
+ # assertion/expectation library such as wrong or the stdlib/minitest
59
+ # assertions if you prefer.
60
+ config.expect_with :rspec do |expectations|
61
+ # Enable only the newer, non-monkey-patching expect syntax.
62
+ # For more details, see:
63
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
64
+ expectations.syntax = :expect
65
+ end
66
+
67
+ # rspec-mocks config goes here. You can use an alternate test double
68
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
69
+ config.mock_with :rspec do |mocks|
70
+ # Enable only the newer, non-monkey-patching expect syntax.
71
+ # For more details, see:
72
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
73
+ mocks.syntax = :expect
74
+
75
+ # Prevents you from mocking or stubbing a method that does not exist on
76
+ # a real object. This is generally recommended.
77
+ mocks.verify_partial_doubles = true
78
+ end
79
+ end
@@ -3,7 +3,7 @@ shared_examples_for :it_can_have_ui_components do |subject_class|
3
3
  it 'adds an accessor method for the named component that defaults to an instance of the specified class' do
4
4
  configuration = double('Kookaburra::Configuration').as_null_object
5
5
  foo_component_class = double(Class)
6
- foo_component_class.should_receive(:new) \
6
+ allow(foo_component_class).to receive(:new) \
7
7
  .with(configuration, :option => :value) \
8
8
  .and_return(:a_foo_component)
9
9
 
@@ -12,7 +12,7 @@ shared_examples_for :it_can_have_ui_components do |subject_class|
12
12
  end
13
13
 
14
14
  component_container = component_container_class.new(configuration)
15
- component_container.foo.should == :a_foo_component
15
+ expect(component_container.foo).to eq :a_foo_component
16
16
  end
17
17
  end
18
18
  end
@@ -1,12 +1,12 @@
1
1
  shared_examples_for :it_can_make_assertions do
2
2
  describe '#assert' do
3
3
  it 'returns true if the condition is truthy' do
4
- subject.send(:assert, true, "Shouldn't see this message").should == true
4
+ expect(subject.send(:assert, true, "Shouldn't see this message")).to eq true
5
5
  end
6
6
 
7
7
  it 'raises a Kookaburra::AssertionFailed exception if the condition is not truthy' do
8
- lambda { subject.send(:assert, false, "False isn't true, dummy.") } \
9
- .should raise_error(Kookaburra::AssertionFailed, "False isn't true, dummy.")
8
+ expect{ subject.send(:assert, false, "False isn't true, dummy.") }.to \
9
+ raise_error(Kookaburra::AssertionFailed, "False isn't true, dummy.")
10
10
  end
11
11
  end
12
12
  end
@@ -2,20 +2,19 @@ shared_examples_for :it_has_a_dependency_accessor do |accessor_name|
2
2
  describe accessor_name.to_s do
3
3
  it "returns the #{accessor_name} object as assigned" do
4
4
  subject.send("#{accessor_name}=", :thing)
5
- subject.send(accessor_name).should == :thing
5
+ expect(subject.send(accessor_name)).to eq :thing
6
6
  end
7
7
 
8
8
  context "when the #{accessor_name} object is not set" do
9
9
  it 'raises a StandardError' do
10
- lambda { subject.send(accessor_name) } \
11
- .should raise_error(StandardError)
10
+ expect{ subject.send(accessor_name) }.to raise_error(StandardError)
12
11
  end
13
12
 
14
13
  it "explains that the #{accessor_name} was not set on initialiation" do
15
14
  begin
16
15
  subject.send(accessor_name)
17
16
  rescue StandardError => e
18
- e.message.should == "No #{accessor_name} object was set on #{subject.class.name} initialization."
17
+ expect(e.message).to eq "No #{accessor_name} object was set on #{subject.class.name} initialization."
19
18
  end
20
19
  end
21
20
  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: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Wilger
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-08-30 00:00:00.000000000 Z
13
+ date: 2014-09-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
@@ -194,6 +194,20 @@ dependencies:
194
194
  - - ">="
195
195
  - !ruby/object:Gem::Version
196
196
  version: '0'
197
+ - !ruby/object:Gem::Dependency
198
+ name: codeclimate-test-reporter
199
+ requirement: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: '0'
204
+ type: :development
205
+ prerelease: false
206
+ version_requirements: !ruby/object:Gem::Requirement
207
+ requirements:
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ version: '0'
197
211
  description: Cucumber + Capybara = Kookaburra? It made sense at the time.
198
212
  email:
199
213
  - johnwilger@gmail.com
@@ -219,6 +233,7 @@ files:
219
233
  - lib/kookaburra/api_driver.rb
220
234
  - lib/kookaburra/assertion.rb
221
235
  - lib/kookaburra/configuration.rb
236
+ - lib/kookaburra/configuration/proxy.rb
222
237
  - lib/kookaburra/dependency_accessor.rb
223
238
  - lib/kookaburra/exceptions.rb
224
239
  - lib/kookaburra/mental_model.rb
@@ -231,7 +246,10 @@ files:
231
246
  - lib/kookaburra/ui_driver/ui_component/address_bar.rb
232
247
  - lib/kookaburra/version.rb
233
248
  - spec/integration/test_a_rack_application_spec.rb
249
+ - spec/integration/test_multiple_applications_spec.rb
234
250
  - spec/kookaburra/api_client_spec.rb
251
+ - spec/kookaburra/api_driver_spec.rb
252
+ - spec/kookaburra/configuration/proxy_spec.rb
235
253
  - spec/kookaburra/configuration_spec.rb
236
254
  - spec/kookaburra/mental_model_spec.rb
237
255
  - spec/kookaburra/test_helpers_spec.rb
@@ -240,6 +258,7 @@ files:
240
258
  - spec/kookaburra/ui_driver/ui_component_spec.rb
241
259
  - spec/kookaburra/ui_driver_spec.rb
242
260
  - spec/kookaburra_spec.rb
261
+ - spec/spec_helper.rb
243
262
  - spec/support/json_api_app_and_kookaburra_drivers.rb
244
263
  - spec/support/shared_examples/it_can_have_ui_components.rb
245
264
  - spec/support/shared_examples/it_can_make_assertions.rb
@@ -270,7 +289,10 @@ specification_version: 4
270
289
  summary: Window Driver pattern for acceptance tests
271
290
  test_files:
272
291
  - spec/integration/test_a_rack_application_spec.rb
292
+ - spec/integration/test_multiple_applications_spec.rb
273
293
  - spec/kookaburra/api_client_spec.rb
294
+ - spec/kookaburra/api_driver_spec.rb
295
+ - spec/kookaburra/configuration/proxy_spec.rb
274
296
  - spec/kookaburra/configuration_spec.rb
275
297
  - spec/kookaburra/mental_model_spec.rb
276
298
  - spec/kookaburra/test_helpers_spec.rb
@@ -279,6 +301,7 @@ test_files:
279
301
  - spec/kookaburra/ui_driver/ui_component_spec.rb
280
302
  - spec/kookaburra/ui_driver_spec.rb
281
303
  - spec/kookaburra_spec.rb
304
+ - spec/spec_helper.rb
282
305
  - spec/support/json_api_app_and_kookaburra_drivers.rb
283
306
  - spec/support/shared_examples/it_can_have_ui_components.rb
284
307
  - spec/support/shared_examples/it_can_make_assertions.rb