site-object 0.2.3 → 0.3.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 +4 -4
- data/lib/site-object/page.rb +12 -9
- data/lib/site-object/site.rb +0 -3
- data/lib/site-object/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 730db955f5d3cf13412e6fc2eef05b75197832ba
|
4
|
+
data.tar.gz: c1f90e003b9e2bdbd9e38aca3af9dcddb545e4d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65e33a7bfb7b8a0603e7f4db56bc81198c9ba5e9410baf7f28916fb7b1fe23f00f3a3322c1fd74174c76340a23bff66b2fb93353a97a12d91ce085f33b47cc9d
|
7
|
+
data.tar.gz: 844a52ce7d9c5eeb4df26d430a52bdaa292de5508f5fee0f5d0b3b8698b5d4b33931a0367bdd2231f7a83faec1c2802c238cd5ccdad90e40fe88ba73e8b2f820
|
data/lib/site-object/page.rb
CHANGED
@@ -286,7 +286,9 @@ module PageObject
|
|
286
286
|
|
287
287
|
# Try to expand the URL template if the URL has parameters.
|
288
288
|
@arguments = {}.with_indifferent_access # Stores the param list that will expand the url_template after examining the arguments used to initialize the page.
|
289
|
-
if @required_arguments.length >
|
289
|
+
if @required_arguments.length > 0 && !args
|
290
|
+
raise SiteObject::PageInitError, "No object was provided when attempting to initialize #{self.class.name}. This page object requires the following arguments for initialization: :#{@required_arguments.join(', :')}.\n\n#{caller.join("\n")}"
|
291
|
+
elsif @required_arguments.length > 0
|
290
292
|
@required_arguments.each do |arg| # Try to extract each URL argument from the hash or object provided, OR from the site object.
|
291
293
|
if args.is_a?(Hash) && !args.empty?
|
292
294
|
if args.with_indifferent_access[arg] #The hash has the required argument.
|
@@ -296,8 +298,6 @@ module PageObject
|
|
296
298
|
else
|
297
299
|
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")}"
|
298
300
|
end
|
299
|
-
# elsif args.is_a?(Hash) && args.empty?
|
300
|
-
# raise SiteObject::PageInitError, "An attempt to initialize the #{self.class.name} page object failed because no page arguments were provided. This page object requires the following arguments for initialization: :#{@required_arguments.join(", :")}\n\n#{caller.join("\n")}."
|
301
301
|
elsif args # Some non-hash object was provided.
|
302
302
|
if args.respond_to?(arg) #The hash has the required argument.
|
303
303
|
@arguments[arg]= args.send(arg)
|
@@ -310,10 +310,8 @@ module PageObject
|
|
310
310
|
# Do nothing here.
|
311
311
|
end
|
312
312
|
end
|
313
|
-
elsif @required_arguments.length
|
314
|
-
|
315
|
-
elsif @required_arguments.length == 0 && !args
|
316
|
-
unless @args.is_a?(Hash) && args.empty?
|
313
|
+
elsif @required_arguments.length == 0 && args # If there are no required arguments.
|
314
|
+
unless args.is_a?(Hash) && args.empty? # Do this unless args is an empty hash.
|
317
315
|
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")}"
|
318
316
|
end
|
319
317
|
else
|
@@ -378,7 +376,12 @@ module PageObject
|
|
378
376
|
# It's better to use the default URL matching if possible. But if for some reason it's not feasible
|
379
377
|
# you can use the alternate method to specify how to match the page.
|
380
378
|
def on_page?
|
381
|
-
|
379
|
+
if @url_template.pattern =~ /#/ # It has a URL fragment. Don't mess with the browser URL.
|
380
|
+
url = @browser.url
|
381
|
+
else # There's no fragment in the URL template, strip the fragment out of the URL so that template matching works better.
|
382
|
+
url = @browser.url.split('#')[0]
|
383
|
+
end
|
384
|
+
|
382
385
|
if @url_matcher && @url_matcher =~ url
|
383
386
|
return true
|
384
387
|
elsif @url_template.match(url)
|
@@ -395,7 +398,7 @@ module PageObject
|
|
395
398
|
end
|
396
399
|
|
397
400
|
# Refreshes the page.
|
398
|
-
def refresh # TODO: Isolate browser library-specific code so that the adding new browser
|
401
|
+
def refresh # TODO: Isolate browser library-specific code so that the adding a new browser library is cleaner.
|
399
402
|
if @browser.is_a?(Watir::Browser)
|
400
403
|
@browser.refresh
|
401
404
|
elsif @browser.is_a?(Selenium::WebDriver::Driver)
|
data/lib/site-object/site.rb
CHANGED
@@ -178,11 +178,8 @@ module SiteObject
|
|
178
178
|
# s = SomeSite.new(hash)
|
179
179
|
# s.open_browser :watir, :firefox
|
180
180
|
def open_browser(platform, browser_type, args={})
|
181
|
-
# puts "howdy"
|
182
|
-
# binding.pry
|
183
181
|
case platform
|
184
182
|
when :watir
|
185
|
-
# binding.pry
|
186
183
|
@browser = Watir::Browser.new(browser_type, args)
|
187
184
|
when :selenium
|
188
185
|
@browser = Selenium::WebDriver::Driver.for(browser_type, args)
|
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
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Fitisoff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -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.2.
|
83
|
+
rubygems_version: 2.2.3
|
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:
|