watir_pump 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/watir_pump/page.rb +32 -26
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b43d865d216cb89a0021ec97a0e0d9dc47732b5
|
4
|
+
data.tar.gz: d225472e316f49be403ce6a1c7c1adbd87a8535c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3825e375c66c430c3ae772ac5935f393c6c1a905f904f1f9e28b183e7fdb53ce8cfea0c4c4f5c702b9c19de49a8735fbced6f662f64dc412006f152dd778603e
|
7
|
+
data.tar.gz: 837952750b60feb3bffca0c5eb0d75147328cceb70b3482f29f1c2fd0b9dfda80d83aeee954235a879c9bbc8cd83664d72de352c5acf92cdc0e9bdf4f7ef8534
|
data/lib/watir_pump/page.rb
CHANGED
@@ -1,38 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'forwardable'
|
3
4
|
require 'addressable/template'
|
4
5
|
require_relative 'component'
|
5
6
|
|
6
7
|
module WatirPump
|
7
8
|
class Page < Component
|
8
9
|
class << self
|
10
|
+
extend Forwardable
|
11
|
+
|
12
|
+
INSTANCE_DELEGATED_METHODS = %i[
|
13
|
+
browser
|
14
|
+
open open_yield open_dsl
|
15
|
+
use use_yield use_dsl
|
16
|
+
act act_yield use_dsl
|
17
|
+
].freeze
|
18
|
+
delegate INSTANCE_DELEGATED_METHODS => :instance
|
19
|
+
|
9
20
|
def uri(uri = nil)
|
10
21
|
@uri = uri unless uri.nil?
|
11
22
|
@uri
|
12
23
|
end
|
13
24
|
|
14
|
-
def open(params = {}, &blk)
|
15
|
-
instance.open(params, &blk)
|
16
|
-
end
|
17
|
-
|
18
|
-
def open_yield(params = {}, &blk)
|
19
|
-
instance.open_yield(params, &blk)
|
20
|
-
end
|
21
|
-
|
22
|
-
def browser
|
23
|
-
instance.browser
|
24
|
-
end
|
25
|
-
|
26
|
-
def use(&blk)
|
27
|
-
instance.use(&blk)
|
28
|
-
end
|
29
|
-
alias act use
|
30
|
-
|
31
|
-
def use_yield(&blk)
|
32
|
-
instance.use_yield(&blk)
|
33
|
-
end
|
34
|
-
alias act_yield use_yield
|
35
|
-
|
36
25
|
def loaded?
|
37
26
|
Addressable::Template.new(instance.url_template).match browser.url
|
38
27
|
end
|
@@ -42,6 +31,14 @@ module WatirPump
|
|
42
31
|
end
|
43
32
|
end # << self
|
44
33
|
|
34
|
+
def open(params = {}, &blk)
|
35
|
+
if WatirPump.config.call_page_blocks_with_yield
|
36
|
+
open_yield(params, &blk)
|
37
|
+
else
|
38
|
+
open_dsl(params, &blk)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
45
42
|
def open_yield(params = {}, &blk)
|
46
43
|
url = Addressable::Template.new(url_template).expand(params).to_s
|
47
44
|
browser.goto url
|
@@ -49,13 +46,22 @@ module WatirPump
|
|
49
46
|
self
|
50
47
|
end
|
51
48
|
|
52
|
-
def
|
49
|
+
def open_dsl(params = {}, &blk)
|
53
50
|
url = Addressable::Template.new(url_template).expand(params).to_s
|
54
51
|
browser.goto url
|
55
|
-
|
52
|
+
use_dsl(&blk) if block_given?
|
56
53
|
self
|
57
54
|
end
|
58
55
|
|
56
|
+
def use(&blk)
|
57
|
+
if WatirPump.config.call_page_blocks_with_yield
|
58
|
+
use_yield(&blk)
|
59
|
+
else
|
60
|
+
use_dsl(&blk)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
alias act use
|
64
|
+
|
59
65
|
def use_yield
|
60
66
|
wait_for_loaded
|
61
67
|
yield self, browser
|
@@ -63,12 +69,12 @@ module WatirPump
|
|
63
69
|
end
|
64
70
|
alias act_yield use_yield
|
65
71
|
|
66
|
-
def
|
72
|
+
def use_dsl(&blk)
|
67
73
|
wait_for_loaded
|
68
74
|
instance_exec(&blk)
|
69
75
|
self
|
70
76
|
end
|
71
|
-
alias
|
77
|
+
alias act_dsl use_dsl
|
72
78
|
|
73
79
|
def url_template
|
74
80
|
WatirPump.config.base_url + self.class.uri
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir_pump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bartek Wilczek
|
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
140
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.6.
|
141
|
+
rubygems_version: 2.6.13
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: Page Objects for Watir
|