site-object 0.4.2 → 0.4.3
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
- data/lib/site-object/page.rb +11 -7
- data/lib/site-object/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 424ea70dcf85238cbe36bed27c8801eb9bc235ce
|
4
|
+
data.tar.gz: 7ac183c3a3656d194229f24987b96560da309e59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75f1d9c95cac8e1c6f7f5d505b101d66a1401cbe5d0c1c2af888ff9acdc8d13094960fcd18b2e67a1a0abf458b4bc80bfc204b807670b533e4d390a27e1d2dbc
|
7
|
+
data.tar.gz: 29bf796128a07e3506667aa870dce0a0167e36890bf8164da59d530b61b94777238d7a6e5a8c256788d02880546e9325aba66cf7ec60c8704b3aab1e9ddde26c
|
data/lib/site-object/page.rb
CHANGED
@@ -169,6 +169,10 @@ module PageObject
|
|
169
169
|
@arguments ||= @url_template.keys.map { |k| k.to_sym }
|
170
170
|
end
|
171
171
|
|
172
|
+
def query_argument
|
173
|
+
required_arguments.find { |x| @url_template.pattern =~ /{\?#{x}\*}/}
|
174
|
+
end
|
175
|
+
|
172
176
|
# Used to define the full or relative URL to the page. Typically, you will *almost* *always* want to use
|
173
177
|
# this method when defining a page object (but see notes below.) The URL can be defined in a number
|
174
178
|
# of different ways. Here are some examples using Google News:
|
@@ -305,7 +309,7 @@ module PageObject
|
|
305
309
|
end
|
306
310
|
|
307
311
|
module PageInstanceMethods
|
308
|
-
attr_reader :arguments, :browser, :page_attributes, :page_elements, :page_features, :page_url, :required_arguments, :site, :url_template, :url_matcher
|
312
|
+
attr_reader :arguments, :browser, :page_attributes, :page_elements, :page_features, :page_url, :query_argument, :required_arguments, :site, :url_template, :url_matcher
|
309
313
|
|
310
314
|
# Takes the name of a page class. If the current page is of that class then it returns a page
|
311
315
|
# object for the page. Raises a SiteObject::WrongPageError if that's not the case.
|
@@ -328,6 +332,7 @@ module PageObject
|
|
328
332
|
@site = site
|
329
333
|
@url_matcher = self.class.url_matcher
|
330
334
|
@url_template = self.class.url_template
|
335
|
+
@query_argument = self.class.query_argument
|
331
336
|
|
332
337
|
# Try to expand the URL template if the URL has parameters.
|
333
338
|
@arguments = {}.with_indifferent_access # Stores the param list that will expand the url_template after examining the arguments used to initialize the page.
|
@@ -349,7 +354,7 @@ module PageObject
|
|
349
354
|
elsif @site.respond_to?(arg)
|
350
355
|
@arguments[arg]= site.send(arg)
|
351
356
|
else
|
352
|
-
raise SiteObject::PageInitError, "#{args.class} was provided, but this object did not respond to :#{arg}, which is necessary to build an URL for the #{self.class.name} page.\n\n#{caller.join("\n")}"
|
357
|
+
raise SiteObject::PageInitError, "A required page argument is missing. #{args.class} was provided, but this object did not respond to :#{arg}, which is necessary to build an URL for the #{self.class.name} page.\n\n#{caller.join("\n")}"
|
353
358
|
end
|
354
359
|
elsif args # Some non-hash object was provided.
|
355
360
|
if args.respond_to?(arg) #The hash has the required argument.
|
@@ -357,16 +362,16 @@ module PageObject
|
|
357
362
|
elsif @site.respond_to?(arg)
|
358
363
|
@arguments[arg]= site.send(arg)
|
359
364
|
else
|
360
|
-
raise SiteObject::PageInitError, "#{args.class} was provided, but this object did not respond to :#{arg}, which is necessary to build an URL for the #{self.class.name} page.\n\n#{caller.join("\n")}"
|
365
|
+
raise SiteObject::PageInitError, "A required page argument is missing. #{args.class} was provided, but this object did not respond to :#{arg}, which is necessary to build an URL for the #{self.class.name} page.\n\n#{caller.join("\n")}"
|
361
366
|
end
|
362
367
|
else
|
363
|
-
|
368
|
+
# Do nothing here yet.
|
364
369
|
end
|
365
370
|
end
|
366
371
|
elsif @required_arguments.empty? && args # If there are no required arguments then nothing should be provided.
|
367
372
|
raise SiteObject::PageInitError, "#{args.class} was provided as a #{self.class.name} initialization argument, but the page URL doesn't require any arguments.\n\n#{caller.join("\n")}"
|
368
373
|
else
|
369
|
-
# Do nothing here.
|
374
|
+
# Do nothing here yet.
|
370
375
|
end
|
371
376
|
|
372
377
|
@url = @url_template.expand(@arguments).to_s
|
@@ -449,11 +454,10 @@ module PageObject
|
|
449
454
|
else
|
450
455
|
if page_args = @url_template.extract(Addressable::URI.parse(url))
|
451
456
|
page_args = page_args.with_indifferent_access
|
452
|
-
|
457
|
+
(@required_arguments - [query_argument]).all? { |k| page_args[k] == @arguments[k].to_s }
|
453
458
|
end
|
454
459
|
end
|
455
460
|
end
|
456
|
-
false
|
457
461
|
end
|
458
462
|
|
459
463
|
def navigation_disabled?
|
data/lib/site-object/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: site-object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Fitisoff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -30,20 +30,20 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '2.
|
33
|
+
version: '2.4'
|
34
34
|
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 2.
|
36
|
+
version: 2.4.0
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '2.
|
43
|
+
version: '2.4'
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 2.
|
46
|
+
version: 2.4.0
|
47
47
|
description: Wraps page objects up into a site object, which provides some introspection
|
48
48
|
and navigation capabilities that page objects don't provide. Works with Watir and
|
49
49
|
Selenium.
|
@@ -80,10 +80,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
82
|
rubyforge_project: site-object
|
83
|
-
rubygems_version: 2.
|
83
|
+
rubygems_version: 2.2.5
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: Wraps page objects up into a site object, which provides some introspection
|
87
87
|
and navigation capabilities that page objects don't provide. Works with Watir and
|
88
88
|
Selenium.
|
89
89
|
test_files: []
|
90
|
+
has_rdoc:
|