site_prism 4.0.beta → 4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +75 -97
- data/lib/site_prism/deprecator.rb +1 -1
- data/lib/site_prism/dsl.rb +24 -33
- data/lib/site_prism/element_checker.rb +3 -11
- data/lib/site_prism/loadable.rb +4 -5
- data/lib/site_prism/page.rb +31 -2
- data/lib/site_prism/rspec_matchers.rb +6 -3
- data/lib/site_prism/section.rb +0 -7
- data/lib/site_prism/timer.rb +10 -10
- data/lib/site_prism/version.rb +1 -1
- data/lib/site_prism/waiter.rb +2 -2
- data/lib/site_prism.rb +1 -1
- metadata +35 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a42324a6a59bf20f2c35c519c130d94e314c5170b47ddf1c9f1d3faae98238d7
|
4
|
+
data.tar.gz: d17845d3b0131de25848bf85b86a7c696ef1160bdc4cf759bd43958d56742d00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e09efb630b6f8270c7c8bb23c9db92bcccaa09e54c0a7e9ef1a6f2a645f47d821bf912141588ccec1bb3c6aea73f181ff6c8e5b771116f84936d10f95e714ab
|
7
|
+
data.tar.gz: d1dee7191ea9c01a8cc03e0726ae55ec1de91fe1d9bbb0f6db73e0c6b8af261d598b59d4d1be54e0589e481613b40e574f0d406ac1242d6a2e4cd46a9480c08c
|
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: https://
|
10
|
+
Find the pretty documentation here: https://www.rubydoc.info/github/site-prism/site_prism
|
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
|
|
@@ -81,34 +81,34 @@ end
|
|
81
81
|
|
82
82
|
# now for some tests
|
83
83
|
|
84
|
-
When(
|
84
|
+
When('I navigate to the google home page') do
|
85
85
|
@home = Home.new
|
86
86
|
@home.load
|
87
87
|
end
|
88
88
|
|
89
|
-
Then(
|
90
|
-
@home.wait_until_menu_visible
|
89
|
+
Then('the home page should contain the menu and the search form') do
|
90
|
+
@home.wait_until_menu_visible(wait: 5)
|
91
91
|
expect(@home).to have_menu
|
92
92
|
expect(@home).to have_search_field
|
93
93
|
expect(@home).to have_search_button
|
94
94
|
end
|
95
95
|
|
96
|
-
When(
|
97
|
-
@home.search_field.
|
96
|
+
When('I search for Sausages') do
|
97
|
+
@home.search_field.send_keys('Sausages')
|
98
98
|
@home.search_button.click
|
99
99
|
end
|
100
100
|
|
101
|
-
Then(
|
101
|
+
Then('the search results page is displayed') do
|
102
102
|
@results_page = SearchResults.new
|
103
103
|
expect(@results_page).to be_displayed
|
104
104
|
end
|
105
105
|
|
106
|
-
Then(
|
107
|
-
@results_page.wait_until_search_results_visible
|
106
|
+
Then('the search results page contains 10 individual search results') do
|
107
|
+
@results_page.wait_until_search_results_visible(wait: 5)
|
108
108
|
expect(@results_page).to have_search_results(count: 10)
|
109
109
|
end
|
110
110
|
|
111
|
-
Then(
|
111
|
+
Then('the search results contain a link to the wikipedia sausages page') do
|
112
112
|
expect(@results_page.search_result_links).to include('http://en.wikipedia.org/wiki/Sausage')
|
113
113
|
end
|
114
114
|
```
|
@@ -134,7 +134,6 @@ require 'capybara'
|
|
134
134
|
require 'capybara/cucumber'
|
135
135
|
require 'selenium-webdriver'
|
136
136
|
require 'site_prism'
|
137
|
-
require 'site_prism/all_there' # Optional but needed to perform more complex matching
|
138
137
|
```
|
139
138
|
|
140
139
|
The driver creation is identical to how you would normally create a Capybara driver,
|
@@ -143,7 +142,7 @@ a sample Selenium one could look something like this...
|
|
143
142
|
```ruby
|
144
143
|
Capybara.register_driver :site_prism do |app|
|
145
144
|
browser = ENV.fetch('browser', 'firefox').to_sym
|
146
|
-
Capybara::Selenium::Driver.new(app, browser: browser,
|
145
|
+
Capybara::Selenium::Driver.new(app, browser: browser, options: options)
|
147
146
|
end
|
148
147
|
|
149
148
|
# Then tell Capybara to use the Driver you've just defined as its default driver
|
@@ -161,7 +160,6 @@ require 'capybara'
|
|
161
160
|
require 'capybara/rspec'
|
162
161
|
require 'selenium-webdriver'
|
163
162
|
require 'site_prism'
|
164
|
-
require 'site_prism/all_there' # Optional but needed to perform more complex matching
|
165
163
|
```
|
166
164
|
|
167
165
|
And again, as above, a sample driver is no different to a normal driver instantiation in Capybara.
|
@@ -175,7 +173,7 @@ to then use instances of those classes in your tests.
|
|
175
173
|
|
176
174
|
If a class represents a page then each element of the page is
|
177
175
|
represented by a method that, when called, returns a reference to that
|
178
|
-
element that can then be acted upon (clicked,
|
176
|
+
element that can then be acted upon (clicked, type in some text), or
|
179
177
|
queried (is it enabled? / visible?).
|
180
178
|
|
181
179
|
SitePrism is based around this concept, but goes further as you'll see
|
@@ -218,7 +216,7 @@ class Home < SitePrism::Page
|
|
218
216
|
end
|
219
217
|
```
|
220
218
|
|
221
|
-
Note that setting a URL is optional - you only need to set a url if you want to be able to
|
219
|
+
Note that setting a URL is **optional** - you only need to set a url if you want to be able to
|
222
220
|
navigate directly to that page. It makes sense to set the URL for a page model of a
|
223
221
|
home page or a login page, but probably not a search results page.
|
224
222
|
|
@@ -245,8 +243,7 @@ See https://github.com/sporkmonger/addressable for more details on parameterized
|
|
245
243
|
|
246
244
|
### Navigating to the Page
|
247
245
|
|
248
|
-
Once the URL has been set (using `set_url`), you can navigate directly
|
249
|
-
to the page using `#load`:
|
246
|
+
Once the URL has been set (using `set_url`), you can navigate directly to the page using `#load`:
|
250
247
|
|
251
248
|
```ruby
|
252
249
|
@home_page = Home.new
|
@@ -282,8 +279,6 @@ end
|
|
282
279
|
This will tell whichever capybara driver you have configured to
|
283
280
|
navigate to the URL set against that page's class.
|
284
281
|
|
285
|
-
See https://github.com/sporkmonger/addressable for more details on parameterized URLs.
|
286
|
-
|
287
282
|
### Verifying that a particular page is displayed
|
288
283
|
|
289
284
|
Automated tests often need to verify that a particular page is
|
@@ -319,8 +314,7 @@ wait time in seconds as the first argument like this:
|
|
319
314
|
#### Specifying parameter values for templated URLs
|
320
315
|
|
321
316
|
Sometimes you want to verify not just that the current URL matches the
|
322
|
-
template, but that you're looking at a specific page matching that
|
323
|
-
template.
|
317
|
+
template, but that you're looking at a specific page matching that template.
|
324
318
|
|
325
319
|
Given the previous example, if you wanted to ensure that the browser had loaded
|
326
320
|
account number 22, you could assert the following:
|
@@ -347,7 +341,7 @@ when comparing your page's URL template to the current_url:
|
|
347
341
|
@account_page.load(id: 22, query: { token: 'ca2786616a4285bc', color: 'irrelevant' })
|
348
342
|
|
349
343
|
expect(@account_page).to be_displayed(id: 22)
|
350
|
-
expect(@account_page.url_matches
|
344
|
+
expect(@account_page.url_matches.dig('query', 'token')).to eq('ca2786616a4285bc')
|
351
345
|
```
|
352
346
|
|
353
347
|
#### Falling back to basic regexp matchers
|
@@ -367,7 +361,7 @@ end
|
|
367
361
|
SitePrism's `#displayed?` predicate method allows for semantic code in your tests:
|
368
362
|
|
369
363
|
```ruby
|
370
|
-
Then(
|
364
|
+
Then('the account page is displayed') do
|
371
365
|
expect(@account_page).to be_displayed
|
372
366
|
expect(@some_other_page).not_to be_displayed
|
373
367
|
end
|
@@ -375,8 +369,7 @@ end
|
|
375
369
|
|
376
370
|
### Getting the Current Page's URL
|
377
371
|
|
378
|
-
SitePrism allows you to get the current page's URL. Here's how it's
|
379
|
-
done:
|
372
|
+
SitePrism allows you to get the current page's URL. Here's how it's done:
|
380
373
|
|
381
374
|
```ruby
|
382
375
|
class Account < SitePrism::Page
|
@@ -462,8 +455,8 @@ end
|
|
462
455
|
@home.load
|
463
456
|
|
464
457
|
@home.search_field #=> will return the capybara element found using the selector
|
465
|
-
@home.search_field.
|
466
|
-
@home.search_field
|
458
|
+
@home.search_field.send_keys('the search string')
|
459
|
+
@home.search_field['value'] #=> standard method on a capybara element (field); returns the string value
|
467
460
|
```
|
468
461
|
|
469
462
|
#### Testing for the existence of the element
|
@@ -492,16 +485,16 @@ end
|
|
492
485
|
...which makes for nice test code:
|
493
486
|
|
494
487
|
```ruby
|
495
|
-
Then(
|
488
|
+
Then('the search field exists') do
|
496
489
|
expect(@home).to have_search_field
|
497
490
|
end
|
498
491
|
```
|
499
492
|
|
500
493
|
#### Testing that an element does not exist
|
501
494
|
|
502
|
-
To test that an element does not exist on the page,
|
495
|
+
To test that an element does not exist on the page, you should not call
|
503
496
|
`#not_to have_search_field`. SitePrism supplies the `#has_no_<element>?` method
|
504
|
-
that should be used to test for non-existence.
|
497
|
+
that should be used instead to test for non-existence.
|
505
498
|
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)
|
506
499
|
Using the above example:
|
507
500
|
|
@@ -514,7 +507,7 @@ Using the above example:
|
|
514
507
|
...which makes for nice test code:
|
515
508
|
|
516
509
|
```ruby
|
517
|
-
Then(
|
510
|
+
Then('the search field exists')do
|
518
511
|
expect(@home).to have_no_search_field #NB: NOT => expect(@home).not_to have_search_field
|
519
512
|
end
|
520
513
|
```
|
@@ -529,7 +522,7 @@ to become visible. You can customise the wait time by supplying a number
|
|
529
522
|
of seconds to wait in-line or configuring the default wait time.
|
530
523
|
|
531
524
|
```ruby
|
532
|
-
@home.wait_until_search_field_visible
|
525
|
+
@home.wait_until_search_field_visible # using the default wait time set
|
533
526
|
# or...
|
534
527
|
@home.wait_until_search_field_visible(wait: 10)
|
535
528
|
```
|
@@ -544,7 +537,7 @@ wait time for the element to become invisible. You can as with the visibility
|
|
544
537
|
waiter, customise the wait time in the same way.
|
545
538
|
|
546
539
|
```ruby
|
547
|
-
@home.wait_until_search_field_invisible
|
540
|
+
@home.wait_until_search_field_invisible # using the default wait time set
|
548
541
|
# or...
|
549
542
|
@home.wait_until_search_field_invisible(wait: 10)
|
550
543
|
```
|
@@ -663,7 +656,7 @@ Then the following method is available:
|
|
663
656
|
This in turn allows the following nice test code
|
664
657
|
|
665
658
|
```ruby
|
666
|
-
Then(
|
659
|
+
Then('there should be some names listed on the page') do
|
667
660
|
expect(@friends_page).to have_names #=> This only passes if there is at least one `name`
|
668
661
|
end
|
669
662
|
```
|
@@ -704,16 +697,16 @@ are present in the browser and `false` if they're not all there.
|
|
704
697
|
|
705
698
|
# and...
|
706
699
|
|
707
|
-
Then(
|
700
|
+
Then('the friends page contains all the expected elements') do
|
708
701
|
expect(@friends_page).to be_all_there
|
709
702
|
end
|
710
703
|
```
|
711
704
|
|
712
705
|
You may wish to have elements declared in a page object class that are not
|
713
706
|
always guaranteed to be present (success or error messages, etc.).
|
714
|
-
If you'd still like to test such a page with
|
715
|
-
|
716
|
-
included in
|
707
|
+
If you'd still like to test such a page with `#all_there?` you can declare
|
708
|
+
`.expected_elements` on your page class that narrows the elements
|
709
|
+
included in `#all_there?` check to those that definitely should be present.
|
717
710
|
|
718
711
|
```ruby
|
719
712
|
class TestPage < SitePrism::Page
|
@@ -748,9 +741,9 @@ for this at the moment are `:none` and `:one`
|
|
748
741
|
Passing `:none` (default), will not change the functionality. However passing in `:one` will cause
|
749
742
|
`site_prism` to recurse through all `section` / `sections` items defined in your present scope.
|
750
743
|
|
751
|
-
Work
|
744
|
+
Work to develop this is contained in the
|
752
745
|
[site_prism-all_there](http://www.github.com/site-prism/site_prism-all_there) repo. So head on over
|
753
|
-
there if you're interested in
|
746
|
+
there if you're interested in this area more
|
754
747
|
|
755
748
|
### Getting the list of missing elements
|
756
749
|
|
@@ -830,15 +823,14 @@ class People < SitePrism::Section
|
|
830
823
|
end
|
831
824
|
|
832
825
|
class Home < SitePrism::Page
|
833
|
-
# section people_with_block will have `headline` and
|
834
|
-
# `footer` elements in it
|
826
|
+
# section people_with_block will have `headline` and `footer` elements in it
|
835
827
|
section :people_with_block, People do
|
836
828
|
element :headline, 'h2'
|
837
829
|
end
|
838
830
|
end
|
839
831
|
```
|
840
832
|
|
841
|
-
The 3rd argument (
|
833
|
+
The 3rd argument (Locator), can be omitted if you are re-using the same
|
842
834
|
locator for all references to the section Class. In order to do this,
|
843
835
|
simply tell SitePrism that you want to use default search arguments.
|
844
836
|
|
@@ -874,7 +866,7 @@ end
|
|
874
866
|
# the page and section in action
|
875
867
|
|
876
868
|
@home = Home.new
|
877
|
-
@home.menu #=> <
|
869
|
+
@home.menu #=> <Menu...>
|
878
870
|
```
|
879
871
|
|
880
872
|
When the `menu` method is called against `@home`, an instance of `Menu`
|
@@ -949,7 +941,7 @@ end
|
|
949
941
|
This then leads to some pretty test code ...
|
950
942
|
|
951
943
|
```ruby
|
952
|
-
Then(
|
944
|
+
Then('the home page menu contains a link to the various search functions') do
|
953
945
|
expect(@home.menu).to have_search
|
954
946
|
expect(@home.menu.search['href']).to include('google.com')
|
955
947
|
expect(@home.menu).to have_images
|
@@ -964,7 +956,7 @@ similar to Capybara's `within` method and allows for shorter test code
|
|
964
956
|
particularly with nested sections. Test code that might have to repeat the block name can be shortened up this way.
|
965
957
|
|
966
958
|
```ruby
|
967
|
-
Then(
|
959
|
+
Then('the home page menu contains a link to the various search functions') do
|
968
960
|
@home.menu.within do |menu|
|
969
961
|
expect(menu).to have_search
|
970
962
|
expect(menu.search['href']).to include('google.com')
|
@@ -974,10 +966,12 @@ Then(/^the home page menu contains a link to the various search functions$/) do
|
|
974
966
|
end
|
975
967
|
```
|
976
968
|
|
977
|
-
Note that on an individual section it's possible to pass a block directly to the section without using `within`.
|
969
|
+
Note that on an individual section it's possible to pass a block directly to the section without using `within`.
|
970
|
+
Because the block is executed only during `Section` initialization this won't work when accessing a single
|
971
|
+
Section from an array of Sections. For that reason we recommend using `within` which works in either case.
|
978
972
|
|
979
973
|
```ruby
|
980
|
-
Then(
|
974
|
+
Then('the home page menu contains a link to the various search functions') do
|
981
975
|
@home.menu do |menu| # possible, but prefer: `@home.menu.within`
|
982
976
|
expect(menu).to have_search
|
983
977
|
end
|
@@ -1129,26 +1123,22 @@ class Home < SitePrism::Page
|
|
1129
1123
|
section :login_and_registration, LoginRegistrationForm, 'div.login-registration'
|
1130
1124
|
end
|
1131
1125
|
|
1132
|
-
#
|
1126
|
+
# Then you could log in like so ...
|
1133
1127
|
|
1134
|
-
Then(
|
1128
|
+
Then('I sign in') do
|
1135
1129
|
@home = Home.new
|
1136
1130
|
@home.load
|
1137
|
-
|
1138
|
-
|
1139
|
-
@home.login_and_registration.login.username.set 'bob'
|
1140
|
-
@home.login_and_registration.login.password.set 'p4ssw0rd'
|
1131
|
+
@home.login_and_registration.login.username.send_keys('bob')
|
1132
|
+
@home.login_and_registration.login.password.send_keys('p4ssw0rd')
|
1141
1133
|
@home.login_and_registration.login.sign_in.click
|
1142
1134
|
end
|
1143
1135
|
|
1144
|
-
#
|
1136
|
+
# And you could sign up like so ...
|
1145
1137
|
|
1146
|
-
When(
|
1138
|
+
When('I sign up') do
|
1147
1139
|
@home = Home.new
|
1148
1140
|
@home.load
|
1149
|
-
|
1150
|
-
expect(@home.login_and_registration).to have_last_name
|
1151
|
-
@home.login_and_registration.first_name.set 'Bob'
|
1141
|
+
@home.login_and_registration.first_name.send_keys('Bob')
|
1152
1142
|
# ...
|
1153
1143
|
end
|
1154
1144
|
```
|
@@ -1188,7 +1178,7 @@ can be called in a page or a section.
|
|
1188
1178
|
|
1189
1179
|
The only difference between `section` and `sections` is that whereas the
|
1190
1180
|
first returns an instance of the supplied section class, the second
|
1191
|
-
returns
|
1181
|
+
returns a `Capybara::Result` containing as many instances of the section class as
|
1192
1182
|
there are capybara elements found by the supplied css selector. This is
|
1193
1183
|
better explained in the following example ...
|
1194
1184
|
|
@@ -1220,7 +1210,7 @@ end
|
|
1220
1210
|
This allows for pretty tests ...
|
1221
1211
|
|
1222
1212
|
```ruby
|
1223
|
-
Then(
|
1213
|
+
Then('there are lots of search_results') do
|
1224
1214
|
expect(@results_page.search_results.size).to eq(10)
|
1225
1215
|
|
1226
1216
|
@home.search_results.each do |result|
|
@@ -1235,12 +1225,14 @@ The css selector that is passed as the 3rd argument to the
|
|
1235
1225
|
elements. Each capybara element found using the css selector is used to
|
1236
1226
|
create a new instance of `SearchResults` and becomes its root
|
1237
1227
|
element. So if the css selector finds 3 `li` elements, calling
|
1238
|
-
`search_results` will return
|
1228
|
+
`search_results` will return a `Capybara::Result` containing 3 instances of
|
1239
1229
|
`SearchResults`, each with one of the `li` elements as it's root element.
|
1240
1230
|
|
1241
1231
|
##### Accessing Within a Collection of Sections
|
1242
1232
|
|
1243
|
-
When using an iterator such as `each` to pass a block through to a collection of sections it is
|
1233
|
+
When using an iterator such as `each` to pass a block through to a collection of sections it is
|
1234
|
+
possible to skip using `within`. However some caution is warranted when accessing the
|
1235
|
+
Sections directly from an array, as the block can only be executed when the section is being initialized. The following does not work:
|
1244
1236
|
|
1245
1237
|
```rb
|
1246
1238
|
@home.search_results.first do |result|
|
@@ -1304,7 +1296,7 @@ Here's how to test for the existence of the section:
|
|
1304
1296
|
This allows for some pretty tests ...
|
1305
1297
|
|
1306
1298
|
```ruby
|
1307
|
-
Then(
|
1299
|
+
Then('there are search results on the page') do
|
1308
1300
|
expect(@home).to have_search_results
|
1309
1301
|
end
|
1310
1302
|
```
|
@@ -1443,8 +1435,8 @@ The error message is ignored unless the boolean value is evaluated as falsey.
|
|
1443
1435
|
|
1444
1436
|
```ruby
|
1445
1437
|
class SomePage < SitePrism::Page
|
1446
|
-
element :
|
1447
|
-
load_validation { [
|
1438
|
+
element :foo, '.foo'
|
1439
|
+
load_validation { [has_foo?, 'did not have foo element!'] }
|
1448
1440
|
end
|
1449
1441
|
```
|
1450
1442
|
|
@@ -1490,8 +1482,8 @@ class FooPage < BasePage
|
|
1490
1482
|
section :form, '#form'
|
1491
1483
|
element :some_other_element, '.myelement'
|
1492
1484
|
|
1493
|
-
load_validation { [has_form
|
1494
|
-
load_validation { [has_some_other_element
|
1485
|
+
load_validation { [has_form?(wait: 5), 'form did not appear'] }
|
1486
|
+
load_validation { [has_some_other_element?(wait: 5), 'some other element did not appear'] }
|
1495
1487
|
end
|
1496
1488
|
```
|
1497
1489
|
|
@@ -1502,12 +1494,6 @@ the validations will be performed in the following order:
|
|
1502
1494
|
2. The `FooPage` validation will wait for the `form` element to be present.
|
1503
1495
|
3. The `FooPage` validation will wait for the `some_other_element` element to be present.
|
1504
1496
|
|
1505
|
-
**NB:** `SitePrism::Page` **used to** include a default load validation on
|
1506
|
-
`page.displayed?` however for v3 this has been removed. It is therefore
|
1507
|
-
necessary to re-define this if you want to retain the behaviour
|
1508
|
-
from site_prism v2. See [UPGRADING.md](https://github.com/site-prism/site_prism/blob/main/UPGRADING.md#default-load-validations)
|
1509
|
-
for more info on this.
|
1510
|
-
|
1511
1497
|
## Using Capybara Query Options
|
1512
1498
|
|
1513
1499
|
When querying an element, section or a collection of elements or sections,
|
@@ -1535,7 +1521,7 @@ fail if the page has not finished loading the section(s):
|
|
1535
1521
|
```ruby
|
1536
1522
|
@home = Home.new
|
1537
1523
|
# ...
|
1538
|
-
expect(@home.search_results.size).to
|
1524
|
+
expect(@home.search_results.size).to eq(25) # This may fail!
|
1539
1525
|
```
|
1540
1526
|
|
1541
1527
|
The above query can be rewritten to utilize the Capybara `:count` option
|
@@ -1546,16 +1532,16 @@ the page within the timeout:
|
|
1546
1532
|
|
1547
1533
|
```ruby
|
1548
1534
|
@home = Home.new
|
1549
|
-
@home.has_search_results?(count: 25)
|
1535
|
+
@home.has_search_results?(count: 25) # will wait default wait time
|
1550
1536
|
# OR
|
1551
|
-
@home.search_results(count: 25)
|
1537
|
+
@home.search_results(count: 25, wait: 5) # will wait 5 seconds
|
1552
1538
|
```
|
1553
1539
|
|
1554
1540
|
Now we can write pretty, non-failing tests without hard coding these options
|
1555
1541
|
into our page and section classes:
|
1556
1542
|
|
1557
1543
|
```ruby
|
1558
|
-
Then(
|
1544
|
+
Then('there are search results on the page') do
|
1559
1545
|
expect(@results_page).to have_search_results(count: 25)
|
1560
1546
|
end
|
1561
1547
|
```
|
@@ -1586,7 +1572,7 @@ The following element methods allow Capybara options to be passed as arguments t
|
|
1586
1572
|
## Test views with Page objects
|
1587
1573
|
|
1588
1574
|
It's possible to use the same page objects of integration tests for view tests, too,
|
1589
|
-
just pass the rendered HTML to the
|
1575
|
+
just pass the rendered HTML to the `load` method:
|
1590
1576
|
|
1591
1577
|
```ruby
|
1592
1578
|
require 'spec_helper'
|
@@ -1688,14 +1674,14 @@ class Home < SitePrism::Page
|
|
1688
1674
|
end
|
1689
1675
|
|
1690
1676
|
# cucumber step that performs login
|
1691
|
-
When(
|
1677
|
+
When('I log in') do
|
1692
1678
|
@home = Home.new
|
1693
1679
|
@home.load
|
1694
1680
|
|
1695
1681
|
@home.login_frame do |frame|
|
1696
1682
|
#`frame` is an instance of the `LoginFrame` class
|
1697
|
-
frame.username.
|
1698
|
-
frame.password.
|
1683
|
+
frame.username.send_keys('admin')
|
1684
|
+
frame.password.send_keys('p4ssword')
|
1699
1685
|
end
|
1700
1686
|
end
|
1701
1687
|
```
|
@@ -1738,14 +1724,6 @@ Capybara.using_wait_time(20) do
|
|
1738
1724
|
end
|
1739
1725
|
```
|
1740
1726
|
|
1741
|
-
## Using SitePrism with VCR
|
1742
|
-
|
1743
|
-
There's a SitePrism plugin called `site_prism.vcr` that lets you use
|
1744
|
-
SitePrism with the VCR gem. Check it out [HERE](https://github.com/dnesteryuk/site_prism.vcr)
|
1745
|
-
|
1746
|
-
Note that as of 2016 this plugin doesn't appear to have been under active development. Also it is
|
1747
|
-
still pinned to the `2.x` series of site_prism so use it of your own accord.
|
1748
|
-
|
1749
1727
|
# Epilogue
|
1750
1728
|
|
1751
1729
|
So, we've seen how to use SitePrism to put together page objects made up
|
@@ -1756,7 +1734,7 @@ all over the place. Here's an example of this common problem:
|
|
1756
1734
|
```ruby
|
1757
1735
|
@home = Home.new # <-- noise
|
1758
1736
|
@home.load
|
1759
|
-
@home.search_field.
|
1737
|
+
@home.search_field.send_keys('Sausages')
|
1760
1738
|
@home.search_field.search_button.click
|
1761
1739
|
@results_page = SearchResults.new # <-- noise
|
1762
1740
|
expect(@results_page).to have_search_result_items
|
@@ -1766,7 +1744,7 @@ The annoyance (and, later, maintenance nightmare) is having to create
|
|
1766
1744
|
`@home` and `@results_page`. It would be better to not have to create
|
1767
1745
|
instances of pages all over your tests.
|
1768
1746
|
|
1769
|
-
|
1747
|
+
One way you can deal with this problem is to create a class containing
|
1770
1748
|
methods that return instances of the pages. Eg:
|
1771
1749
|
|
1772
1750
|
```ruby
|
@@ -1803,17 +1781,17 @@ end
|
|
1803
1781
|
# and here's how to use it
|
1804
1782
|
|
1805
1783
|
#first line of the test...
|
1806
|
-
Given(
|
1784
|
+
Given('I start on the home page') do
|
1807
1785
|
@app = App.new
|
1808
1786
|
@app.home.load
|
1809
1787
|
end
|
1810
1788
|
|
1811
|
-
When(
|
1789
|
+
When('I search for Sausages') do
|
1812
1790
|
@app.home.search_field.set 'Sausages'
|
1813
1791
|
@app.home.search_button.click
|
1814
1792
|
end
|
1815
1793
|
|
1816
|
-
Then(
|
1794
|
+
Then('I am on the results page') do
|
1817
1795
|
expect(@app.results_page).to be_displayed
|
1818
1796
|
end
|
1819
1797
|
|
@@ -1823,8 +1801,8 @@ end
|
|
1823
1801
|
The only thing that needs instantiating is the `App` class - from then on
|
1824
1802
|
pages don't need to be initialized, they are now returned by methods on `@app`.
|
1825
1803
|
|
1826
|
-
It is possible to further optimise this, by using Cucumber/RSpec hooks,
|
1827
|
-
other things. However the investigation and optimisation of this (and other
|
1804
|
+
It is possible to further optimise this, by using Cucumber/RSpec hooks, memoization as well
|
1805
|
+
as many other things. However the investigation and optimisation of this (and other
|
1828
1806
|
aspects of SitePrism), is left as an exercise to the Reader.
|
1829
1807
|
|
1830
1808
|
Happy testing from all of the SitePrism team!
|
@@ -15,7 +15,7 @@ module SitePrism
|
|
15
15
|
warn("#{old} is being deprecated and should no longer be used.")
|
16
16
|
end
|
17
17
|
|
18
|
-
warn("#{old} will be removed in SitePrism
|
18
|
+
warn("#{old} will be removed in SitePrism v5. You have been warned!")
|
19
19
|
end
|
20
20
|
|
21
21
|
# @return SitePrism.logger.debug(msg)
|
data/lib/site_prism/dsl.rb
CHANGED
@@ -16,7 +16,7 @@ module SitePrism
|
|
16
16
|
|
17
17
|
private
|
18
18
|
|
19
|
-
def
|
19
|
+
def raise_if_runtime_block_supplied(object, name, has_block, type)
|
20
20
|
return unless has_block
|
21
21
|
|
22
22
|
SitePrism.logger.debug("Type passed in: #{type}")
|
@@ -24,25 +24,21 @@ module SitePrism
|
|
24
24
|
raise SitePrism::UnsupportedBlockError
|
25
25
|
end
|
26
26
|
|
27
|
-
# Call `find` inside `to_capybara_node` context (Either Capybara::Session or Capybara::Node::Element)
|
28
27
|
def _find(*find_args)
|
29
28
|
kwargs = find_args.pop
|
30
29
|
to_capybara_node.find(*find_args, **kwargs)
|
31
30
|
end
|
32
31
|
|
33
|
-
# Call `all` inside `to_capybara_node` context (Either Capybara::Session or Capybara::Node::Element)
|
34
32
|
def _all(*find_args)
|
35
33
|
kwargs = find_args.pop
|
36
34
|
to_capybara_node.all(*find_args, **kwargs)
|
37
35
|
end
|
38
36
|
|
39
|
-
# Call `has_selector?` inside `to_capybara_node` context (Either Capybara::Session or Capybara::Node::Element)
|
40
37
|
def element_exists?(*find_args)
|
41
38
|
kwargs = find_args.pop
|
42
39
|
to_capybara_node.has_selector?(*find_args, **kwargs)
|
43
40
|
end
|
44
41
|
|
45
|
-
# Call `has_no_selector?` inside `to_capybara_node` context (Either Capybara::Session or Capybara::Node::Element)
|
46
42
|
def element_does_not_exist?(*find_args)
|
47
43
|
kwargs = find_args.pop
|
48
44
|
to_capybara_node.has_no_selector?(*find_args, **kwargs)
|
@@ -103,10 +99,10 @@ module SitePrism
|
|
103
99
|
# Wait for the elements to be present or not -> @return [TrueClass, SitePrism::Error]
|
104
100
|
# Validate certain properties about the element
|
105
101
|
def element(name, *find_args)
|
106
|
-
|
102
|
+
raise_if_build_time_block_supplied(self, name, block_given?, :element)
|
107
103
|
build(:element, name, *find_args) do
|
108
104
|
define_method(name) do |*runtime_args, &runtime_block|
|
109
|
-
|
105
|
+
raise_if_runtime_block_supplied(self, name, runtime_block, :element)
|
110
106
|
_find(*merge_args(find_args, runtime_args))
|
111
107
|
end
|
112
108
|
end
|
@@ -118,10 +114,10 @@ module SitePrism
|
|
118
114
|
# Wait for the elements to be present or not -> @return [TrueClass, SitePrism::Error]
|
119
115
|
# Validate certain properties about the elements
|
120
116
|
def elements(name, *find_args)
|
121
|
-
|
117
|
+
raise_if_build_time_block_supplied(self, name, block_given?, :elements)
|
122
118
|
build(:elements, name, *find_args) do
|
123
119
|
define_method(name) do |*runtime_args, &runtime_block|
|
124
|
-
|
120
|
+
raise_if_runtime_block_supplied(self, name, runtime_block, :elements)
|
125
121
|
_all(*merge_args(find_args, runtime_args))
|
126
122
|
end
|
127
123
|
end
|
@@ -151,7 +147,7 @@ module SitePrism
|
|
151
147
|
section_class, find_args = extract_section_options(args, &block)
|
152
148
|
build(:sections, name, *find_args) do
|
153
149
|
define_method(name) do |*runtime_args, &runtime_block|
|
154
|
-
|
150
|
+
raise_if_runtime_block_supplied(self, name, runtime_block, :sections)
|
155
151
|
_all(*merge_args(find_args, runtime_args)).map do |element|
|
156
152
|
section_class.new(self, element)
|
157
153
|
end
|
@@ -160,7 +156,7 @@ module SitePrism
|
|
160
156
|
end
|
161
157
|
|
162
158
|
def iframe(name, klass, *args)
|
163
|
-
|
159
|
+
raise_if_build_time_block_supplied(self, name, block_given?, :elements)
|
164
160
|
element_find_args = deduce_iframe_element_find_args(args)
|
165
161
|
scope_find_args = deduce_iframe_scope_find_args(args)
|
166
162
|
build(:iframe, name, *element_find_args) do
|
@@ -175,10 +171,10 @@ module SitePrism
|
|
175
171
|
# Return a list of all mapped items on a SitePrism class instance (Page or Section)
|
176
172
|
# If legacy is set to true (Default) -> @return [Array]
|
177
173
|
# If legacy is set to false (New behaviour) -> @return [Hash]
|
178
|
-
def mapped_items(legacy:
|
179
|
-
return
|
174
|
+
def mapped_items(legacy: false)
|
175
|
+
return legacy_mapped_items if legacy
|
180
176
|
|
181
|
-
|
177
|
+
@mapped_items ||= { element: [], elements: [], section: [], sections: [], iframe: [] }
|
182
178
|
end
|
183
179
|
|
184
180
|
private
|
@@ -192,13 +188,13 @@ module SitePrism
|
|
192
188
|
map_item(type, name)
|
193
189
|
yield
|
194
190
|
end
|
195
|
-
add_helper_methods(name, *find_args)
|
191
|
+
add_helper_methods(name, type, *find_args)
|
196
192
|
end
|
197
193
|
|
198
|
-
def add_helper_methods(name, *find_args)
|
194
|
+
def add_helper_methods(name, _type, *find_args)
|
199
195
|
create_existence_checker(name, *find_args)
|
200
196
|
create_nonexistence_checker(name, *find_args)
|
201
|
-
SitePrism::
|
197
|
+
SitePrism::RSpecMatchers.new(name)._create_rspec_existence_matchers if defined?(RSpec)
|
202
198
|
create_visibility_waiter(name, *find_args)
|
203
199
|
create_invisibility_waiter(name, *find_args)
|
204
200
|
end
|
@@ -254,15 +250,15 @@ module SitePrism
|
|
254
250
|
end
|
255
251
|
|
256
252
|
def create_error_method(name)
|
257
|
-
SitePrism.
|
258
|
-
SitePrism::Deprecator.soft_deprecate(
|
253
|
+
SitePrism::Deprecator.deprecate(
|
259
254
|
'DSL definition with no find_args',
|
260
|
-
'
|
255
|
+
'DSL definition with at least 1 find_arg'
|
261
256
|
)
|
257
|
+
SitePrism.logger.error("#{name} has come from an item with no locators.")
|
262
258
|
define_method(name) { raise SitePrism::InvalidElementError }
|
263
259
|
end
|
264
260
|
|
265
|
-
def
|
261
|
+
def raise_if_build_time_block_supplied(parent_object, name, has_block, type)
|
266
262
|
return unless has_block
|
267
263
|
|
268
264
|
SitePrism.logger.debug("Type passed in: #{type}")
|
@@ -270,22 +266,17 @@ module SitePrism
|
|
270
266
|
raise SitePrism::UnsupportedBlockError
|
271
267
|
end
|
272
268
|
|
273
|
-
def
|
274
|
-
SitePrism::Deprecator.
|
275
|
-
'.mapped_items on a class',
|
276
|
-
'
|
277
|
-
'.mapped_items(legacy: false)'
|
269
|
+
def legacy_mapped_items
|
270
|
+
SitePrism::Deprecator.deprecate(
|
271
|
+
'.mapped_items structure (internally), on a class',
|
272
|
+
'Thew new .mapped_items structure'
|
278
273
|
)
|
279
|
-
@
|
280
|
-
end
|
281
|
-
|
282
|
-
def new_mapped_items
|
283
|
-
@new_mapped_items ||= { element: [], elements: [], section: [], sections: [], iframe: [] }
|
274
|
+
@legacy_mapped_items ||= []
|
284
275
|
end
|
285
276
|
|
286
277
|
def map_item(type, name)
|
287
|
-
|
288
|
-
|
278
|
+
mapped_items(legacy: true) << { type => name }
|
279
|
+
mapped_items[type] << name.to_sym
|
289
280
|
end
|
290
281
|
|
291
282
|
def deduce_iframe_scope_find_args(args)
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module SitePrism
|
4
|
+
#
|
4
5
|
# [SitePrism::ElementChecker]
|
5
6
|
#
|
6
7
|
# This allows users to run `#all_there?` checks on an instance.
|
7
8
|
#
|
8
|
-
# NB: This functionality is being removed in v4 in favour of the all_there gem
|
9
9
|
module ElementChecker
|
10
10
|
# Runnable in the scope of any SitePrism::Page or Section.
|
11
11
|
# Returns +true+ when "every item" that is being checked is
|
@@ -26,13 +26,7 @@ module SitePrism
|
|
26
26
|
# Override: 'one' => Perform one recursive dive into all section/sections
|
27
27
|
# items and call #all_there? on all of those items too.
|
28
28
|
def all_there?(recursion: :none)
|
29
|
-
|
30
|
-
when :none; then elements_to_check.all? { |name| there?(name) }
|
31
|
-
when :one; then SitePrism::AllThere::RecursionChecker.new(self).all_there?
|
32
|
-
else
|
33
|
-
SitePrism.logger.debug("Input value '#{recursion}'. Valid values are :none or :one.")
|
34
|
-
SitePrism.logger.error('Invalid recursion setting, Will not run #all_there?.')
|
35
|
-
end
|
29
|
+
SitePrism::AllThere::RecursionChecker.new(self).all_there?(recursion: recursion)
|
36
30
|
end
|
37
31
|
|
38
32
|
# Returns each element that is currently present inside the scope being tested
|
@@ -51,8 +45,6 @@ module SitePrism
|
|
51
45
|
|
52
46
|
private
|
53
47
|
|
54
|
-
# If the page or section has expected_items set, return expected_items that are mapped
|
55
|
-
# otherwise just return the list of all mapped_items
|
56
48
|
def elements_to_check
|
57
49
|
if _expected_items
|
58
50
|
SitePrism.logger.debug('Expected Items has been set.')
|
@@ -63,7 +55,7 @@ module SitePrism
|
|
63
55
|
end
|
64
56
|
|
65
57
|
def _mapped_items
|
66
|
-
self.class.mapped_items
|
58
|
+
self.class.mapped_items.values.flatten.uniq
|
67
59
|
end
|
68
60
|
|
69
61
|
def _expected_items
|
data/lib/site_prism/loadable.rb
CHANGED
@@ -43,10 +43,11 @@ module SitePrism
|
|
43
43
|
|
44
44
|
# Check if the page is loaded.
|
45
45
|
#
|
46
|
-
# On failure, if an error was reported by a failing validation,
|
47
|
-
# it will be available via the `load_error` accessor.
|
46
|
+
# On failure, if an error was reported by a failing validation, it will be available via the `load_error` accessor
|
48
47
|
#
|
49
|
-
#
|
48
|
+
# It will return true if the page has been loaded successfully; otherwise it returns false
|
49
|
+
#
|
50
|
+
# @return [Boolean]
|
50
51
|
def loaded?
|
51
52
|
self.load_error = nil
|
52
53
|
|
@@ -57,8 +58,6 @@ module SitePrism
|
|
57
58
|
|
58
59
|
private
|
59
60
|
|
60
|
-
# If any load validations from page subclasses returns false,
|
61
|
-
# immediately return false.
|
62
61
|
def load_validations_pass?
|
63
62
|
self.class.load_validations.all? do |validation|
|
64
63
|
passed, message = instance_eval(&validation)
|
data/lib/site_prism/page.rb
CHANGED
@@ -9,7 +9,7 @@ module SitePrism
|
|
9
9
|
# through clicking buttons or filling in fields, or verbosely loaded by using the `#load` method
|
10
10
|
#
|
11
11
|
# All method calls made whilst on a page are scoped using `#to_capybara_node` which defaults to the
|
12
|
-
# current Capybara session
|
12
|
+
# current Capybara session or the `@page` that has been loaded in-line
|
13
13
|
class Page
|
14
14
|
include Capybara::DSL
|
15
15
|
include ElementChecker
|
@@ -48,12 +48,15 @@ module SitePrism
|
|
48
48
|
#
|
49
49
|
# @return [Capybara::Node::Simple || Capybara::Session]
|
50
50
|
def page
|
51
|
+
SitePrism::Deprecator.deprecate('Calling #page on a SitePrism::Page instance')
|
51
52
|
(defined?(@page) && @page) || Capybara.current_session
|
52
53
|
end
|
53
54
|
|
54
55
|
# This scopes our calls inside Page correctly to the `Capybara::Session`
|
56
|
+
#
|
57
|
+
# @return [Capybara::Node::Simple || Capybara::Session]
|
55
58
|
def to_capybara_node
|
56
|
-
page
|
59
|
+
(defined?(@page) && @page) || Capybara.current_session
|
57
60
|
end
|
58
61
|
|
59
62
|
# Loads the page.
|
@@ -85,12 +88,21 @@ module SitePrism
|
|
85
88
|
return_yield || true
|
86
89
|
end
|
87
90
|
|
91
|
+
# Returns true if the page is displayed within the requisite time
|
92
|
+
# Returns false if the page is not displayed within the requisite time
|
93
|
+
#
|
94
|
+
# @return [Boolean]
|
88
95
|
def displayed?(*args)
|
89
96
|
wait_until_displayed(*args)
|
90
97
|
rescue SitePrism::TimeoutError
|
91
98
|
false
|
92
99
|
end
|
93
100
|
|
101
|
+
# Wait until the page is displayed according to input arguments
|
102
|
+
# If no url_matcher is provided we don't know how to determine if the page is displayed. So we return an error
|
103
|
+
# Then we wait until the url matches the expected mappings
|
104
|
+
#
|
105
|
+
# @return [Boolean]
|
94
106
|
def wait_until_displayed(*args)
|
95
107
|
raise SitePrism::NoUrlMatcherForPageError unless url_matcher
|
96
108
|
|
@@ -99,6 +111,13 @@ module SitePrism
|
|
99
111
|
Waiter.wait_until_true(seconds) { url_matches?(expected_mappings) }
|
100
112
|
end
|
101
113
|
|
114
|
+
# Return the matching information of a page
|
115
|
+
#
|
116
|
+
# Return nil if the page is not displayed correctly
|
117
|
+
# Return the regex matches if we have provided a regexp style url_matcher
|
118
|
+
# Otherwise fall back to an addressable-style template of matches
|
119
|
+
#
|
120
|
+
# @return [Nil || MatchData || Hash]
|
102
121
|
def url_matches(seconds = Capybara.default_max_wait_time)
|
103
122
|
return unless displayed?(seconds)
|
104
123
|
return regexp_backed_matches if url_matcher.is_a?(Regexp)
|
@@ -106,14 +125,24 @@ module SitePrism
|
|
106
125
|
template_backed_matches
|
107
126
|
end
|
108
127
|
|
128
|
+
# Returns the templated url from the set_url property defined during the page definition
|
129
|
+
# Returns `nil` if there was not a property set (i.e. the page should not be directly loaded)
|
130
|
+
#
|
131
|
+
# @return [NilClass || String]
|
109
132
|
def url(expansion = {})
|
110
133
|
self.class.url && Addressable::Template.new(self.class.url).expand(expansion).to_s
|
111
134
|
end
|
112
135
|
|
136
|
+
# Returns the url_matcher property defined during the page definition
|
137
|
+
#
|
138
|
+
# @return [Regexp]
|
113
139
|
def url_matcher
|
114
140
|
self.class.url_matcher
|
115
141
|
end
|
116
142
|
|
143
|
+
# Returns true if the page is secure, otherwise returns false
|
144
|
+
#
|
145
|
+
# @return [Boolean]
|
117
146
|
def secure?
|
118
147
|
page.current_url.start_with?('https')
|
119
148
|
end
|
@@ -4,13 +4,16 @@ module SitePrism
|
|
4
4
|
#
|
5
5
|
# @api private
|
6
6
|
#
|
7
|
-
class
|
7
|
+
class RSpecMatchers
|
8
8
|
attr_reader :element_name
|
9
9
|
|
10
10
|
def initialize(element_name)
|
11
11
|
@element_name = element_name
|
12
12
|
end
|
13
13
|
|
14
|
+
# Create the positive and negative rspec matchers that will use the SitePrism boolean methods
|
15
|
+
#
|
16
|
+
# @return [Symbol]
|
14
17
|
def _create_rspec_existence_matchers
|
15
18
|
SitePrism.logger.debug('Including all relevant matcher names / warnings in RSpec scope.')
|
16
19
|
create_rspec_existence_matchers(matcher, object_method, negated_object_method, warning)
|
@@ -43,8 +46,8 @@ module SitePrism
|
|
43
46
|
end
|
44
47
|
|
45
48
|
def warning
|
46
|
-
"The RSpec matcher '#{matcher}' was added by SitePrism, but the object under test "\
|
47
|
-
"does not respond to '#{negated_object_method}' and is probably not a SitePrism object. "\
|
49
|
+
"The RSpec matcher '#{matcher}' was added by SitePrism, but the object under test " \
|
50
|
+
"does not respond to '#{negated_object_method}' and is probably not a SitePrism object. " \
|
48
51
|
'Falling back to the default RSpec matcher.'
|
49
52
|
end
|
50
53
|
end
|
data/lib/site_prism/section.rb
CHANGED
@@ -72,13 +72,6 @@ module SitePrism
|
|
72
72
|
Capybara.within(root_element) { yield(self) }
|
73
73
|
end
|
74
74
|
|
75
|
-
# This was the old API-style of delegating through the Capybara.page call and over-loading
|
76
|
-
# the method so we always went through our correct `root_element`
|
77
|
-
def page
|
78
|
-
SitePrism.logger.fatal('This is not supposed to be used. All delegation now happens automatically!')
|
79
|
-
raise SitePrism::SitePrismError
|
80
|
-
end
|
81
|
-
|
82
75
|
def capybara_session
|
83
76
|
Capybara.current_session
|
84
77
|
end
|
data/lib/site_prism/timer.rb
CHANGED
@@ -7,9 +7,9 @@ module SitePrism
|
|
7
7
|
class Timer
|
8
8
|
attr_reader :wait_time
|
9
9
|
|
10
|
-
# Return &block
|
11
|
-
#
|
12
10
|
# Count towards a specified time (Supplied)
|
11
|
+
#
|
12
|
+
# @return [Proc]
|
13
13
|
def self.run(wait_time, &block)
|
14
14
|
new(wait_time).run(&block)
|
15
15
|
end
|
@@ -19,16 +19,16 @@ module SitePrism
|
|
19
19
|
@done = false
|
20
20
|
end
|
21
21
|
|
22
|
-
# Return Boolean
|
23
|
-
#
|
24
22
|
# Whether the timer has completed
|
23
|
+
#
|
24
|
+
# @return [Boolean]
|
25
25
|
def done?
|
26
26
|
@done == true
|
27
27
|
end
|
28
28
|
|
29
|
-
# Return &block
|
30
|
-
#
|
31
29
|
# Start the Timer and re-evaluate the block repeatedly
|
30
|
+
#
|
31
|
+
# @return [Proc]
|
32
32
|
def run
|
33
33
|
start
|
34
34
|
yield self
|
@@ -36,9 +36,9 @@ module SitePrism
|
|
36
36
|
stop
|
37
37
|
end
|
38
38
|
|
39
|
-
# Return [Boolean, Nil]
|
40
|
-
#
|
41
39
|
# Start the Timer in a separate process
|
40
|
+
#
|
41
|
+
# Return [True]
|
42
42
|
def start
|
43
43
|
stop
|
44
44
|
return if wait_time.zero?
|
@@ -50,9 +50,9 @@ module SitePrism
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
# Return True
|
54
|
-
#
|
55
53
|
# Forcibly stop the timer, and kill any threads created by it
|
54
|
+
#
|
55
|
+
# Return [True]
|
56
56
|
def stop
|
57
57
|
if @thread
|
58
58
|
@thread.kill
|
data/lib/site_prism/version.rb
CHANGED
data/lib/site_prism/waiter.rb
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
module SitePrism
|
4
4
|
# [SitePrism::Waiter]
|
5
5
|
class Waiter
|
6
|
-
# @return Boolean
|
7
|
-
#
|
8
6
|
# A looper that will wait until the passed in block evaluates to true
|
9
7
|
# Alternatively it will time out once the wait_time is exceeded
|
8
|
+
#
|
9
|
+
# @return [Boolean]
|
10
10
|
def self.wait_until_true(wait_time = Capybara.default_max_wait_time, sleep_duration = 0.05)
|
11
11
|
Timer.run(wait_time) do |timer|
|
12
12
|
loop do
|
data/lib/site_prism.rb
CHANGED
@@ -16,7 +16,7 @@ module SitePrism
|
|
16
16
|
autoload :Loadable, 'site_prism/loadable'
|
17
17
|
autoload :Logger, 'site_prism/logger'
|
18
18
|
autoload :Page, 'site_prism/page'
|
19
|
-
autoload :
|
19
|
+
autoload :RSpecMatchers, 'site_prism/rspec_matchers'
|
20
20
|
autoload :Section, 'site_prism/section'
|
21
21
|
autoload :Timer, 'site_prism/timer'
|
22
22
|
autoload :Waiter, 'site_prism/waiter'
|
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.0
|
4
|
+
version: '4.0'
|
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:
|
12
|
+
date: 2023-04-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -17,48 +17,42 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '2.
|
20
|
+
version: '2.8'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '2.
|
27
|
+
version: '2.8'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: capybara
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '3.
|
34
|
+
version: '3.27'
|
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: '3.
|
41
|
+
version: '3.27'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: site_prism-all_there
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '1'
|
49
|
-
- - "<"
|
46
|
+
- - "~>"
|
50
47
|
- !ruby/object:Gem::Version
|
51
|
-
version: '2'
|
48
|
+
version: '2.0'
|
52
49
|
type: :runtime
|
53
50
|
prerelease: false
|
54
51
|
version_requirements: !ruby/object:Gem::Requirement
|
55
52
|
requirements:
|
56
|
-
- - "
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
version: '1'
|
59
|
-
- - "<"
|
53
|
+
- - "~>"
|
60
54
|
- !ruby/object:Gem::Version
|
61
|
-
version: '2'
|
55
|
+
version: '2.0'
|
62
56
|
- !ruby/object:Gem::Dependency
|
63
57
|
name: cucumber
|
64
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,104 +79,104 @@ dependencies:
|
|
85
79
|
requirements:
|
86
80
|
- - "~>"
|
87
81
|
- !ruby/object:Gem::Version
|
88
|
-
version: '3.
|
82
|
+
version: '3.12'
|
89
83
|
type: :development
|
90
84
|
prerelease: false
|
91
85
|
version_requirements: !ruby/object:Gem::Requirement
|
92
86
|
requirements:
|
93
87
|
- - "~>"
|
94
88
|
- !ruby/object:Gem::Version
|
95
|
-
version: '3.
|
89
|
+
version: '3.12'
|
96
90
|
- !ruby/object:Gem::Dependency
|
97
91
|
name: rubocop
|
98
92
|
requirement: !ruby/object:Gem::Requirement
|
99
93
|
requirements:
|
100
94
|
- - "~>"
|
101
95
|
- !ruby/object:Gem::Version
|
102
|
-
version: 1.
|
96
|
+
version: 1.49.0
|
103
97
|
type: :development
|
104
98
|
prerelease: false
|
105
99
|
version_requirements: !ruby/object:Gem::Requirement
|
106
100
|
requirements:
|
107
101
|
- - "~>"
|
108
102
|
- !ruby/object:Gem::Version
|
109
|
-
version: 1.
|
103
|
+
version: 1.49.0
|
110
104
|
- !ruby/object:Gem::Dependency
|
111
105
|
name: rubocop-performance
|
112
106
|
requirement: !ruby/object:Gem::Requirement
|
113
107
|
requirements:
|
114
108
|
- - "~>"
|
115
109
|
- !ruby/object:Gem::Version
|
116
|
-
version: 1.
|
110
|
+
version: 1.16.0
|
117
111
|
type: :development
|
118
112
|
prerelease: false
|
119
113
|
version_requirements: !ruby/object:Gem::Requirement
|
120
114
|
requirements:
|
121
115
|
- - "~>"
|
122
116
|
- !ruby/object:Gem::Version
|
123
|
-
version: 1.
|
117
|
+
version: 1.16.0
|
124
118
|
- !ruby/object:Gem::Dependency
|
125
119
|
name: rubocop-rspec
|
126
120
|
requirement: !ruby/object:Gem::Requirement
|
127
121
|
requirements:
|
128
122
|
- - "~>"
|
129
123
|
- !ruby/object:Gem::Version
|
130
|
-
version: 2.
|
124
|
+
version: 2.19.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: 2.
|
131
|
+
version: 2.19.0
|
138
132
|
- !ruby/object:Gem::Dependency
|
139
133
|
name: selenium-webdriver
|
140
134
|
requirement: !ruby/object:Gem::Requirement
|
141
135
|
requirements:
|
142
|
-
- - "
|
143
|
-
- !ruby/object:Gem::Version
|
144
|
-
version: '3.13'
|
145
|
-
- - "<"
|
136
|
+
- - "~>"
|
146
137
|
- !ruby/object:Gem::Version
|
147
|
-
version: '
|
138
|
+
version: '4.0'
|
148
139
|
type: :development
|
149
140
|
prerelease: false
|
150
141
|
version_requirements: !ruby/object:Gem::Requirement
|
151
142
|
requirements:
|
152
|
-
- - "
|
153
|
-
- !ruby/object:Gem::Version
|
154
|
-
version: '3.13'
|
155
|
-
- - "<"
|
143
|
+
- - "~>"
|
156
144
|
- !ruby/object:Gem::Version
|
157
|
-
version: '
|
145
|
+
version: '4.0'
|
158
146
|
- !ruby/object:Gem::Dependency
|
159
147
|
name: simplecov
|
160
148
|
requirement: !ruby/object:Gem::Requirement
|
161
149
|
requirements:
|
162
150
|
- - "~>"
|
163
151
|
- !ruby/object:Gem::Version
|
164
|
-
version: '0.
|
152
|
+
version: '0.21'
|
165
153
|
type: :development
|
166
154
|
prerelease: false
|
167
155
|
version_requirements: !ruby/object:Gem::Requirement
|
168
156
|
requirements:
|
169
157
|
- - "~>"
|
170
158
|
- !ruby/object:Gem::Version
|
171
|
-
version: '0.
|
159
|
+
version: '0.21'
|
172
160
|
- !ruby/object:Gem::Dependency
|
173
161
|
name: webdrivers
|
174
162
|
requirement: !ruby/object:Gem::Requirement
|
175
163
|
requirements:
|
176
|
-
- - "
|
164
|
+
- - ">"
|
177
165
|
- !ruby/object:Gem::Version
|
178
166
|
version: '4.6'
|
167
|
+
- - "<"
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '6'
|
179
170
|
type: :development
|
180
171
|
prerelease: false
|
181
172
|
version_requirements: !ruby/object:Gem::Requirement
|
182
173
|
requirements:
|
183
|
-
- - "
|
174
|
+
- - ">"
|
184
175
|
- !ruby/object:Gem::Version
|
185
176
|
version: '4.6'
|
177
|
+
- - "<"
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '6'
|
186
180
|
description: SitePrism gives you a simple, clean and semantic DSL for describing your
|
187
181
|
site. SitePrism implements the Page Object Model pattern on top of Capybara.
|
188
182
|
email:
|
@@ -224,12 +218,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
224
218
|
requirements:
|
225
219
|
- - ">="
|
226
220
|
- !ruby/object:Gem::Version
|
227
|
-
version: '2.
|
221
|
+
version: '2.6'
|
228
222
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
229
223
|
requirements:
|
230
|
-
- - "
|
224
|
+
- - ">="
|
231
225
|
- !ruby/object:Gem::Version
|
232
|
-
version:
|
226
|
+
version: '0'
|
233
227
|
requirements: []
|
234
228
|
rubygems_version: 3.0.3.1
|
235
229
|
signing_key:
|