ae_page_objects 1.5.0 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bdbc7b1c3cc7929e18cae25d6b5a0073bc941d85
4
- data.tar.gz: 0767bbea656f6a123d00c2dae7c00673714272d3
3
+ metadata.gz: 2dec9e34721561ba781508ef0b2c14b254fa4f5f
4
+ data.tar.gz: 33356ca72c8529bbb1c64169c42c290c545b486b
5
5
  SHA512:
6
- metadata.gz: 12c29ba3329811692f161d16a46dc95bf187492c49585295e183f2d63bc356420a3ea76a4cb158b77f49db322517f18b674020741424389427f975c7189d3fb9
7
- data.tar.gz: fa23580da483d787a283c96ac7495780ff52b17dd7563892aa4e89bed21205e15a97b64de1a547aafeb373f3391496fce569bf1f933d443b241e9e15eeca5d63
6
+ metadata.gz: 3ff183bf91b4049702f1fbb32192e7f92d05e279743c1091e0a5740ea50dc89ccf595a7fdefa3ae7c3cdf14a77fef9c3f214d9ad5a8f1bcf58d5ae4b6b9e12ea
7
+ data.tar.gz: 4b7c1c3de1d8f16b7f38b2cfaf4f67e5b5f0b1671b614d0be8a5e147bcf568104c82e00362d06428e2bebce6bdd29c939acb486441a8efd343eea461056b2ecf
@@ -9,14 +9,12 @@ module AePageObjects
9
9
  autoload :Site, 'ae_page_objects/core/site'
10
10
  autoload :BasicRouter, 'ae_page_objects/core/basic_router'
11
11
  autoload :ApplicationRouter, 'ae_page_objects/core/application_router'
12
- autoload :RakeRouter, 'ae_page_objects/core/rake_router'
13
12
  autoload :Dsl, 'ae_page_objects/core/dsl'
14
13
 
15
14
  autoload :Singleton, 'ae_page_objects/util/singleton'
16
15
  autoload :InternalHelpers, 'ae_page_objects/util/internal_helpers'
17
16
  autoload :HashSymbolizer, 'ae_page_objects/util/hash_symbolizer'
18
17
  autoload :Inflector, 'ae_page_objects/util/inflector'
19
- autoload :Waiter, 'ae_page_objects/util/waiter'
20
18
 
21
19
  module MultipleWindows
22
20
  autoload :Browser, 'ae_page_objects/multiple_windows/browser'
@@ -32,8 +30,6 @@ module AePageObjects
32
30
  autoload :SameWindowLoaderStrategy, 'ae_page_objects/single_window/same_window_loader_strategy'
33
31
  end
34
32
 
35
- autoload :Window, 'ae_page_objects/window'
36
-
37
33
  autoload :DocumentQuery, 'ae_page_objects/document_query'
38
34
  autoload :DocumentLoader, 'ae_page_objects/document_loader'
39
35
 
@@ -48,35 +44,48 @@ module AePageObjects
48
44
  autoload :Select, 'ae_page_objects/elements/select'
49
45
  autoload :Checkbox, 'ae_page_objects/elements/checkbox'
50
46
 
51
- def self.browser
52
- @browser ||= begin
53
- driver = Capybara.current_session.driver
47
+ class << self
54
48
 
55
- case driver
56
- when Capybara::Selenium::Driver then
57
- MultipleWindows::Browser.new
58
- else
59
- SingleWindow::Browser.new
49
+ def browser
50
+ @browser ||= begin
51
+ driver = Capybara.current_session.driver
52
+
53
+ case driver
54
+ when Capybara::Selenium::Driver then
55
+ MultipleWindows::Browser.new
56
+ else
57
+ SingleWindow::Browser.new
58
+ end
60
59
  end
61
60
  end
62
- end
63
61
 
64
- def self.wait_until(seconds_to_wait = nil, error_message = nil)
65
- seconds_to_wait ||= Capybara.default_wait_time
66
- start_time = Time.now
62
+ def wait_until(seconds_to_wait = nil, error_message = nil)
63
+ seconds_to_wait ||= default_max_wait_time
64
+ start_time = Time.now
65
+
66
+ until result = yield
67
+ delay = seconds_to_wait - (Time.now - start_time)
67
68
 
68
- until result = yield
69
- delay = seconds_to_wait - (Time.now - start_time)
69
+ if delay <= 0
70
+ raise WaitTimeoutError, error_message || "Timed out waiting for condition"
71
+ end
70
72
 
71
- if delay <= 0
72
- raise WaitTimeoutError, error_message || "Timed out waiting for condition"
73
+ sleep(0.05)
74
+ raise FrozenInTime, "Time appears to be frozen" if Time.now == start_time
73
75
  end
74
76
 
75
- sleep(0.05)
76
- raise FrozenInTime, "Time appears to be frozen" if Time.now == start_time
77
+ result
77
78
  end
78
79
 
79
- result
80
+ private
81
+
82
+ def default_max_wait_time
83
+ if Capybara.respond_to?(:default_max_wait_time)
84
+ Capybara.default_max_wait_time
85
+ else
86
+ Capybara.default_wait_time
87
+ end
88
+ end
80
89
  end
81
90
  end
82
91
 
@@ -58,29 +58,6 @@ module AePageObjects
58
58
  ResolvedRoute = Struct.new(:controller, :action)
59
59
  end
60
60
 
61
- class Rails23 < Base
62
-
63
- private
64
-
65
- def routes
66
- @routes ||= begin
67
- routes_class = Class.new do
68
- include ActionController::UrlWriter
69
- end
70
- ActionController::Routing::Routes.install_helpers(routes_class)
71
- routes_class.new
72
- end
73
- end
74
-
75
- def normalize_url(url)
76
- url
77
- end
78
-
79
- def router
80
- ActionController::Routing::Routes
81
- end
82
- end
83
-
84
61
  class Rails3 < Base
85
62
 
86
63
  private
@@ -155,9 +132,7 @@ module AePageObjects
155
132
 
156
133
  def recognizer
157
134
  @recognizer ||= begin
158
- if ::Rails.version =~ /\A2\.3/
159
- Recognizer::Rails23.new
160
- elsif ::Rails.version =~ /\A3\.[01]/
135
+ if ::Rails.version =~ /\A3\.[01]/
161
136
  Recognizer::Rails3.new
162
137
  elsif ::Rails.version =~ /\A3\.2/
163
138
  Recognizer::Rails32.new
@@ -33,11 +33,6 @@ module AePageObjects
33
33
  false
34
34
  end
35
35
 
36
- def not_visible?
37
- warn "[DEPRECATION WARNING]: AePageObjects::Element#not_visible? is deprecated and will be removed in version 2.0.0. Use AePageObjects::Element#hidden? instead."
38
- hidden?
39
- end
40
-
41
36
  def present?
42
37
  wait_until_present
43
38
  true
@@ -52,11 +47,6 @@ module AePageObjects
52
47
  false
53
48
  end
54
49
 
55
- def not_present?
56
- warn "[DEPRECATION WARNING]: AePageObjects::Element#not_present? is deprecated and will be removed in version 2.0.0. Use AePageObjects::Element#absent? instead."
57
- absent?
58
- end
59
-
60
50
  def presence
61
51
  implicit_element
62
52
  rescue LoadingElementFailed
@@ -90,11 +80,6 @@ module AePageObjects
90
80
  raise ElementNotPresent, "element_class: #{@element_class}, options: #{@options.inspect}"
91
81
  end
92
82
 
93
- def wait_for_presence(timeout = nil)
94
- warn "[DEPRECATION WARNING]: AePageObjects::Element#wait_for_presence is deprecated and will be removed in version 2.0.0. Use AePageObjects::Element#wait_until_present instead."
95
- wait_until_present(timeout)
96
- end
97
-
98
83
  def wait_until_absent(timeout = nil)
99
84
  with_reloaded_element(timeout) do
100
85
  @loaded_element.nil?
@@ -104,11 +89,6 @@ module AePageObjects
104
89
  raise ElementNotAbsent, "element_class: #{@element_class}, options: #{@options.inspect}"
105
90
  end
106
91
 
107
- def wait_for_absence(timeout = nil)
108
- warn "[DEPRECATION WARNING]: AePageObjects::Element#wait_for_absence is deprecated and will be removed in version 2.0.0. Use AePageObjects::Element#wait_until_absent instead."
109
- wait_until_absent(timeout)
110
- end
111
-
112
92
  def is_a?(type)
113
93
  type == @element_class || type == ElementProxy
114
94
  end
@@ -65,23 +65,19 @@ module AePageObjects
65
65
  def item_xpath
66
66
  @item_xpath ||= begin
67
67
  evaled_locator = eval_locator(@item_locator)
68
+
69
+ query_args = evaled_locator + [{:exact => true}]
70
+ query = Capybara::Query.new(*query_args)
68
71
 
69
- if Capybara::VERSION =~ /\A1/
70
- Capybara::Selector.normalize(*evaled_locator).xpaths.first
71
- else
72
- query_args = evaled_locator + [{:exact => true}]
73
- query = Capybara::Query.new(*query_args)
72
+ result = query.xpath
74
73
 
75
- result = query.xpath
76
-
77
- # if it's CSS, we need to run it through XPath as Capybara::Query#xpath only
78
- # works when the selector is xpath. Lame.
79
- if query.selector.format == :css
80
- result = XPath.css(query.xpath).to_xpath
81
- end
82
-
83
- result
74
+ # if it's CSS, we need to run it through XPath as Capybara::Query#xpath only
75
+ # works when the selector is xpath. Lame.
76
+ if query.selector.format == :css
77
+ result = XPath.css(query.xpath).to_xpath
84
78
  end
79
+
80
+ result
85
81
  end
86
82
  end
87
83
 
@@ -1,3 +1,3 @@
1
1
  module AePageObjects
2
- VERSION = '1.5.0'.freeze
2
+ VERSION = '2.0.0.beta1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ae_page_objects
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 2.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donnie Tognazzini
@@ -14,22 +14,16 @@ dependencies:
14
14
  name: capybara
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.1'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '2.8'
19
+ version: '2.1'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '1.1'
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: '2.8'
26
+ version: '2.1'
33
27
  description: Capybara Page Objects pattern
34
28
  email:
35
29
  - engineering@appfolio.com
@@ -41,7 +35,6 @@ files:
41
35
  - lib/ae_page_objects/core/application_router.rb
42
36
  - lib/ae_page_objects/core/basic_router.rb
43
37
  - lib/ae_page_objects/core/dsl.rb
44
- - lib/ae_page_objects/core/rake_router.rb
45
38
  - lib/ae_page_objects/core/site.rb
46
39
  - lib/ae_page_objects/core/universe.rb
47
40
  - lib/ae_page_objects/core_ext/module.rb
@@ -70,9 +63,7 @@ files:
70
63
  - lib/ae_page_objects/util/internal_helpers.rb
71
64
  - lib/ae_page_objects/util/page_polling.rb
72
65
  - lib/ae_page_objects/util/singleton.rb
73
- - lib/ae_page_objects/util/waiter.rb
74
66
  - lib/ae_page_objects/version.rb
75
- - lib/ae_page_objects/window.rb
76
67
  homepage: http://github.com/appfolio/ae_page_objects
77
68
  licenses:
78
69
  - MIT
@@ -85,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
85
76
  requirements:
86
77
  - - ">="
87
78
  - !ruby/object:Gem::Version
88
- version: '0'
79
+ version: 1.9.3
89
80
  required_rubygems_version: !ruby/object:Gem::Requirement
90
81
  requirements:
91
82
  - - ">="
@@ -1,152 +0,0 @@
1
- module AePageObjects
2
- class RakeRouter < BasicRouter
3
-
4
- attr_reader :routes
5
-
6
- def initialize(rake_routes, mounted_prefix = '')
7
- warn "[DEPRECATION WARNING]: AePageObjects::RakeRouter is deprecated and will be removed in version 2.0.0."
8
-
9
- @mounted_prefix = mounted_prefix || ""
10
- @routes = {}
11
- route_line_regex = /(\w+)(?:\s[A-Z]+)?\s+(\/.*)\(.:format\).*$/
12
-
13
- rake_routes.split("\n").each do |line|
14
- line = line.strip
15
- matches = route_line_regex.match(line)
16
- if matches
17
- @routes[matches[1].to_sym] = Route.new(matches[2], @mounted_prefix)
18
- end
19
- end
20
- end
21
-
22
- def path_recognizes_url?(path, url)
23
- if path.is_a?(Symbol)
24
- route = @routes[path]
25
- route && route.matches?(url)
26
- else
27
- super
28
- end
29
- end
30
-
31
- def generate_path(named_route, *args)
32
- if named_route.is_a?(String)
33
- return Path.new(@mounted_prefix + named_route)
34
- end
35
-
36
- if route = @routes[named_route]
37
- options = args.last.is_a?(Hash) ? args.pop : {}
38
- route.generate_path(options)
39
- end
40
- end
41
-
42
- private
43
-
44
- class Path < String
45
- attr_reader :params, :regex
46
-
47
- def initialize(value)
48
- super(value.gsub(/(\/)+/, '/').sub(/\(\.\:format\)$/, ''))
49
-
50
- @params = parse_params
51
- @regex = generate_regex
52
- end
53
-
54
- def generate(param_values)
55
- param_values = HashSymbolizer.new(param_values).symbolize_keys
56
- @params.values.inject(self) do |path, param|
57
- param.substitute(path, param_values)
58
- end
59
- end
60
-
61
- private
62
- def parse_params
63
- # overwrite the required status with the optional
64
- {}.merge(required_params).merge(optional_params)
65
- end
66
-
67
- def find_params(using_regex)
68
- scan(using_regex).flatten.map(&:to_sym)
69
- end
70
-
71
- def optional_params
72
- {}.tap do |optional_params|
73
- find_params(/\(\/\:(\w+)\)/).each do |param_name|
74
- optional_params[param_name] = Param.new(param_name, true)
75
- end
76
- end
77
- end
78
-
79
- def required_params
80
- {}.tap do |required_params|
81
- find_params(/\:(\w+)/).each do |param_name|
82
- required_params[param_name] = Param.new(param_name, false)
83
- end
84
- end
85
- end
86
-
87
- def generate_regex
88
- regex_spec = @params.values.inject(self) do |regex_spec, param|
89
- param.replace_param_in_url(regex_spec)
90
- end
91
- Regexp.new regex_spec
92
- end
93
- end
94
-
95
- class Param < Struct.new(:name, :optional)
96
- include Comparable
97
-
98
- def optional?
99
- optional
100
- end
101
-
102
- def <=>(other)
103
- name.to_s <=> other.name.to_s
104
- end
105
-
106
- def eql?(other)
107
- name == other.name
108
- end
109
-
110
- def hash
111
- name.hash
112
- end
113
-
114
- def replace_param_in_url(url)
115
- if optional?
116
- url.gsub("(/:#{name})", '(\/.+)?')
117
- else
118
- url.gsub(":#{name}", '(.+)')
119
- end
120
- end
121
-
122
- def substitute(url, values)
123
- if optional?
124
- if values[name]
125
- url.sub("(/:#{name})", "/#{values[name]}")
126
- else
127
- url.sub("(/:#{name})", '')
128
- end
129
- else
130
- raise ArgumentError, "Missing required parameter '#{name}' for '#{url}' in #{values.inspect}" unless values.key? name
131
- url.sub(":#{name}", values[name])
132
- end
133
- end
134
- end
135
-
136
- class Route
137
- def initialize(spec, mounted_prefix)
138
- @path = Path.new(mounted_prefix + spec)
139
- @path.freeze
140
- end
141
-
142
- def matches?(url)
143
- url =~ @path.regex
144
- end
145
-
146
- def generate_path(options)
147
- options = HashSymbolizer.new(options).symbolize_keys
148
- @path.generate(options)
149
- end
150
- end
151
- end
152
- end
@@ -1,32 +0,0 @@
1
- require 'ae_page_objects/util/page_polling'
2
-
3
- module AePageObjects
4
- module Waiter
5
- class << self
6
- include AePageObjects::PagePolling
7
-
8
- def wait_until(timeout = nil, &block)
9
- warn "[DEPRECATION WARNING]: AePageObjects::Waiter.wait_until is deprecated and will be removed in version 2.0.0. Use AePageObjects.wait_until instead."
10
- wait_until_return_false(timeout, &block)
11
- end
12
-
13
- def wait_for(timeout = nil, &block)
14
- warn "[DEPRECATION WARNING]: AePageObjects::Waiter.wait_for is deprecated and will be removed in version 2.0.0. Use AePageObjects.wait_until instead."
15
- wait_until_return_false(timeout, &block)
16
- end
17
-
18
- def wait_until!(timeout = nil, &block)
19
- warn "[DEPRECATION WARNING]: AePageObjects::Waiter.wait_until! is deprecated and will be removed in version 2.0.0. Use AePageObjects.wait_until instead."
20
- poll_until(timeout, &block)
21
- end
22
-
23
- private
24
-
25
- def wait_until_return_false(timeout, &block)
26
- poll_until(timeout, &block)
27
- rescue WaitTimeoutError
28
- false
29
- end
30
- end
31
- end
32
- end
@@ -1,19 +0,0 @@
1
- unless AePageObjects.respond_to?(:browser)
2
- raise "Deprecation warnings out of date."
3
- end
4
-
5
- module AePageObjects
6
- class Window
7
- class << self
8
- def all
9
- warn "[DEPRECATION WARNING]: AePageObjects::Window.all is deprecated. Use AePageObjects.browser.windows()"
10
- AePageObjects.browser.windows
11
- end
12
-
13
- def close_all
14
- warn "[DEPRECATION WARNING]: AePageObjects::Window.close_all is deprecated. Use AePageObjects.browser.windows.close_all()"
15
- all.close_all
16
- end
17
- end
18
- end
19
- end