appom 0.7.2 → 0.7.3

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
  SHA256:
3
- metadata.gz: d71f4b1ffb22a76d11c9c98a6e6394ad50263dc06ec7abbf749141bd968dd13b
4
- data.tar.gz: 1d851b42ab205c6328e281674a702bbfdc5d2b87a2d195d0ca9f3a942fa43c7e
3
+ metadata.gz: 37ebc727ef6c2feb2f7d4098ad6fed4a6921de7715686bb9c70c155b5c85b710
4
+ data.tar.gz: 6110ce4011fefa4f4615d8b160b7dc654da546d2874b90d1dfaf61150a686dc2
5
5
  SHA512:
6
- metadata.gz: 4908fefd966ad6e8fdddfb88f836311e3115cb8781faab6af39f49b92ef410f90e5e979e92296b9c4aa1027afa2258d094828623d617f16204b0ec7a7a288789
7
- data.tar.gz: 7a71f39865ee617a77a5ae0b96b6b451b4f647e5d1ca97b8c204a6f0ebc215f733fb279715f7bbe180281fbc49e53c7af8c1ce7a4aeb55371b1c6297a84b951a
6
+ metadata.gz: 8f78893b02b096e667223f2ad3d55da4844ebedcaacccb37c4b96126b4b1087449ab8201fc2ccf69722c1df8e4b04548be90384e4292a1a6fd6d685a358697a8
7
+ data.tar.gz: eb5e5b89e891e58743ea002a637ce0eef046a22d7476c994831c9b1c104688b917d6be25a714b04344a5fe0dc8292cb0f29a96fb9594e030ca93e2ecedfe9b05
@@ -14,6 +14,8 @@ module Appom
14
14
  class TimeoutError < StandardError; end
15
15
  # An element could not be located on the page using the given search parameters.
16
16
  class NoSuchElementError < StandardError; end
17
+ # An elements is empty using the given search parameters.
18
+ class ElementsEmptyError < StandardError; end
17
19
 
18
20
  autoload :ElementContainer, 'appom/element_container'
19
21
  autoload :Page, 'appom/page'
@@ -92,7 +92,7 @@ module Appom
92
92
 
93
93
  def sections(name, *args, &block)
94
94
  section_class, find_args = extract_section_options(args, &block)
95
- build_elements(name, *find_args) do
95
+ build_sections(section_class, name, *find_args) do
96
96
  define_method(name) do |*runtime_args, &block|
97
97
  raise_if_block(self, name, !block.nil?, :sections)
98
98
  _all(*merge_args(find_args, runtime_args)).map do |element|
@@ -117,7 +117,7 @@ module Appom
117
117
 
118
118
  private
119
119
 
120
- # Add item to @mapped_items or define method for element
120
+ # Add item to @mapped_items or define method for element and section
121
121
  def build_element(name, *find_args)
122
122
  if find_args.empty?
123
123
  create_error_method(name)
@@ -146,6 +146,20 @@ module Appom
146
146
  create_get_all_elements(name, *find_args)
147
147
  end
148
148
 
149
+ # Add item to @mapped_items or define method for elements
150
+ def build_sections(section_class, name, *find_args)
151
+ if find_args.empty?
152
+ create_error_method(name)
153
+ else
154
+ add_to_mapped_items(name)
155
+ yield
156
+ end
157
+
158
+ create_existence_checker(name, *find_args)
159
+ create_nonexistence_checker(name, *find_args)
160
+ create_get_all_sections(section_class, name, *find_args)
161
+ end
162
+
149
163
  # Define method to notify that we can't find item without args
150
164
  def create_error_method(name)
151
165
  define_method(name) do
@@ -153,12 +167,6 @@ module Appom
153
167
  end
154
168
  end
155
169
 
156
- def add_helper_methods(name, *find_args)
157
- create_existence_checker(name, *find_args)
158
- create_nonexistence_checker(name, *find_args)
159
- create_get_all_elements(name, *find_args)
160
- end
161
-
162
170
  def create_helper_method(proposed_method_name, *find_args)
163
171
  if find_args.empty?
164
172
  create_error_method(proposed_method_name)
@@ -205,7 +213,22 @@ module Appom
205
213
  create_helper_method(method_name, *find_args) do
206
214
  define_method(method_name) do |*runtime_args|
207
215
  args = merge_args(find_args, runtime_args)
208
- wait_check_util_empty(*args)
216
+ wait_util_get_not_empty(*args)
217
+ end
218
+ end
219
+ end
220
+
221
+ ##
222
+ # Try to get all sections until not get empty array
223
+ #
224
+ def create_get_all_sections(section_class, element_name, *find_args)
225
+ method_name = "get_all_#{element_name}"
226
+ create_helper_method(method_name, *find_args) do
227
+ define_method(method_name) do |*runtime_args|
228
+ args = merge_args(find_args, runtime_args)
229
+ wait_util_get_not_empty(*args).map do |element|
230
+ section_class.new(self, element)
231
+ end
209
232
  end
210
233
  end
211
234
  end
@@ -43,7 +43,7 @@ module Appom
43
43
  result = page.find_elements(*find_args)
44
44
  # If reponse is empty we will return false to make it not pass Wait condition
45
45
  if result.empty?
46
- return false
46
+ raise Appom::ElementsEmptyError, "Array is empty"
47
47
  end
48
48
  # Return result
49
49
  return result
@@ -1,3 +1,3 @@
1
1
  module Appom
2
- VERSION = '0.7.2'.freeze
2
+ VERSION = '0.7.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry.Tran