ae_page_objects 5.0.0.tim1 → 5.0.0

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
- SHA1:
3
- metadata.gz: dbfd8677597cf0026b13d31f3a468148cedab2df
4
- data.tar.gz: 7385fcd650b5ea30d077e6fd7fcc23c997808fc1
2
+ SHA256:
3
+ metadata.gz: 9ac141566f7fa0ef821de7597f5ca1c52d8e20a2a73a772c186631ea9340b3ba
4
+ data.tar.gz: e43b377ece706710f77792e4e7a4540160bd94ee4d81f0f5e6e8b360df452a49
5
5
  SHA512:
6
- metadata.gz: d1bd1f9f15668d99c7ed9e9ff604bd54d23b5159d702b01188194b51fcc145614dc960bf242216fd7b7976b909523dc06a226e465cc5b4599c9b2b87d37665b1
7
- data.tar.gz: 2de8621bfc85d7c66306af7c9761e3b0a57692bc307c97e2df1a23f003334867be5dd2cd039d5051c05add08e0e1dd1199972630ce2ddb1dba9ceb0b148d2fa2
6
+ metadata.gz: 67411eea6351ede5cf53ba6944b5ab15ee1066208df1afb7d493dbe6a99de623881d8742fbb764ef04a92103f6432af9dbc597ffb6e0d0fad02b0ad3842ae4d2
7
+ data.tar.gz: 83146923f3c423858fbaddafd47f0532bfd5c6b7658e256766d6bbb697c1228eb3f57c4776526694278b0b75dc7946dda8bf4f809d280b447081d36a9793c920
@@ -89,6 +89,11 @@ module AePageObjects
89
89
  def configure(options)
90
90
  @locator = options.delete(:locator)
91
91
  @name = options.delete(:name)
92
+ if options.key?(:wait)
93
+ @wait = options.delete(:wait)
94
+ else
95
+ @wait = true
96
+ end
92
97
 
93
98
  @name = @name.to_s if @name
94
99
  end
@@ -107,20 +112,24 @@ module AePageObjects
107
112
 
108
113
  def scoped_node
109
114
  locator = eval_locator(@locator)
110
- if locator.empty?
111
- parent.node
115
+
116
+ return parent.node if locator.empty?
117
+
118
+ default_options = { minimum: 0 }
119
+ if locator.last.is_a?(::Hash)
120
+ locator[-1] = default_options.merge(locator.last)
112
121
  else
113
- default_options = { minimum: 0 }
114
- if locator.last.is_a?(::Hash)
115
- locator[-1] = default_options.merge(locator.last)
116
- else
117
- locator.push(default_options)
118
- end
122
+ locator.push(default_options)
123
+ end
119
124
 
125
+ if @wait
120
126
  node = AePageObjects.wait_until { parent.node.first(*locator) }
121
- node.allow_reload!
122
- node
127
+ else
128
+ node = parent.node.first(*locator)
129
+ raise LoadingElementFailed, 'Element Not Found' unless node
123
130
  end
131
+ node.allow_reload!
132
+ node
124
133
  rescue AePageObjects::WaitTimeoutError => e
125
134
  raise LoadingElementFailed, e.message
126
135
  end
@@ -15,36 +15,22 @@ module AePageObjects
15
15
  @loaded_element = nil
16
16
  end
17
17
 
18
- def visible?(options = {})
19
- options[:wait] ||= 0
20
- wait_until_visible(options[:wait])
21
- true
22
- rescue ElementNotVisible
23
- false
18
+ def visible?
19
+ reload_element
20
+ @loaded_element&.visible?
24
21
  end
25
22
 
26
- def hidden?(options = {})
27
- options[:wait] ||= 0
28
- wait_until_hidden(options[:wait])
29
- true
30
- rescue ElementNotHidden
31
- false
23
+ def hidden?
24
+ !visible?
32
25
  end
33
26
 
34
- def present?(options = {})
35
- options[:wait] ||= 0
36
- wait_until_present(options[:wait])
37
- true
38
- rescue ElementNotPresent
39
- false
27
+ def present?
28
+ reload_element
29
+ !@loaded_element.nil?
40
30
  end
41
31
 
42
- def absent?(options = {})
43
- options[:wait] ||= 0
44
- wait_until_absent(options[:wait])
45
- true
46
- rescue ElementNotAbsent
47
- false
32
+ def absent?
33
+ !present?
48
34
  end
49
35
 
50
36
  def presence
@@ -127,8 +113,19 @@ module AePageObjects
127
113
 
128
114
  private
129
115
 
130
- def load_element
131
- @element_class.new(*@args)
116
+ def load_element(wait: true)
117
+ args = @args.dup
118
+
119
+ options_or_locator = args.pop
120
+ options = if options_or_locator.is_a?(Hash)
121
+ options_or_locator.merge(wait: wait)
122
+ else
123
+ { locator: options_or_locator, wait: wait }
124
+ end
125
+
126
+ args << options
127
+
128
+ @element_class.new(*args)
132
129
  end
133
130
 
134
131
  def implicit_element
@@ -136,7 +133,7 @@ module AePageObjects
136
133
  end
137
134
 
138
135
  def reload_element
139
- @loaded_element = load_element
136
+ @loaded_element = load_element(wait: false)
140
137
  rescue LoadingElementFailed
141
138
  @loaded_element = nil
142
139
  end
@@ -133,12 +133,12 @@ module AePageObjects
133
133
  private
134
134
 
135
135
  def recognizer
136
- @recognizer ||= case ::Rails.version
137
- when /\A3\.[01]/
136
+ @recognizer ||= case ::Rails.gem_version
137
+ when Gem::Requirement.new('>= 3.0', '< 3.2')
138
138
  Recognizer::Rails3.new
139
- when /\A3\.2/
139
+ when Gem::Requirement.new('~> 3.2')
140
140
  Recognizer::Rails32.new
141
- when /\A(4\.[012]|5\.0)/
141
+ when Gem::Requirement.new('>= 4.0', '< 7.0')
142
142
  Recognizer::Rails4Plus.new
143
143
  else
144
144
  warn "[WARNING]: AePageObjects is not tested against Rails #{::Rails.version} and may behave in an undefined manner."
@@ -1,3 +1,3 @@
1
1
  module AePageObjects
2
- VERSION = '5.0.0.tim1'.freeze
2
+ VERSION = '5.0.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ae_page_objects
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.tim1
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AppFolio Engineering
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-20 00:00:00.000000000 Z
11
+ date: 2021-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -64,7 +64,7 @@ homepage: http://github.com/appfolio/ae_page_objects
64
64
  licenses:
65
65
  - MIT
66
66
  metadata: {}
67
- post_install_message:
67
+ post_install_message:
68
68
  rdoc_options: []
69
69
  require_paths:
70
70
  - lib
@@ -75,13 +75,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
75
  version: 2.2.5
76
76
  required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - ">"
78
+ - - ">="
79
79
  - !ruby/object:Gem::Version
80
- version: 1.3.1
80
+ version: '0'
81
81
  requirements: []
82
- rubyforge_project:
83
- rubygems_version: 2.5.2
84
- signing_key:
82
+ rubygems_version: 3.1.2
83
+ signing_key:
85
84
  specification_version: 4
86
85
  summary: Capybara Page Objects pattern
87
86
  test_files: []