kookaburra 0.23.1 → 0.24.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1,4 +1,4 @@
1
- rvm use ruby-1.9.3@kookaburra --create --install
2
- rvm use ruby-1.9.2@kookaburra --create --install
3
- rvm use ree-1.8.7@kookaburra --create --install
4
- rvm use ruby-1.8.7@kookaburra --create --install
1
+ rvm use ruby-1.9.3@kookaburra --create --install; bundle check
2
+ rvm use ruby-1.9.2@kookaburra --create --install; bundle check
3
+ rvm use ree-1.8.7@kookaburra --create --install; bundle check
4
+ rvm use ruby-1.8.7@kookaburra --create --install; bundle check
data/Gemfile CHANGED
@@ -1,8 +1,8 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gem 'i18n'
4
- gem 'activesupport', '>= 3.0'
5
4
  gem 'patron'
5
+ gem 'json_pure'
6
6
 
7
7
  # Add dependencies to develop your gem here.
8
8
  # Include everything needed to run rake, tests, features, etc.
@@ -1,9 +1,6 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activesupport (3.2.3)
5
- i18n (~> 0.6)
6
- multi_json (~> 1.0)
7
4
  addressable (2.2.7)
8
5
  capybara (1.1.2)
9
6
  mime-types (>= 1.16)
@@ -24,6 +21,7 @@ GEM
24
21
  rake
25
22
  rdoc
26
23
  json (1.6.6)
24
+ json_pure (1.7.3)
27
25
  libwebsocket (0.1.3)
28
26
  addressable
29
27
  mime-types (1.18)
@@ -77,10 +75,10 @@ PLATFORMS
77
75
  ruby
78
76
 
79
77
  DEPENDENCIES
80
- activesupport (>= 3.0)
81
78
  capybara
82
79
  i18n
83
80
  jeweler
81
+ json_pure
84
82
  patron
85
83
  redcarpet (~> 1.0)
86
84
  reek
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.23.1
1
+ 0.24.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "kookaburra"
8
- s.version = "0.23.1"
8
+ s.version = "0.24.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-04-13"
12
+ s.date = "2012-05-15"
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 = [
@@ -67,8 +67,8 @@ Gem::Specification.new do |s|
67
67
 
68
68
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
69
69
  s.add_runtime_dependency(%q<i18n>, [">= 0"])
70
- s.add_runtime_dependency(%q<activesupport>, [">= 3.0"])
71
70
  s.add_runtime_dependency(%q<patron>, [">= 0"])
71
+ s.add_runtime_dependency(%q<json_pure>, [">= 0"])
72
72
  s.add_development_dependency(%q<rspec>, [">= 0"])
73
73
  s.add_development_dependency(%q<capybara>, [">= 0"])
74
74
  s.add_development_dependency(%q<yard>, [">= 0"])
@@ -78,8 +78,8 @@ Gem::Specification.new do |s|
78
78
  s.add_development_dependency(%q<sinatra>, [">= 0"])
79
79
  else
80
80
  s.add_dependency(%q<i18n>, [">= 0"])
81
- s.add_dependency(%q<activesupport>, [">= 3.0"])
82
81
  s.add_dependency(%q<patron>, [">= 0"])
82
+ s.add_dependency(%q<json_pure>, [">= 0"])
83
83
  s.add_dependency(%q<rspec>, [">= 0"])
84
84
  s.add_dependency(%q<capybara>, [">= 0"])
85
85
  s.add_dependency(%q<yard>, [">= 0"])
@@ -90,8 +90,8 @@ Gem::Specification.new do |s|
90
90
  end
91
91
  else
92
92
  s.add_dependency(%q<i18n>, [">= 0"])
93
- s.add_dependency(%q<activesupport>, [">= 3.0"])
94
93
  s.add_dependency(%q<patron>, [">= 0"])
94
+ s.add_dependency(%q<json_pure>, [">= 0"])
95
95
  s.add_dependency(%q<rspec>, [">= 0"])
96
96
  s.add_dependency(%q<capybara>, [">= 0"])
97
97
  s.add_dependency(%q<yard>, [">= 0"])
@@ -1,5 +1,3 @@
1
- require 'active_support/core_ext/string'
2
-
3
1
  class Kookaburra
4
2
  # @private
5
3
  module DependencyAccessor
@@ -15,8 +13,10 @@ class Kookaburra
15
13
 
16
14
  def define_dependency_accessor(name)
17
15
  define_method(name) do
16
+ class_name = self.class.name
17
+ class_name.sub!(/^$/, 'an Anonymous Class!!!')
18
18
  instance_variable_get("@#{name}") or raise "No %s object was set on %s initialization." \
19
- % [name, [self.class.name, 'an Anonymous Class!!!'].reject(&:blank?).first]
19
+ % [name, class_name]
20
20
  end
21
21
 
22
22
  define_method("#{name}=") do |value|
@@ -1,4 +1,4 @@
1
- require 'active_support/core_ext/module/delegation'
1
+ require 'forwardable'
2
2
 
3
3
  class Kookaburra
4
4
  # Your GivenDriver subclass is used to define your testing DSL for setting up
@@ -33,6 +33,8 @@ class Kookaburra
33
33
  # end
34
34
  # end
35
35
  class GivenDriver
36
+ extend Forwardable
37
+
36
38
  # It is unlikely that you would call #initialize yourself; your GivenDriver
37
39
  # object is instantiated for you by {Kookaburra#given}.
38
40
  #
@@ -48,7 +50,7 @@ class Kookaburra
48
50
  # Access to the shared {Kookaburra::MentalModel} instance
49
51
  #
50
52
  # @attribute [rw] mental_model
51
- delegate :mental_model, :to => :configuration
53
+ def_delegator :configuration, :mental_model
52
54
 
53
55
  # Used to access your APIDriver in your own GivenDriver implementation
54
56
  #
@@ -1,6 +1,6 @@
1
- require 'kookaburra/api_driver'
2
1
  require 'delegate'
3
- require 'active_support/json'
2
+ require 'json'
3
+ require 'kookaburra/api_driver'
4
4
 
5
5
  class Kookaburra
6
6
  # Delegates all methods (by default) to and instance of
@@ -55,11 +55,11 @@ class Kookaburra
55
55
  end
56
56
 
57
57
  def encode(data)
58
- ActiveSupport::JSON.encode(data) unless data.nil?
58
+ JSON.dump(data) unless data.nil?
59
59
  end
60
60
 
61
61
  def decode(data)
62
- ActiveSupport::JSON.decode(data)
62
+ JSON.parse(data)
63
63
  end
64
64
  end
65
65
  end
@@ -1,6 +1,5 @@
1
1
  require 'delegate'
2
2
  require 'kookaburra/exceptions'
3
- require 'active_support/core_ext/hash'
4
3
 
5
4
  class Kookaburra
6
5
  # Each instance of {Kookaburra} has its own instance of MentalModel. This object
@@ -69,6 +68,33 @@ class Kookaburra
69
68
  self.object_id == other.object_id
70
69
  end
71
70
 
71
+ # Returns a new hash that contains key/value pairs for the
72
+ # specified keys with values copied from this collection.
73
+ #
74
+ # @note This is semantically the same as `Hash#slice` as provided
75
+ # by `ActiveSupport::CoreExt::Hash`
76
+ # @param [Object] *keys The keys that should be copied from the
77
+ # collection
78
+ # @return [Hash] The resulting keys/values from the collection
79
+ def slice(*keys)
80
+ data = keys.inject({}) { |memo, key|
81
+ memo[key] = self[key]
82
+ memo
83
+ }
84
+ end
85
+
86
+ # Returns a new hash that contains every key/value from this
87
+ # collection *except* for the specified keys
88
+ #
89
+ # @note This is semantically the same as `Hash#except` as provided
90
+ # by `ActiveSupport::CoreExt::Hash`
91
+ # @param [Object] *keys The keys that should *not* be copied from
92
+ # the collection
93
+ # @return [Hash] The resulting keys/values from the collection
94
+ def except(*keys)
95
+ slice(*(self.keys - keys))
96
+ end
97
+
72
98
  # Deletes a key/value pair from the collection, and persists the deleted pair
73
99
  # in a subcollection.
74
100
  #
@@ -53,7 +53,7 @@ class Kookaburra
53
53
  # @return Boolean
54
54
  def matches?(actual)
55
55
  @actual = actual
56
- expected_items_not_found.empty? && unexpected_items_found.empty?
56
+ expected_items_found? && !unexpected_items_found?
57
57
  end
58
58
 
59
59
  # Message to be printed when observed reality does not conform to
@@ -64,13 +64,13 @@ class Kookaburra
64
64
  # @return String
65
65
  def failure_message_for_should
66
66
  message = "expected #{@collection_key} to match the user's mental model, but:\n"
67
- if expected_items_not_found.present?
67
+ unless expected_items_found?
68
68
  message += "expected to be present: #{pp_array(expected_items)}\n"
69
- message += "the missing elements were: #{pp_array(expected_items_not_found)}\n"
69
+ message += "the missing elements were: #{pp_array(expected_items_that_were_not_found)}\n"
70
70
  end
71
- if unexpected_items_found.present?
71
+ if unexpected_items_found?
72
72
  message += "expected to not be present: #{pp_array(unexpected_items)}\n"
73
- message += "the unexpected extra elements: #{pp_array(unexpected_items_found)}\n"
73
+ message += "the unexpected extra elements: #{pp_array(unexpected_items_that_were_found)}\n"
74
74
  end
75
75
  message
76
76
  end
@@ -99,15 +99,23 @@ class Kookaburra
99
99
  def expected_items; @expected.values; end
100
100
  def unexpected_items; @unexpected.values; end
101
101
 
102
- def expected_items_not_found
102
+ def expected_items_that_were_not_found
103
103
  difference_between_arrays(expected_items, @actual)
104
104
  end
105
105
 
106
- def unexpected_items_found
106
+ def unexpected_items_that_were_found
107
107
  unexpected_items_not_found = difference_between_arrays(unexpected_items, @actual)
108
108
  difference_between_arrays(unexpected_items, unexpected_items_not_found)
109
109
  end
110
110
 
111
+ def expected_items_found?
112
+ expected_items_that_were_not_found.empty?
113
+ end
114
+
115
+ def unexpected_items_found?
116
+ !unexpected_items_that_were_found.empty?
117
+ end
118
+
111
119
  # (Swiped from RSpec's array matcher)
112
120
  # Returns the difference of arrays, accounting for duplicates.
113
121
  # e.g., difference_between_arrays([1, 2, 3, 3], [1, 2, 3]) # => [3]
@@ -1,6 +1,6 @@
1
+ require 'forwardable'
1
2
  require 'kookaburra'
2
3
  require 'kookaburra/mental_model_matcher'
3
- require 'active_support/core_ext/module/delegation'
4
4
 
5
5
  class Kookaburra
6
6
  # This module is intended to be mixed in to your testing context to provide
@@ -81,6 +81,8 @@ class Kookaburra
81
81
  # ui.widget_list.widgets.should == k.get_data(:widgets).slice(widgets)
82
82
  # end
83
83
  module TestHelpers
84
+ extend Forwardable
85
+
84
86
  # The {Kookaburra} instance to be used by your tests. It gets configured
85
87
  # using the options set in {Kookaburra.configuration}, and the result is
86
88
  # memoized.
@@ -92,11 +94,11 @@ class Kookaburra
92
94
 
93
95
  # @method given
94
96
  # Delegates to {#k}
95
- delegate :given, :to => :k
97
+ def_delegator :k, :given
96
98
 
97
99
  # @method ui
98
100
  # Delegates to {#k}
99
- delegate :ui, :to => :k
101
+ def_delegator :k, :ui
100
102
 
101
103
  # RSpec-style custom matcher that compares a given array with
102
104
  # the current state of one named collection in the mental model
@@ -1,5 +1,4 @@
1
- require 'active_support/core_ext/hash'
2
- require 'active_support/core_ext/module/delegation'
1
+ require 'forwardable'
3
2
  require 'kookaburra/assertion'
4
3
  require 'kookaburra/ui_driver/ui_component'
5
4
  require 'kookaburra/ui_driver/ui_component/address_bar'
@@ -60,6 +59,7 @@ class Kookaburra
60
59
  # ui.account_management.account_list.should be_visible
61
60
  class UIDriver
62
61
  include Assertion
62
+ extend Forwardable
63
63
 
64
64
  class << self
65
65
  # Tells the UIDriver about your {UIComponent} subclasses.
@@ -112,6 +112,8 @@ class Kookaburra
112
112
 
113
113
  # @attribute [r] mental_model
114
114
  # @return [Kookaburra::MentalModel]
115
- delegate :mental_model, :to => :@configuration
115
+ def_delegator :configuration, :mental_model
116
+
117
+ attr_reader :configuration
116
118
  end
117
119
  end
@@ -1,6 +1,5 @@
1
1
  require 'kookaburra/exceptions'
2
2
  require 'kookaburra/assertion'
3
- require 'active_support/core_ext/object/try'
4
3
 
5
4
  class Kookaburra
6
5
  class UIDriver
@@ -148,7 +147,8 @@ class Kookaburra
148
147
  # @raise [UnexpectedResponse] raised if the server error detection
149
148
  # function returns true
150
149
  def detect_server_error!
151
- if @server_error_detection.try(:call, browser)
150
+ return if @server_error_detection.nil?
151
+ if @server_error_detection.call(browser)
152
152
  raise UnexpectedResponse, "Your server error detection function detected a server error. Looks like your applications is busted. :-("
153
153
  end
154
154
  end
@@ -5,8 +5,7 @@ require 'thwait'
5
5
 
6
6
  # These are required for the Rack app used for testing
7
7
  require 'sinatra/base'
8
- require 'active_support/json'
9
- require 'active_support/hash_with_indifferent_access'
8
+ require 'json'
10
9
 
11
10
  # The server port that the application server will attach to
12
11
  APP_PORT = ENV['APP_PORT'] || 3009
@@ -24,7 +23,7 @@ describe "testing a Rack application with Kookaburra" do
24
23
 
25
24
  def parse_json_req_body
26
25
  request.body.rewind
27
- ActiveSupport::JSON.decode(request.body.read).symbolize_keys
26
+ JSON.parse(request.body.read, :symbolize_names => true)
28
27
  end
29
28
 
30
29
  post '/users' do
@@ -104,7 +103,7 @@ describe "testing a Rack application with Kookaburra" do
104
103
  widget_data = if request.media_type == 'application/json'
105
104
  parse_json_req_body
106
105
  else
107
- params.symbolize_keys.slice(:name)
106
+ {:name => params['name']}
108
107
  end
109
108
  widget_data[:id] = `uuidgen`.strip
110
109
  @@widgets << widget_data
@@ -24,11 +24,21 @@ describe Kookaburra::MentalModel do
24
24
  end
25
25
 
26
26
  describe '#slice' do
27
- it 'returns a hash of items matching the specified keys' do
27
+ it 'returns a hash of items from the collection that match the specified keys' do
28
28
  collection[:foo] = 'foo'
29
29
  collection[:bar] = 'bar'
30
30
  collection[:baz] = 'baz'
31
- collection.slice(:foo, :baz).should == { :foo => 'foo', :baz => 'baz' }
31
+ collection.slice(:foo, :baz).should == {:foo => 'foo', :baz => 'baz'}
32
+ end
33
+ end
34
+
35
+ describe '#except' do
36
+ it 'returns a hash of items from the collection that do not match the specified keys' do
37
+ collection[:foo] = 'foo'
38
+ collection[:bar] = 'bar'
39
+ collection[:baz] = 'baz'
40
+ collection[:yak] = 'yak'
41
+ collection.except(:foo, :baz).should == {:bar => 'bar', :yak => 'yak'}
32
42
  end
33
43
  end
34
44
 
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: 65
4
+ hash: 127
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 23
9
- - 1
10
- version: 0.23.1
8
+ - 24
9
+ - 0
10
+ version: 0.24.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - John Wilger
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2012-04-13 00:00:00 Z
20
+ date: 2012-05-15 00:00:00 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  type: :runtime
@@ -40,13 +40,12 @@ dependencies:
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- hash: 7
43
+ hash: 3
44
44
  segments:
45
- - 3
46
45
  - 0
47
- version: "3.0"
46
+ version: "0"
48
47
  version_requirements: *id002
49
- name: activesupport
48
+ name: patron
50
49
  prerelease: false
51
50
  - !ruby/object:Gem::Dependency
52
51
  type: :runtime
@@ -60,7 +59,7 @@ dependencies:
60
59
  - 0
61
60
  version: "0"
62
61
  version_requirements: *id003
63
- name: patron
62
+ name: json_pure
64
63
  prerelease: false
65
64
  - !ruby/object:Gem::Dependency
66
65
  type: :development