site_prism 3.6 → 3.7

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: 1ec5104247e3512bd7ebf0a48c579cc92041ef21b9c130531ef0cb4ff5a52f88
4
- data.tar.gz: a44ff822766bb37ff023048349037c0467ae47333d4b421bc53d8a59cb2af087
3
+ metadata.gz: adf8cf393fc3ad828528159a54048e54c3c396f3743c79b10a75ea313ddd135c
4
+ data.tar.gz: f2fb2ecb2f8942e3e59228994da32262a65b14a2c49f573468100f1aca799061
5
5
  SHA512:
6
- metadata.gz: 1a6991ecd0110bb53533fb848c40753a13067aed17913f2dd261a5d0b4c8c1747f9f54d1be83d954856037e6cbd24abd665d498b74ff0ad835ab1bea1e0a084a
7
- data.tar.gz: bcfe1f63bcaf2b20c64241c03b1c9c718628609fa0bdaa67c01a78b02964b809135aa815e6b0073d4272235226eda5ad802b8b6852d8b118d0806d96e09e2068
6
+ metadata.gz: aecf017750d915a617052242d8959af91ec1b154e5d394f2fa7df096649cf198052ecdf25cef22476f88682c45d71ff6c49c39262726d7d75ea33d07b751f47b
7
+ data.tar.gz: e2ed8f07246c08e910fd870ecc9140f813619109b107ae6448d59f98176b84b6f50c58cc8609615e68f5ddd0e09076b3b30f906fe0647994d78ec4df7b2d1941
data/README.md CHANGED
@@ -7,7 +7,7 @@ _A Page Object Model DSL for Capybara_
7
7
  SitePrism gives you a simple, clean and semantic DSL for describing your site using the Page Object Model pattern,
8
8
  for use with Capybara in automated acceptance testing.
9
9
 
10
- Find the pretty documentation here: http://rdoc.info/gems/site_prism/frames
10
+ Find the pretty documentation here: https://rdoc.info/gems/site_prism/frames
11
11
 
12
12
  Make sure to add your project/company to https://github.com/site-prism/site_prism/wiki/Who-is-using-SitePrism
13
13
 
@@ -23,7 +23,7 @@ SitePrism is built and tested to work on Ruby 2.4 - 2.6. Ruby 2.3 (Now EOL), is
23
23
  If you are using SitePrism with Ruby 2.3 it is highly advisable to upgrade to a more modern Ruby
24
24
  such as 2.6 or 2.7, if for any other reason, to get a noticeable speed boost!
25
25
 
26
- SitePrism should run on all major browsers. The gem's integration tests are ran on Chrome and Firefox.
26
+ SitePrism should run on all major browsers. The gem's integration tests are run on Chrome and Firefox.
27
27
 
28
28
  If you find you cannot integrate nicely with SitePrism, please open an
29
29
  [issue request](https://github.com/site-prism/site_prism/issues/new)
@@ -298,7 +298,13 @@ expect(@account_page).to be_displayed
298
298
  ```
299
299
 
300
300
  Calling `#displayed?` will return true if the browser's current URL
301
- matches the page's template and false if it doesn't.
301
+ matches the page's template and false if it doesn't. It will wait for
302
+ `Capybara.default_max_wait_time` seconds or you can pass an explicit
303
+ wait time in seconds as the first argument like this:
304
+
305
+ ```ruby
306
+ @account_page.displayed?(10) # wait up to 10 seconds for display
307
+ ```
302
308
 
303
309
  #### Specifying parameter values for templated URLs
304
310
 
@@ -425,8 +431,11 @@ as a string.
425
431
  #### Accessing the individual element
426
432
 
427
433
  The `element` method will add a number of methods to instances of the
428
- particular Page class. The first method to be added is the name of the
429
- element. So using the following example:
434
+ particular Page class. The first method added is the name of the
435
+ element. It finds the element using [Capybara::Node::Finders#find](https://www.rubydoc.info/github/teamcapybara/capybara/master/Capybara/Node/Finders#find-instance_method)
436
+ returning a [Capybara::Node::Element](https://www.rubydoc.info/github/teamcapybara/capybara/master/Capybara/Node/Element) or
437
+ raising [Capybara::ElementNotFound](https://www.rubydoc.info/github/teamcapybara/capybara/master/Capybara/ElementNotFound)
438
+ if the element can not be found.
430
439
 
431
440
  ```ruby
432
441
  class Home < SitePrism::Page
@@ -450,7 +459,9 @@ end
450
459
  #### Testing for the existence of the element
451
460
 
452
461
  Another method added to the Page class by the `element` method is the
453
- `has_<element_name>?` method. Using the same example as above:
462
+ `has_<element_name>?` method.
463
+ This method delegates to [Capybara::Node::Matchers#has_selector?](https://www.rubydoc.info/github/teamcapybara/capybara/master/Capybara/Node/Matchers#has_selector%3F-instance_method).
464
+ Using the same example as above:
454
465
 
455
466
  ```ruby
456
467
  class Home < SitePrism::Page
@@ -480,7 +491,9 @@ end
480
491
 
481
492
  To test that an element does not exist on the page, it is not possible to just call
482
493
  `#not_to have_search_field`. SitePrism supplies the `#has_no_<element>?` method
483
- that should be used to test for non-existence. Using the above example:
494
+ that should be used to test for non-existence.
495
+ This method delegates to [Capybara::Node::Matchers#has_no_selector?](https://www.rubydoc.info/github/teamcapybara/capybara/master/Capybara/Node/Matchers#has_no_selector%3F-instance_method)
496
+ Using the above example:
484
497
 
485
498
  ```ruby
486
499
  @home = Home.new
@@ -499,8 +512,9 @@ end
499
512
  #### Waiting for an element to become visible
500
513
 
501
514
  A method that gets added by calling `element` is the
502
- `wait_until_<element_name>_visible` method. Calling this method will
503
- cause the test to wait for Capybara's default wait time for the element
515
+ `wait_until_<element_name>_visible` method.
516
+ This method delegates to [Capybara::Node::Matchers#has_selector?](https://www.rubydoc.info/github/teamcapybara/capybara/master/Capybara/Node/Matchers#has_selector%3F-instance_method).
517
+ Calling this method will cause the test to wait for Capybara's default wait time for the element
504
518
  to become visible. You can customise the wait time by supplying a number
505
519
  of seconds to wait in-line or configuring the default wait time.
506
520
 
@@ -513,10 +527,11 @@ of seconds to wait in-line or configuring the default wait time.
513
527
  #### Waiting for an element to become invisible
514
528
 
515
529
  Another method added by calling `element` is the
516
- `wait_until_<element_name>_invisible` method. Calling this method will
517
- cause the test to wait for Capybara's default wait time for the element
518
- to become invisible. You can as with the visibility waiter, customise
519
- the wait time in the same way.
530
+ `wait_until_<element_name>_invisible` method.
531
+ This method delegates to [Capybara::Node::Matchers#has_no_selector?](https://www.rubydoc.info/github/teamcapybara/capybara/master/Capybara/Node/Matchers#has_no_selector%3F-instance_method).
532
+ Calling this method will cause the test to wait for Capybara's default
533
+ wait time for the element to become invisible. You can as with the visibility
534
+ waiter, customise the wait time in the same way.
520
535
 
521
536
  ```ruby
522
537
  @home.wait_until_search_field_invisible
@@ -3,6 +3,7 @@
3
3
  module SitePrism
4
4
  class RecursionChecker
5
5
  attr_reader :instance
6
+
6
7
  private :instance
7
8
 
8
9
  def initialize(instance)
@@ -2,7 +2,6 @@
2
2
 
3
3
  module SitePrism
4
4
  class Section
5
- include Capybara::DSL
6
5
  include ElementChecker
7
6
  include Loadable
8
7
  include DSL
@@ -10,17 +9,26 @@ module SitePrism
10
9
 
11
10
  attr_reader :root_element, :parent
12
11
 
13
- def self.set_default_search_arguments(*args)
14
- @default_search_arguments = args
15
- end
12
+ class << self
13
+ def set_default_search_arguments(*args)
14
+ @default_search_arguments = args
15
+ end
16
+
17
+ def default_search_arguments
18
+ return @default_search_arguments if @default_search_arguments
19
+
20
+ superclass.respond_to?(:default_search_arguments) && superclass.default_search_arguments
21
+ end
22
+
23
+ private
16
24
 
17
- def self.default_search_arguments
18
- @default_search_arguments ||
19
- (
20
- superclass.respond_to?(:default_search_arguments) &&
21
- superclass.default_search_arguments
22
- ) ||
23
- nil
25
+ def root_element_methods
26
+ ::Capybara::Session::NODE_METHODS + %i[native visible?]
27
+ end
28
+
29
+ def session_methods
30
+ ::Capybara::Session::DSL_METHODS - root_element_methods
31
+ end
24
32
  end
25
33
 
26
34
  def initialize(parent, root_element, &block)
@@ -29,29 +37,39 @@ module SitePrism
29
37
  within(&block) if block_given?
30
38
  end
31
39
 
32
- def within
33
- Capybara.within(@root_element) { yield(self) }
40
+ # Send all root_element methods through `#root_element`
41
+ # NB: This requires a method called `#to_capybara_node` being created and
42
+ # then set to this value (Capybara agnostic API)
43
+ root_element_methods.each do |method|
44
+ def_delegators :root_element, method
34
45
  end
35
46
 
36
- # Capybara::DSL module "delegates" Capybara methods to the "page" method
37
- # as such we need to overload this method so that the correct scoping
38
- # occurs and calls within a section (For example section.find(element))
39
- # correctly scope to look within the section only
40
- def page
41
- return root_element if root_element
47
+ # Send all methods that previously acted on the `#page` method that existed previously
48
+ # through to the same location - But directly as `Capybara.current_session`
49
+ session_methods.each do |method|
50
+ def_delegators :capybara_session, method
51
+ end
42
52
 
43
- SitePrism.logger.warn('Root Element not found; Falling back to `super`')
44
- super
53
+ # This scopes our calls inside Section correctly to the `Capybara::Node::Element`
54
+ def to_capybara_node
55
+ root_element
45
56
  end
46
57
 
47
- def visible?
48
- page.visible?
58
+ # This allows us to return anything thats passed in as a block to the section at
59
+ # creation time, so that an anonymous section or such-like will have the extra methods
60
+ def within
61
+ Capybara.within(root_element) { yield(self) }
49
62
  end
50
63
 
51
- def_delegators :capybara_session,
52
- :execute_script,
53
- :evaluate_script,
54
- :within_frame
64
+ # This was the old API-style of delegating through the Capybara.page call and over-loading
65
+ # the method so we always went through our correct `root_element`
66
+ def page
67
+ SitePrism::Deprecator.deprecate('Using page inside section')
68
+ return root_element if root_element
69
+
70
+ SitePrism.logger.warn('Root Element not found; Falling back to Capybara.current_session')
71
+ capybara_session
72
+ end
55
73
 
56
74
  def capybara_session
57
75
  Capybara.current_session
@@ -62,9 +80,5 @@ module SitePrism
62
80
  candidate = candidate.parent until candidate.is_a?(SitePrism::Page)
63
81
  candidate
64
82
  end
65
-
66
- def native
67
- root_element.native
68
- end
69
83
  end
70
84
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SitePrism
4
- VERSION = '3.6'
4
+ VERSION = '3.7'
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: '3.6'
4
+ version: '3.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Hill
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-08-17 00:00:00.000000000 Z
12
+ date: 2020-10-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
@@ -29,22 +29,16 @@ dependencies:
29
29
  name: capybara
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
34
  version: '3.8'
35
- - - "<="
36
- - !ruby/object:Gem::Version
37
- version: '3.29'
38
35
  type: :runtime
39
36
  prerelease: false
40
37
  version_requirements: !ruby/object:Gem::Requirement
41
38
  requirements:
42
- - - ">="
39
+ - - "~>"
43
40
  - !ruby/object:Gem::Version
44
41
  version: '3.8'
45
- - - "<="
46
- - !ruby/object:Gem::Version
47
- version: '3.29'
48
42
  - !ruby/object:Gem::Dependency
49
43
  name: site_prism-all_there
50
44
  requirement: !ruby/object:Gem::Requirement
@@ -127,14 +121,14 @@ dependencies:
127
121
  requirements:
128
122
  - - "~>"
129
123
  - !ruby/object:Gem::Version
130
- version: 0.81.0
124
+ version: 0.83.0
131
125
  type: :development
132
126
  prerelease: false
133
127
  version_requirements: !ruby/object:Gem::Requirement
134
128
  requirements:
135
129
  - - "~>"
136
130
  - !ruby/object:Gem::Version
137
- version: 0.81.0
131
+ version: 0.83.0
138
132
  - !ruby/object:Gem::Dependency
139
133
  name: rubocop-performance
140
134
  requirement: !ruby/object:Gem::Requirement
@@ -169,7 +163,7 @@ dependencies:
169
163
  requirements:
170
164
  - - ">="
171
165
  - !ruby/object:Gem::Version
172
- version: '3.9'
166
+ version: '3.11'
173
167
  - - "<"
174
168
  - !ruby/object:Gem::Version
175
169
  version: '4.1'
@@ -179,7 +173,7 @@ dependencies:
179
173
  requirements:
180
174
  - - ">="
181
175
  - !ruby/object:Gem::Version
182
- version: '3.9'
176
+ version: '3.11'
183
177
  - - "<"
184
178
  - !ruby/object:Gem::Version
185
179
  version: '4.1'