gamera 0.1.5 → 0.1.6
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -1
- data/lib/gamera.rb +4 -0
- data/lib/gamera/modules/visitable.rb +56 -0
- data/lib/gamera/page.rb +6 -62
- data/lib/gamera/utils/path_joiner.rb +13 -0
- metadata +6 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39ff7f416acffb3dcf8337af12277f8909dbedf0
|
4
|
+
data.tar.gz: bb476b347c1072a52b33b2150bc06c3f304162d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df265039a2e6ccb513b63ad756e93b248f79604ce1be9879f76908fb60d33dee08540c38c9b5a1261d68d9e10aca2a4cf58fbd55171c304aa4fcd6562ce7476c
|
7
|
+
data.tar.gz: f0ab1a3fc8caddf64621e14ced528a65e3b80763d9a3dde47a7f2ecb71088834b3b34246d0098b68c9341f36b19ec89785373ccbeb368235186676ba7198d4c5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
Զ�"�!��If蠆�"
|
2
|
+
O{st���-ʠ�4��\���HA�h!�Ƭ��ʔi4�}���f��#�eЖ����C���� �O�/��Qm��|^�w<3�pL.s����I1��Q�L��O��mJ�Lb��r�L�_�A^�{��jϐ�2(2�Q
|
data/lib/gamera.rb
CHANGED
@@ -3,6 +3,10 @@ require_relative 'gamera/builders/sequel_fixture_builder'
|
|
3
3
|
require_relative 'gamera/exceptions'
|
4
4
|
require_relative 'gamera/page'
|
5
5
|
|
6
|
+
require_relative 'gamera/modules/visitable'
|
7
|
+
|
8
|
+
require_relative 'gamera/utils/path_joiner'
|
9
|
+
|
6
10
|
require_relative 'gamera/page_sections/form'
|
7
11
|
require_relative 'gamera/page_sections/table'
|
8
12
|
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Gamera
|
2
|
+
module Visitable
|
3
|
+
# Methods to include on pages that are visitable, i.e. have a URL to visit and are then displayed.
|
4
|
+
|
5
|
+
include Capybara::DSL
|
6
|
+
|
7
|
+
# Open the page url in the browser specified in your Capybara configuration
|
8
|
+
#
|
9
|
+
# @param fail_on_redirect [Boolean] Whether to fail if the site redirects to a page that does not match the url_matcher regex
|
10
|
+
# @raise [WrongPageVisited] if the site redirects to URL that doesn't match the url_matcher regex and fail_on_redirect is true
|
11
|
+
def visit(fail_on_redirect = true)
|
12
|
+
super(url)
|
13
|
+
if fail_on_redirect
|
14
|
+
fail Gamera::WrongPageVisited, "Expected URL '#{url}', got '#{page.current_url}'" unless displayed?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Check to see if we eventually land on the right page
|
19
|
+
#
|
20
|
+
# @param wait_time_seconds [Integer] How long to wait for the correct page to load
|
21
|
+
# @return [Boolean] true if the url loaded in the browser matches the url_matcher pattern
|
22
|
+
# @raise [NoUrlMatcherForPage] if there's no url_matcher for this page
|
23
|
+
def displayed?(wait_time_seconds = Capybara.default_wait_time)
|
24
|
+
fail Gamera::NoUrlMatcherForPage if url_matcher.nil?
|
25
|
+
start_time = Time.now
|
26
|
+
loop do
|
27
|
+
return true if page.current_url.chomp('/') =~ url_matcher
|
28
|
+
break unless Time.now - start_time <= wait_time_seconds
|
29
|
+
sleep(0.05)
|
30
|
+
end
|
31
|
+
false
|
32
|
+
end
|
33
|
+
|
34
|
+
# A method to wait for slow loading data on a page. Useful, for example,
|
35
|
+
# when waiting on a page that shows the count of records loaded via a slow
|
36
|
+
# web or import.
|
37
|
+
#
|
38
|
+
# @param retries [Integer] Number of times to reload the page before giving up
|
39
|
+
# @param allowed_errors [Array] Array of errors that trigger a refresh, e.g., if an ExpectationNotMetError was raised during an acceptance test
|
40
|
+
# @param block [Block] The block to execute after each refresh
|
41
|
+
def with_refreshes(retries, allowed_errors = [RSpec::Expectations::ExpectationNotMetError], &block)
|
42
|
+
retries_left ||= retries
|
43
|
+
visit
|
44
|
+
block.call(retries_left)
|
45
|
+
rescue *allowed_errors => e
|
46
|
+
retries_left -= 1
|
47
|
+
retry if retries_left >= 0
|
48
|
+
raise e
|
49
|
+
end
|
50
|
+
|
51
|
+
# A reminder to implement a url method when using this module.
|
52
|
+
def url
|
53
|
+
fail NotImplementedError, 'To use the Visitable module, you must implement a url method'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/gamera/page.rb
CHANGED
@@ -27,6 +27,8 @@
|
|
27
27
|
|
28
28
|
require 'capybara'
|
29
29
|
require_relative 'exceptions'
|
30
|
+
require_relative 'modules/visitable'
|
31
|
+
require_relative 'utils/path_joiner'
|
30
32
|
|
31
33
|
module Gamera
|
32
34
|
# This is a base class which implements common methods for page object
|
@@ -131,75 +133,17 @@ module Gamera
|
|
131
133
|
# end
|
132
134
|
class Page
|
133
135
|
include Capybara::DSL
|
136
|
+
include Visitable
|
137
|
+
extend Forwardable
|
134
138
|
|
135
139
|
attr_reader :url, :url_matcher
|
136
140
|
|
141
|
+
def_delegator PathJoiner, :path_join, :path_join
|
142
|
+
|
137
143
|
def initialize(url, url_matcher = nil)
|
138
144
|
@url = url
|
139
145
|
@url_matcher = url_matcher || /#{url}/
|
140
146
|
end
|
141
147
|
|
142
|
-
# Open the page url in the browser specified in your Capybara configuration
|
143
|
-
#
|
144
|
-
# @param fail_on_redirect [Boolean] Whether to fail if the site redirects to a page that does not match the url_matcher regex
|
145
|
-
# @raise [WrongPageVisited] if the site redirects to URL that doesn't match the url_matcher regex and fail_on_redirect is true
|
146
|
-
def visit(fail_on_redirect = true)
|
147
|
-
super(url)
|
148
|
-
if fail_on_redirect
|
149
|
-
fail WrongPageVisited, "Expected URL '#{url}', got '#{page.current_url}'" unless displayed?
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
# Check to see if we eventually land on the right page
|
154
|
-
#
|
155
|
-
# @param wait_time_seconds [Integer] How long to wait for the correct page to load
|
156
|
-
# @return [Boolean] true if the url loaded in the browser matches the url_matcher pattern
|
157
|
-
# @raise [NoUrlMatcherForPage] if there's no url_matcher for this page
|
158
|
-
def displayed?(wait_time_seconds = Capybara.default_wait_time)
|
159
|
-
fail Gamera::NoUrlMatcherForPage if url_matcher.nil?
|
160
|
-
start_time = Time.now
|
161
|
-
loop do
|
162
|
-
return true if page.current_url.chomp('/') =~ url_matcher
|
163
|
-
break unless Time.now - start_time <= wait_time_seconds
|
164
|
-
sleep(0.05)
|
165
|
-
end
|
166
|
-
false
|
167
|
-
end
|
168
|
-
|
169
|
-
# A method to wait for slow loading data on a page. Useful, for example,
|
170
|
-
# when waiting on a page that shows the count of records loaded via a slow
|
171
|
-
# web or import.
|
172
|
-
#
|
173
|
-
# @param retries [Integer] Number of times to reload the page before giving up
|
174
|
-
# @param allowed_errors [Array] Array of errors that trigger a refresh, e.g., if an ExpectationNotMetError was raised during an acceptance test
|
175
|
-
# @param block [Block] The block to execute after each refresh
|
176
|
-
def with_refreshes(retries, allowed_errors = [RSpec::Expectations::ExpectationNotMetError], &block)
|
177
|
-
retries_left ||= retries
|
178
|
-
visit
|
179
|
-
block.call(retries_left)
|
180
|
-
rescue *allowed_errors => e
|
181
|
-
retries_left -= 1
|
182
|
-
retry if retries_left >= 0
|
183
|
-
raise e
|
184
|
-
end
|
185
|
-
|
186
|
-
# This is a flag for tracking which page object classes don't cover all of
|
187
|
-
# the elements and/or controls on the target web page.
|
188
|
-
#
|
189
|
-
# @return [Boolean] true unless everything's been captured in the page
|
190
|
-
# object class
|
191
|
-
def sparse?
|
192
|
-
false
|
193
|
-
end
|
194
|
-
|
195
|
-
# This is a utility method to clean up URLs formed by concatenation since we
|
196
|
-
# sometimes ended up with "//" in the middle of URLs which broke the
|
197
|
-
# url_matcher checks.
|
198
|
-
#
|
199
|
-
# @param elements [String] duck types
|
200
|
-
# @return [String] of elements joined by single "/" characters.
|
201
|
-
def path_join(*elements)
|
202
|
-
"/#{elements.join('/')}".gsub(%r(//+), '/')
|
203
|
-
end
|
204
148
|
end
|
205
149
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Gamera
|
2
|
+
class PathJoiner
|
3
|
+
# This is a utility method to clean up URLs formed by concatenation since we
|
4
|
+
# sometimes ended up with "//" in the middle of URLs which broke the
|
5
|
+
# url_matcher checks.
|
6
|
+
#
|
7
|
+
# @param elements [String] duck types
|
8
|
+
# @return [String] of elements joined by single "/" characters.
|
9
|
+
def self.path_join(*elements)
|
10
|
+
"/#{elements.join('/')}".gsub(%r(//+), '/')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gamera
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Dobbs
|
@@ -32,7 +32,7 @@ cert_chain:
|
|
32
32
|
464gGOxiLBQhgi5LrYOx/4oHzyd9o7ZEC/rFUw6RlYq/Zy91Y68MQG3R4q54FSDr
|
33
33
|
JCSrp1wI+0CJRVpPuS6W3r3h8/lBfq6wPTmg3MzlDTDYHTnh7poY3EqC6x7+xA==
|
34
34
|
-----END CERTIFICATE-----
|
35
|
-
date: 2015-11-
|
35
|
+
date: 2015-11-11 00:00:00.000000000 Z
|
36
36
|
dependencies:
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: sinatra
|
@@ -183,7 +183,7 @@ dependencies:
|
|
183
183
|
version: '2.0'
|
184
184
|
- - ">="
|
185
185
|
- !ruby/object:Gem::Version
|
186
|
-
version: 2.0.
|
186
|
+
version: 2.0.4
|
187
187
|
type: :runtime
|
188
188
|
prerelease: false
|
189
189
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -193,7 +193,7 @@ dependencies:
|
|
193
193
|
version: '2.0'
|
194
194
|
- - ">="
|
195
195
|
- !ruby/object:Gem::Version
|
196
|
-
version: 2.0.
|
196
|
+
version: 2.0.4
|
197
197
|
- !ruby/object:Gem::Dependency
|
198
198
|
name: byebug
|
199
199
|
requirement: !ruby/object:Gem::Requirement
|
@@ -288,10 +288,12 @@ files:
|
|
288
288
|
- lib/gamera/builders/sequel_fixture_builder.rb
|
289
289
|
- lib/gamera/exceptions.rb
|
290
290
|
- lib/gamera/general_proxy.rb
|
291
|
+
- lib/gamera/modules/visitable.rb
|
291
292
|
- lib/gamera/page.rb
|
292
293
|
- lib/gamera/page_sections/form.rb
|
293
294
|
- lib/gamera/page_sections/table.rb
|
294
295
|
- lib/gamera/utils/database_cleaner.rb
|
296
|
+
- lib/gamera/utils/path_joiner.rb
|
295
297
|
- lib/pry_setup.rb
|
296
298
|
homepage: http://gamera-team.github.io/gamera/
|
297
299
|
licenses:
|
metadata.gz.sig
CHANGED
Binary file
|