masteryconnect-automation-utils 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: db57579418efac7adddb2826e69822b076812cd8
4
+ data.tar.gz: 860c2822da65e32138bdc78b18b8e3fd58528189
5
+ SHA512:
6
+ metadata.gz: 59635a8a89f4a0c48ec0f02896c53166f5ac91d43ed89af6cbdcad29c601a60df02b0ef3811172c950e44a0c9784b3dcfbd94e2d0dc16b731edc191439b813d5
7
+ data.tar.gz: 9c75ee10bcbb528b544eabb8ad9f061ef8f0bda572c49252dfde43780af7b224acbf3a0e419ef2865b3a5c5173de059f0559c65febad50cff9e3c1a140ade4eb
@@ -0,0 +1,38 @@
1
+ # An alternative to Capybara's built-in implicit waits (using the 'find' method)
2
+ # @author nredmond@masteryconnect.com
3
+ module ImplicitWaitManager
4
+ # An exception to be thrown when an element was not found in the given amount of time.
5
+ class PageNotLoadedException < StandardError
6
+ def initialize message
7
+ super message
8
+ end
9
+ end
10
+
11
+ # Waits for an element to be visible on the page. Yields to a block where
12
+ # the element can be queried.
13
+ # @param seconds [Integer] The maximum number of seconds to wait for the
14
+ # element to become visible
15
+ # @param interval [Integer] The interval, in seconds, for which the function
16
+ # should wait to try again when an element is not visible
17
+ # @param message [String] The error message to present when the element was
18
+ # not visible within the specified number of seconds
19
+ def wait_until(seconds = 10, interval = 1,
20
+ message = 'The action could not be completed.' +
21
+ ' Maybe the page did not load, or the wrong locator was used.')
22
+ max_load_attempts = seconds / interval
23
+ number_load_attempts = 0
24
+
25
+ begin
26
+ yield
27
+ rescue Capybara::ElementNotFound
28
+ number_load_attempts += 1
29
+
30
+ if number_load_attempts > max_load_attempts
31
+ raise PageNotLoadedException.new message
32
+ else
33
+ sleep interval
34
+ retry
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,2 @@
1
+ require_relative 'recursive-hash-utils'
2
+ require_relative 'implicit-wait-manager'
@@ -0,0 +1,28 @@
1
+ # Helper methods to recursively modify Hash objects
2
+ # @author nredmond@masteryconnect.com
3
+ module RecursiveHashUtils
4
+ # Recursively convert all string keys in a Hash to symbol keys. Will recurse
5
+ # through nested Hash and Array objects.
6
+ def self.convert_string_keys_to_symbols hash
7
+ s2s = lambda do |h|
8
+ if Hash === h
9
+ Hash[
10
+ h.map do |k, v|
11
+ [k.respond_to?(:to_sym) ? k.to_sym : k, s2s[v]]
12
+ end
13
+ ]
14
+ elsif Array === h
15
+ hash_array = []
16
+ h.each do |val|
17
+ hash_array.push s2s[val]
18
+ end
19
+
20
+ hash_array
21
+ else
22
+ h
23
+ end
24
+ end
25
+
26
+ s2s[hash]
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: masteryconnect-automation-utils
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nick Redmond
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-08 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Provides util methods available to all RSpec test automation projects.
14
+ Util methods include additional Ruby functionality, along with RSpec helper methods.
15
+ May include data-driven automation helpers in the future.
16
+ email: nicholas.john.redmond@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/implicit-wait-manager.rb
22
+ - lib/masteryconnect-automation-utils.rb
23
+ - lib/recursive-hash-utils.rb
24
+ homepage: http://rubygems.org/gems/masteryconnect-automation-utils
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 2.2.2
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: Utils used in MasteryConnect QA automation. Formerly known as 'recursive-hash-utils'.
48
+ test_files: []
49
+ has_rdoc: