site_prism 3.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.md +1 -1
- data/README.md +6 -6
- data/lib/site_prism/element_checker.rb +13 -6
- data/lib/site_prism/element_container.rb +14 -11
- data/lib/site_prism/page.rb +2 -2
- data/lib/site_prism/version.rb +1 -1
- data/lib/site_prism/waiter.rb +1 -0
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 484d33816dfd3b61f4ebd4c4e0b96418877c84730b3d5edacc214895c17ac565
|
4
|
+
data.tar.gz: 3c18ff1ba0590d025eea607b46bb44d733f67669d53fd5cc535491cc85e5eae1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55df767a6fe3d3a2234c94d69c496396bcab8fd095177e780d2c16bc30ad8f08d5339e0e02a9f65be3d46c58b8d16718c56c52b9482db515ef5084dcef17dbd4
|
7
|
+
data.tar.gz: 1bc2a80d5bb5926d4db0c209a14a6c368266329eb26e5ab8ddb17de7fbfbcb265f80b01edbdb9ded18e8d8a14f2ced7731f5cb1404c4fade0bda3aee9d2959d9
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -32,7 +32,7 @@ Here's an overview of how SitePrism is designed to be used:
|
|
32
32
|
|
33
33
|
class Home < SitePrism::Page
|
34
34
|
set_url '/index.htm'
|
35
|
-
set_url_matcher
|
35
|
+
set_url_matcher(/google.com\/?/)
|
36
36
|
|
37
37
|
element :search_field, 'input[name="q"]'
|
38
38
|
element :search_button, 'button[name="btnK"]'
|
@@ -41,7 +41,7 @@ class Home < SitePrism::Page
|
|
41
41
|
end
|
42
42
|
|
43
43
|
class SearchResults < SitePrism::Page
|
44
|
-
set_url_matcher
|
44
|
+
set_url_matcher(/google.com\/results\?.*/)
|
45
45
|
|
46
46
|
section :menu, MenuSection, '#gbx3'
|
47
47
|
sections :search_results, SearchResultSection, '#results li'
|
@@ -72,7 +72,7 @@ When(/^I navigate to the google home page$/) do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
Then(/^the home page should contain the menu and the search form$/) do
|
75
|
-
@home.
|
75
|
+
@home.wait_until_menu_visible # menu loads after a second or 2, give it time to arrive
|
76
76
|
expect(@home).to have_menu
|
77
77
|
expect(@home).to have_search_field
|
78
78
|
expect(@home).to have_search_button
|
@@ -89,7 +89,7 @@ Then(/^the search results page is displayed$/) do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
Then(/^the search results page contains 10 individual search results$/) do
|
92
|
-
@results_page.
|
92
|
+
@results_page.wait_until_search_results_visible
|
93
93
|
expect(@results_page).to have_search_results(count: 10)
|
94
94
|
end
|
95
95
|
|
@@ -318,7 +318,7 @@ URL matchers by it by calling `set_url_matcher`:
|
|
318
318
|
|
319
319
|
```ruby
|
320
320
|
class Account < SitePrism::Page
|
321
|
-
set_url_matcher
|
321
|
+
set_url_matcher(/accounts/\d+/)
|
322
322
|
end
|
323
323
|
```
|
324
324
|
|
@@ -858,7 +858,7 @@ end
|
|
858
858
|
@home.menu.search.click #=> clicks the search link in the home page menu
|
859
859
|
@home.menu.search['href'] #=> returns the value for the href attribute of the capybara element representing the search link
|
860
860
|
@home.menu.has_images? #=> returns true or false based on whether the link is present in the section on the page
|
861
|
-
@home.menu.
|
861
|
+
@home.menu.wait_until_images_visible #=> waits for capybara's default wait time until the element is visible in the page section
|
862
862
|
|
863
863
|
```
|
864
864
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module SitePrism
|
4
4
|
module ElementChecker
|
5
5
|
def all_there?
|
6
|
-
elements_to_check.all? { |
|
6
|
+
elements_to_check.all? { |item_name| there?(item_name) }
|
7
7
|
end
|
8
8
|
|
9
9
|
def elements_present
|
@@ -13,21 +13,28 @@ module SitePrism
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def elements_to_check
|
16
|
-
if
|
17
|
-
|
16
|
+
if expected_items
|
17
|
+
SitePrism.logger.debug('Expected Items has been set.')
|
18
|
+
mapped_items.select { |item_name| expected_items.include?(item_name) }
|
18
19
|
else
|
19
20
|
mapped_items
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
24
|
def mapped_items
|
24
|
-
|
25
|
+
mapped_items_list.map(&:values).flatten
|
26
|
+
end
|
25
27
|
|
28
|
+
def mapped_items_list
|
26
29
|
self.class.mapped_items.uniq
|
27
30
|
end
|
28
31
|
|
29
|
-
def
|
30
|
-
|
32
|
+
def expected_items
|
33
|
+
self.class.expected_items
|
34
|
+
end
|
35
|
+
|
36
|
+
def there?(item_name)
|
37
|
+
send("has_#{item_name}?")
|
31
38
|
end
|
32
39
|
end
|
33
40
|
end
|
@@ -58,10 +58,10 @@ module SitePrism
|
|
58
58
|
|
59
59
|
# rubocop:disable Metrics/ModuleLength
|
60
60
|
module ClassMethods
|
61
|
-
attr_reader :
|
61
|
+
attr_reader :expected_items
|
62
62
|
|
63
63
|
def element(name, *find_args)
|
64
|
-
build(name, *find_args) do
|
64
|
+
build(:element, name, *find_args) do
|
65
65
|
define_method(name) do |*runtime_args, &element_block|
|
66
66
|
raise_if_block(self, name, !element_block.nil?, :element)
|
67
67
|
_find(*merge_args(find_args, runtime_args))
|
@@ -70,7 +70,7 @@ module SitePrism
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def elements(name, *find_args)
|
73
|
-
build(name, *find_args) do
|
73
|
+
build(:elements, name, *find_args) do
|
74
74
|
define_method(name) do |*runtime_args, &element_block|
|
75
75
|
raise_if_block(self, name, !element_block.nil?, :elements)
|
76
76
|
_all(*merge_args(find_args, runtime_args))
|
@@ -84,7 +84,7 @@ module SitePrism
|
|
84
84
|
|
85
85
|
def section(name, *args, &block)
|
86
86
|
section_class, find_args = extract_section_options(args, &block)
|
87
|
-
build(name, *find_args) do
|
87
|
+
build(:section, name, *find_args) do
|
88
88
|
define_method(name) do |*runtime_args, &runtime_block|
|
89
89
|
section_element = _find(*merge_args(find_args, runtime_args))
|
90
90
|
section_class.new(self, section_element, &runtime_block)
|
@@ -94,7 +94,7 @@ module SitePrism
|
|
94
94
|
|
95
95
|
def sections(name, *args, &block)
|
96
96
|
section_class, find_args = extract_section_options(args, &block)
|
97
|
-
build(name, *find_args) do
|
97
|
+
build(:sections, name, *find_args) do
|
98
98
|
define_method(name) do |*runtime_args, &element_block|
|
99
99
|
raise_if_block(self, name, !element_block.nil?, :sections)
|
100
100
|
_all(*merge_args(find_args, runtime_args)).map do |element|
|
@@ -107,7 +107,7 @@ module SitePrism
|
|
107
107
|
def iframe(name, klass, *args)
|
108
108
|
element_find_args = deduce_iframe_element_find_args(args)
|
109
109
|
scope_find_args = deduce_iframe_scope_find_args(args)
|
110
|
-
|
110
|
+
map_item!(:iframe, name)
|
111
111
|
add_iframe_helper_methods(name, *element_find_args)
|
112
112
|
define_method(name) do |&block|
|
113
113
|
raise MissingBlockError unless block
|
@@ -118,23 +118,26 @@ module SitePrism
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
-
def
|
121
|
+
def mapped_items
|
122
122
|
@mapped_items ||= []
|
123
|
-
@mapped_items << item
|
124
123
|
end
|
125
124
|
|
126
125
|
private
|
127
126
|
|
128
|
-
def build(name, *find_args)
|
127
|
+
def build(type, name, *find_args)
|
129
128
|
if find_args.empty?
|
130
129
|
create_error_method(name)
|
131
130
|
else
|
132
|
-
|
131
|
+
map_item!(type, name)
|
133
132
|
yield
|
134
133
|
end
|
135
134
|
add_helper_methods(name, *find_args)
|
136
135
|
end
|
137
136
|
|
137
|
+
def map_item!(type, name)
|
138
|
+
mapped_items << { type => name }
|
139
|
+
end
|
140
|
+
|
138
141
|
def add_helper_methods(name, *find_args)
|
139
142
|
create_existence_checker(name, *find_args)
|
140
143
|
create_nonexistence_checker(name, *find_args)
|
@@ -200,7 +203,7 @@ module SitePrism
|
|
200
203
|
end
|
201
204
|
|
202
205
|
def create_error_method(name)
|
203
|
-
SitePrism.logger.
|
206
|
+
SitePrism.logger.error("#{name} has come from an item with 0 locators.")
|
204
207
|
|
205
208
|
define_method(name) do
|
206
209
|
raise SitePrism::InvalidElementError
|
data/lib/site_prism/page.rb
CHANGED
@@ -21,7 +21,7 @@ module SitePrism
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def url_matcher
|
24
|
-
@url_matcher
|
24
|
+
@url_matcher ||= url
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -31,7 +31,7 @@ module SitePrism
|
|
31
31
|
# in order, with the default "displayed?" validation being ran _FIRST_
|
32
32
|
|
33
33
|
def page
|
34
|
-
@page
|
34
|
+
@page ||= Capybara.current_session
|
35
35
|
end
|
36
36
|
|
37
37
|
# Loads the page.
|
data/lib/site_prism/version.rb
CHANGED
data/lib/site_prism/waiter.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: site_prism
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nat Ritmeyer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-01-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '2.
|
34
|
+
version: '2.18'
|
35
35
|
- - "<"
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: '4.0'
|
@@ -41,7 +41,7 @@ dependencies:
|
|
41
41
|
requirements:
|
42
42
|
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: '2.
|
44
|
+
version: '2.18'
|
45
45
|
- - "<"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '4.0'
|
@@ -51,14 +51,14 @@ dependencies:
|
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.1'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
61
|
+
version: '3.1'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: dotenv
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,56 +79,56 @@ dependencies:
|
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '12.
|
82
|
+
version: '12.3'
|
83
83
|
type: :development
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '12.
|
89
|
+
version: '12.3'
|
90
90
|
- !ruby/object:Gem::Dependency
|
91
91
|
name: rspec
|
92
92
|
requirement: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '3.
|
96
|
+
version: '3.8'
|
97
97
|
type: :development
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '3.
|
103
|
+
version: '3.8'
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
105
|
name: rubocop
|
106
106
|
requirement: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 0.60.0
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
113
|
version_requirements: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 0.60.0
|
118
118
|
- !ruby/object:Gem::Dependency
|
119
119
|
name: selenium-webdriver
|
120
120
|
requirement: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '3.
|
124
|
+
version: '3.7'
|
125
125
|
type: :development
|
126
126
|
prerelease: false
|
127
127
|
version_requirements: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '3.
|
131
|
+
version: '3.7'
|
132
132
|
- !ruby/object:Gem::Dependency
|
133
133
|
name: simplecov
|
134
134
|
requirement: !ruby/object:Gem::Requirement
|
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
189
|
version: '0'
|
190
190
|
requirements: []
|
191
191
|
rubyforge_project:
|
192
|
-
rubygems_version: 2.7.
|
192
|
+
rubygems_version: 2.7.8
|
193
193
|
signing_key:
|
194
194
|
specification_version: 4
|
195
195
|
summary: A Page Object Model DSL for Capybara
|