site_prism 2.11 → 2.12

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
  SHA1:
3
- metadata.gz: e194be3ee7349ee99bb8704a35acca0d4bf963d9
4
- data.tar.gz: 584fc98753ee4abfd4bbd1e220b537dfd2a10280
3
+ metadata.gz: 486bfe34bc7f4ab7dedc373ffdb850d146c731d8
4
+ data.tar.gz: 324a724708c627fbc2242bc783ac80a1626472e0
5
5
  SHA512:
6
- metadata.gz: 4a6eb96791b4c5be970baa67ed782a14744066284ca8053fd0832ddf78325dc95aaedf5c97a488ef1e041b999d28e91b048c5be226d89a2c6308de15ec561d66
7
- data.tar.gz: bad1b3076a2ca4a4b40430228d806dfc1e22a127f23451c46f2976c89fed03e8f9a804357dc6cb2244e4d158022edd3687b1efef180542317c631145f556f264
6
+ metadata.gz: 62687b2613246d5f2a9afc1623d961ec43249439dbb9f7d391758c723832a587524cd617e4893bdf53405ac42aed942656892eb4269d7a1092d08245573e2796
7
+ data.tar.gz: c8065b3bb3cd831bb3ee12e975c701e9b29d998a45d8e640bca5b15c895fe4bfb18012c6fa24dba3ed40af9a53100424ffbc23c9ea212755a7a73bf195fcd60a
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011-2016, Nathaniel Ritmeyer
1
+ Copyright (c) 2011-2018, Nathaniel Ritmeyer
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
data/README.md CHANGED
@@ -11,7 +11,7 @@ Make sure to add your project/company to https://github.com/natritmeyer/site_pri
11
11
 
12
12
  ## Supported Rubies / Browsers
13
13
 
14
- SitePrism is built and tested to work on Ruby 2.0 - 2.4. There is also some limited support for the Ruby 1.9 series.
14
+ SitePrism is built and tested to work on Ruby 2.1 - 2.4. There is also some limited support for the Ruby 1.9/2.0 series.
15
15
 
16
16
  SitePrism should run on all major browsers. The gem's integration tests are ran on the latest version of Firefox.
17
17
 
@@ -1517,7 +1517,7 @@ end
1517
1517
  To expose the iframe, reference it from another page or class using the `iframe`
1518
1518
  method. The `iframe` method takes 3 arguments; the name by which you
1519
1519
  would like to reference the iframe, the page class that represents the
1520
- iframe, and an ID or class by which you can locate the iframe. For example:
1520
+ iframe, and the CSS selector by which you can locate the iframe. For example:
1521
1521
 
1522
1522
  ```ruby
1523
1523
  class PageContainingIframe < SitePrism::Page
@@ -1525,8 +1525,21 @@ class PageContainingIframe < SitePrism::Page
1525
1525
  end
1526
1526
  ```
1527
1527
 
1528
- The third argument to the `iframe` method must
1529
- contain a selector that will locate the iframe node.
1528
+ ### Locating an iframe
1529
+
1530
+ While the above example uses a CSS selector to find the iframe, it is also
1531
+ possible to use an XPath expression or the index of the iframe in its parent
1532
+ (a shortcut for an `nth-of-type` CSS selector). For example:
1533
+
1534
+ ```ruby
1535
+ class PageContainingIframe < SitePrism::Page
1536
+ # XPath Expression:
1537
+ iframe :my_iframe, MyIframe, :xpath, '//iframe[@id="my_iframe_id"]'
1538
+
1539
+ # Index (nth-of-type) Selector:
1540
+ iframe :my_iframe, MyIframe, 0
1541
+ end
1542
+ ```
1530
1543
 
1531
1544
  ### Testing for an iframe's existence
1532
1545
 
@@ -85,7 +85,8 @@ module SitePrism
85
85
  component_url = uri.public_send(component).to_s
86
86
  extracted_mappings = component_template.extract(component_url)
87
87
  unless extracted_mappings
88
- # to support Addressable's expansion of queries, ensure it's parsing the fragment as appropriate (e.g. {?params*})
88
+ # to support Addressable's expansion of queries
89
+ # ensure it's parsing the fragment as appropriate (e.g. {?params*})
89
90
  prefix = COMPONENT_PREFIXES[component]
90
91
  return nil unless prefix && (extracted_mappings = component_template.extract(prefix + component_url))
91
92
  end
@@ -48,15 +48,15 @@ module SitePrism
48
48
  end
49
49
  end
50
50
 
51
- def iframe(iframe_name, iframe_page_class, selector)
52
- element_selector = deduce_iframe_element_selector(selector)
53
- scope_selector = deduce_iframe_scope_selector(selector)
51
+ def iframe(iframe_name, iframe_page_class, *args)
52
+ element_find_args = deduce_iframe_element_find_args(args)
53
+ scope_find_args = deduce_iframe_scope_find_args(args)
54
54
  add_to_mapped_items iframe_name
55
- create_existence_checker iframe_name, element_selector
56
- create_nonexistence_checker iframe_name, element_selector
57
- create_waiter iframe_name, element_selector
55
+ create_existence_checker iframe_name, *element_find_args
56
+ create_nonexistence_checker iframe_name, *element_find_args
57
+ create_waiter iframe_name, *element_find_args
58
58
  define_method iframe_name do |&block|
59
- within_frame scope_selector do
59
+ within_frame(*scope_find_args) do
60
60
  block.call iframe_page_class.new
61
61
  end
62
62
  end
@@ -69,7 +69,8 @@ module SitePrism
69
69
 
70
70
  def raise_if_block(obj, name, has_block)
71
71
  return unless has_block
72
- raise SitePrism::UnsupportedBlock, "#{obj.class}##{name} does not accept blocks, did you mean to define a (i)frame?"
72
+
73
+ raise SitePrism::UnsupportedBlock, "#{obj.class}##{name}"
73
74
  end
74
75
 
75
76
  private
@@ -168,12 +169,26 @@ module SitePrism
168
169
  end
169
170
  end
170
171
 
171
- def deduce_iframe_scope_selector(selector)
172
- selector.is_a?(Integer) ? selector : selector.split('#').last
172
+ def deduce_iframe_scope_find_args(args)
173
+ case args[0]
174
+ when Integer
175
+ [args[0]]
176
+ when String
177
+ [:css, args[0]]
178
+ else
179
+ args
180
+ end
173
181
  end
174
182
 
175
- def deduce_iframe_element_selector(selector)
176
- selector.is_a?(Integer) ? "iframe:nth-of-type(#{selector + 1})" : selector
183
+ def deduce_iframe_element_find_args(args)
184
+ case args[0]
185
+ when Integer
186
+ "iframe:nth-of-type(#{args[0] + 1})"
187
+ when String
188
+ [:css, args[0]]
189
+ else
190
+ args
191
+ end
177
192
  end
178
193
 
179
194
  def extract_section_options(args, &block)
@@ -184,7 +199,7 @@ module SitePrism
184
199
  else
185
200
  raise ArgumentError, 'You should provide section class either as a block, or as the second argument.'
186
201
  end
187
- return section_class, args
202
+ [section_class, args]
188
203
  end
189
204
  end
190
205
  end
@@ -14,6 +14,12 @@ module SitePrism
14
14
  class TimeoutException < StandardError; end
15
15
  class TimeOutWaitingForElementVisibility < StandardError; end
16
16
  class TimeOutWaitingForElementInvisibility < StandardError; end
17
- class UnsupportedBlock < StandardError; end
17
+
18
+ class UnsupportedBlock < StandardError
19
+ def message
20
+ "#{super} does not accept blocks, did you mean to define a (i)frame?"
21
+ end
22
+ end
23
+
18
24
  NotLoadedError = Class.new(StandardError)
19
25
  end
@@ -17,20 +17,21 @@ module SitePrism
17
17
  Capybara.within(@root_element) { yield(self) } if block_given?
18
18
  end
19
19
 
20
- def visible?
21
- root_element.visible?
20
+ # Capybara::DSL module "delegates" Capybara methods to the "page" method
21
+ def page
22
+ root_element || Capybara.current_session
22
23
  end
23
24
 
24
- def text
25
- root_element.text
25
+ def visible?
26
+ page.visible?
26
27
  end
27
28
 
28
29
  def execute_script(input)
29
- Capybara.current_session.execute_script input
30
+ Capybara.current_session.execute_script(input)
30
31
  end
31
32
 
32
33
  def evaluate_script(input)
33
- Capybara.current_session.evaluate_script input
34
+ Capybara.current_session.evaluate_script(input)
34
35
  end
35
36
 
36
37
  def parent_page
@@ -41,16 +42,16 @@ module SitePrism
41
42
  candidate_page
42
43
  end
43
44
 
45
+ def native
46
+ root_element.native
47
+ end
48
+
44
49
  private
45
50
 
46
51
  def find_first(*find_args)
47
52
  root_element.find(*find_args)
48
53
  end
49
54
 
50
- def find_all(*find_args)
51
- root_element.all(*find_args)
52
- end
53
-
54
55
  def element_exists?(*find_args)
55
56
  root_element.has_selector?(*find_args) unless root_element.nil?
56
57
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SitePrism
4
- VERSION = '2.11'.freeze
4
+ VERSION = '2.12'.freeze
5
5
  end
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: '2.11'
4
+ version: '2.12'
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-03-12 00:00:00.000000000 Z
12
+ date: 2018-04-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '2.7'
34
+ version: '2.12'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '2.7'
41
+ version: '2.12'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: cucumber
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -67,34 +67,20 @@ dependencies:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '11.0'
70
- - !ruby/object:Gem::Dependency
71
- name: redcarpet
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - "~>"
75
- - !ruby/object:Gem::Version
76
- version: '3.0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - "~>"
82
- - !ruby/object:Gem::Version
83
- version: '3.0'
84
70
  - !ruby/object:Gem::Dependency
85
71
  name: rspec
86
72
  requirement: !ruby/object:Gem::Requirement
87
73
  requirements:
88
74
  - - "~>"
89
75
  - !ruby/object:Gem::Version
90
- version: '3.2'
76
+ version: '3.3'
91
77
  type: :development
92
78
  prerelease: false
93
79
  version_requirements: !ruby/object:Gem::Requirement
94
80
  requirements:
95
81
  - - "~>"
96
82
  - !ruby/object:Gem::Version
97
- version: '3.2'
83
+ version: '3.3'
98
84
  - !ruby/object:Gem::Dependency
99
85
  name: rubocop
100
86
  requirement: !ruby/object:Gem::Requirement
@@ -113,30 +99,50 @@ dependencies:
113
99
  name: selenium-webdriver
114
100
  requirement: !ruby/object:Gem::Requirement
115
101
  requirements:
116
- - - "~>"
102
+ - - ">="
117
103
  - !ruby/object:Gem::Version
118
104
  version: 3.4.0
105
+ - - "<="
106
+ - !ruby/object:Gem::Version
107
+ version: 3.8.0
119
108
  type: :development
120
109
  prerelease: false
121
110
  version_requirements: !ruby/object:Gem::Requirement
122
111
  requirements:
123
- - - "~>"
112
+ - - ">="
124
113
  - !ruby/object:Gem::Version
125
114
  version: 3.4.0
115
+ - - "<="
116
+ - !ruby/object:Gem::Version
117
+ version: 3.8.0
126
118
  - !ruby/object:Gem::Dependency
127
119
  name: simplecov
128
120
  requirement: !ruby/object:Gem::Requirement
129
121
  requirements:
130
122
  - - ">="
131
123
  - !ruby/object:Gem::Version
132
- version: '0.11'
124
+ version: '0.12'
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0.12'
132
+ - !ruby/object:Gem::Dependency
133
+ name: dotenv
134
+ requirement: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '2.1'
133
139
  type: :development
134
140
  prerelease: false
135
141
  version_requirements: !ruby/object:Gem::Requirement
136
142
  requirements:
137
143
  - - ">="
138
144
  - !ruby/object:Gem::Version
139
- version: '0.11'
145
+ version: '2.1'
140
146
  description: |-
141
147
  SitePrism gives you a simple, clean and semantic DSL for describing your site.
142
148
  SitePrism implements the Page Object Model pattern on top of Capybara.