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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9eaed0d98cdcffc5d23f9c8cadf03b5cb343a5f8e65b7f9d96334442112c115
4
- data.tar.gz: 5286b415093777314940312fff696f080b980eefdb4f9d9f4134559da56155ea
3
+ metadata.gz: 484d33816dfd3b61f4ebd4c4e0b96418877c84730b3d5edacc214895c17ac565
4
+ data.tar.gz: 3c18ff1ba0590d025eea607b46bb44d733f67669d53fd5cc535491cc85e5eae1
5
5
  SHA512:
6
- metadata.gz: 889e8c4aad04e3ba37d2742cdaeae1234a1665297c2fd295495fedf91eeefc7b0e21a118a63c4b86a7d2492a07685b92cf39792b6bc781a3e5e82b03720090ae
7
- data.tar.gz: 828b1e6e1693c506dc082babb9bc51049a28d32aa04ea37483f8a2d89cde8e63a6392b0f4b85b52d33d22b084234d6b3ecb81e3941e6b4e7a4fe688c5469285c
6
+ metadata.gz: 55df767a6fe3d3a2234c94d69c496396bcab8fd095177e780d2c16bc30ad8f08d5339e0e02a9f65be3d46c58b8d16718c56c52b9482db515ef5084dcef17dbd4
7
+ data.tar.gz: 1bc2a80d5bb5926d4db0c209a14a6c368266329eb26e5ab8ddb17de7fbfbcb265f80b01edbdb9ded18e8d8a14f2ced7731f5cb1404c4fade0bda3aee9d2959d9
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011-2018, Nathaniel Ritmeyer & the Site Prism team
1
+ Copyright (c) 2011-2019, Nathaniel Ritmeyer & the SitePrism team
2
2
 
3
3
  All rights reserved.
4
4
 
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 /google.com\/?/
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 /google.com\/results\?.*/
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.wait_for_menu # menu loads after a second or 2, give it time to arrive
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.wait_for_search_results
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 %r{/accounts/\d+}
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.wait_for_images #=> waits for capybara's default wait time until the element appears in the page section
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? { |element| there?(element) }
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 self.class.expected_items
17
- mapped_items.select { |el| self.class.expected_items.include?(el) }
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
- return unless self.class.mapped_items
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 there?(element)
30
- send("has_#{element}?")
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 :mapped_items, :expected_items
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
- add_to_mapped_items(name)
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 add_to_mapped_items(item)
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
- add_to_mapped_items(name)
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.debug("#{name} has come from an item with 0 locators.")
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
@@ -21,7 +21,7 @@ module SitePrism
21
21
  end
22
22
 
23
23
  def url_matcher
24
- @url_matcher || url
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 || Capybara.current_session
34
+ @page ||= Capybara.current_session
35
35
  end
36
36
 
37
37
  # Loads the page.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SitePrism
4
- VERSION = '3.0'.freeze
4
+ VERSION = '3.0.1'.freeze
5
5
  end
@@ -8,6 +8,7 @@ module SitePrism
8
8
  loop do
9
9
  return true if yield
10
10
  break if Time.now - start_time > wait_time
11
+
11
12
  sleep(0.05)
12
13
  end
13
14
 
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: '3.0'
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: 2018-10-12 00:00:00.000000000 Z
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.17'
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.17'
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.0'
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.0'
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.0'
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.0'
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.6'
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.6'
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: '0.58'
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: '0.58'
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.6'
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.6'
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.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