capybara-lockstep 0.7.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +9 -1
- data/Gemfile.lock +2 -4
- data/README.md +26 -16
- data/lib/capybara-lockstep/capybara_ext.rb +4 -4
- data/lib/capybara-lockstep/configuration.rb +18 -8
- data/lib/capybara-lockstep/lockstep.rb +14 -2
- data/lib/capybara-lockstep/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86f6aba93856539de9e2df301e720cced0c444de2d62436e72ea620765f9b3e1
|
4
|
+
data.tar.gz: 1ae5dc301b4761d7c51796313ea4a6210596b5975e02f639410916ddc53060b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1dc1f1e4a8af3d4d02f4d7b2aec3ae99844ba42bd3713028a138842bdc296c6bc0ed39688b8c15d7976830cc97df9ebc96cee3f3cfc9ab5f799e99ec59fee23
|
7
|
+
data.tar.gz: 50e27f5304cc7fbc1ed0c74ee87311ef8c8a333ecd4395af7cf155305ce0607f4b0f20defdf901d8f5cb3cbe8fc1ddb23638d9587c27f15e2071aea59c24297c
|
data/.github/workflows/test.yml
CHANGED
@@ -7,9 +7,13 @@ on:
|
|
7
7
|
pull_request:
|
8
8
|
branches:
|
9
9
|
- master
|
10
|
+
workflow_dispatch:
|
11
|
+
branches:
|
12
|
+
- master
|
10
13
|
jobs:
|
11
14
|
test:
|
12
15
|
runs-on: ubuntu-20.04
|
16
|
+
timeout-minutes: 3
|
13
17
|
strategy:
|
14
18
|
fail-fast: false
|
15
19
|
matrix:
|
@@ -33,4 +37,8 @@ jobs:
|
|
33
37
|
gem install bundler:2.2.15
|
34
38
|
bundle install --no-deployment
|
35
39
|
- name: Run tests
|
36
|
-
|
40
|
+
uses: nick-invision/retry@v2
|
41
|
+
with:
|
42
|
+
timeout_seconds: 30
|
43
|
+
max_attempts: 3
|
44
|
+
command: bundle exec rake spec
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
capybara-lockstep (0.
|
4
|
+
capybara-lockstep (1.0.0)
|
5
5
|
activesupport (>= 3.2)
|
6
6
|
capybara (>= 2.0)
|
7
7
|
ruby2_keywords
|
@@ -44,10 +44,8 @@ GEM
|
|
44
44
|
rake
|
45
45
|
jasmine-core (3.6.0)
|
46
46
|
mini_mime (1.1.0)
|
47
|
-
mini_portile2 (2.5.1)
|
48
47
|
minitest (5.14.4)
|
49
|
-
nokogiri (1.11.3)
|
50
|
-
mini_portile2 (~> 2.5.0)
|
48
|
+
nokogiri (1.11.3-x86_64-linux)
|
51
49
|
racc (~> 1.4)
|
52
50
|
phantomjs (2.1.1.0)
|
53
51
|
public_suffix (4.0.6)
|
data/README.md
CHANGED
@@ -249,22 +249,6 @@ To enable logging in the browser console (but not STDOUT), include the snippet w
|
|
249
249
|
capybara_lockstep(debug: true)
|
250
250
|
```
|
251
251
|
|
252
|
-
|
253
|
-
## Disabling synchronization
|
254
|
-
|
255
|
-
Sometimes you want to disable browser synchronization, e.g. to observe a loading spinner during a long-running request.
|
256
|
-
|
257
|
-
To disable synchronization:
|
258
|
-
|
259
|
-
```ruby
|
260
|
-
begin
|
261
|
-
Capybara::Lockstep.enabled = false
|
262
|
-
do_unsynchronized_work
|
263
|
-
ensure
|
264
|
-
Capybara::Lockstep.enabled = true
|
265
|
-
end
|
266
|
-
```
|
267
|
-
|
268
252
|
## Synchronization timeout
|
269
253
|
|
270
254
|
By default capybara-lockstep will wait `Capybara.default_max_wait_time` seconds for the page initialize and for JavaScript and AJAX request to finish.
|
@@ -300,6 +284,32 @@ You may also synchronize from your client-side JavaScript. The following will ru
|
|
300
284
|
CapybaraLockstep.synchronize(callback)
|
301
285
|
```
|
302
286
|
|
287
|
+
|
288
|
+
## Disabling synchronization
|
289
|
+
|
290
|
+
Sometimes you want to disable browser synchronization, e.g. to observe a loading spinner during a long-running request.
|
291
|
+
|
292
|
+
To disable automatic synchronization:
|
293
|
+
|
294
|
+
```ruby
|
295
|
+
begin
|
296
|
+
Capybara::Lockstep.mode = :manual
|
297
|
+
do_unsynchronized_work
|
298
|
+
ensure
|
299
|
+
Capybara::Lockstep.mode = :auto
|
300
|
+
end
|
301
|
+
```
|
302
|
+
|
303
|
+
Note that you may still force synchronization by calling `Capybara::Lockstep.synchronize` manually.
|
304
|
+
|
305
|
+
To completely disable synchronization:
|
306
|
+
|
307
|
+
```ruby
|
308
|
+
Capybara::Lockstep.mode = :off
|
309
|
+
Capybara::Lockstep.synchronize # will not synchronize
|
310
|
+
```
|
311
|
+
|
312
|
+
|
303
313
|
## Signaling asynchronous work
|
304
314
|
|
305
315
|
If for some reason you want capybara-lockstep to consider additional asynchronous work as "busy", you can do so:
|
@@ -55,8 +55,7 @@ module Capybara
|
|
55
55
|
# we force a non-lazy synchronization so we pick up all client-side changes
|
56
56
|
# that have not been caused by Capybara commands.
|
57
57
|
script_may_navigate_away = script =~ /\b(location|history)\b/
|
58
|
-
Lockstep.log "Synchronizing before script: #{script}"
|
59
|
-
Lockstep.synchronize(lazy: !script_may_navigate_away)
|
58
|
+
Lockstep.auto_synchronize(lazy: !script_may_navigate_away, log: "Synchronizing before script: #{script}")
|
60
59
|
end
|
61
60
|
|
62
61
|
super(script, *args, &block).tap do
|
@@ -143,9 +142,10 @@ module Capybara
|
|
143
142
|
module Lockstep
|
144
143
|
module SynchronizeWithCatchUp
|
145
144
|
ruby2_keywords def synchronize(*args, &block)
|
146
|
-
# This method is called
|
145
|
+
# This method is called by Capybara before most interactions with
|
146
|
+
# the browser. It is a different method than Capybara::Lockstep.synchronize!
|
147
147
|
# We use the { lazy } option to only synchronize when we're out of sync.
|
148
|
-
Capybara::Lockstep.
|
148
|
+
Capybara::Lockstep.auto_synchronize(lazy: true)
|
149
149
|
|
150
150
|
super(*args, &block)
|
151
151
|
end
|
@@ -29,16 +29,30 @@ module Capybara
|
|
29
29
|
@debug
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def mode
|
33
33
|
if javascript_driver?
|
34
|
-
@
|
34
|
+
@mode.nil? ? :auto : @mode
|
35
35
|
else
|
36
|
-
|
36
|
+
:off
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
def mode=(mode)
|
41
|
+
@mode = mode
|
42
|
+
end
|
43
|
+
|
40
44
|
def enabled=(enabled)
|
41
|
-
|
45
|
+
case enabled
|
46
|
+
when true
|
47
|
+
log "Setting `Capybara::Lockstep.enabled = true` is deprecated. Set `Capybara::Lockstep.mode = :auto` instead."
|
48
|
+
self.mode = :auto
|
49
|
+
when false
|
50
|
+
log "Setting `Capybara::Lockstep.enabled = false` is deprecated. Set `Capybara::Lockstep.mode = :manual` or `Capybara::Lockstep.mode = :off` instead."
|
51
|
+
self.mode = :manual
|
52
|
+
when nil
|
53
|
+
# Reset to default
|
54
|
+
self.mode = nil
|
55
|
+
end
|
42
56
|
end
|
43
57
|
|
44
58
|
def wait_tasks
|
@@ -55,10 +69,6 @@ module Capybara
|
|
55
69
|
@wait_tasks
|
56
70
|
end
|
57
71
|
|
58
|
-
def disabled?
|
59
|
-
!enabled?
|
60
|
-
end
|
61
|
-
|
62
72
|
private
|
63
73
|
|
64
74
|
def javascript_driver?
|
@@ -23,14 +23,26 @@ module Capybara
|
|
23
23
|
page.instance_variable_set(:@lockstep_synchronized, value)
|
24
24
|
end
|
25
25
|
|
26
|
-
def synchronize(lazy: false)
|
27
|
-
if (lazy && synchronized?) || synchronizing? ||
|
26
|
+
def synchronize(lazy: false, log: nil)
|
27
|
+
if (lazy && synchronized?) || synchronizing? || mode == :off
|
28
28
|
return
|
29
29
|
end
|
30
30
|
|
31
|
+
# Allow passing a log message that is only logged
|
32
|
+
# when we're actually synchronizing.
|
33
|
+
if log
|
34
|
+
self.log(log)
|
35
|
+
end
|
36
|
+
|
31
37
|
synchronize_now
|
32
38
|
end
|
33
39
|
|
40
|
+
def auto_synchronize(**options)
|
41
|
+
if mode == :auto
|
42
|
+
synchronize(**options)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
34
46
|
private
|
35
47
|
|
36
48
|
def synchronize_now
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-lockstep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henning Koch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
|
-
rubygems_version: 3.
|
119
|
+
rubygems_version: 3.2.6
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: Synchronize Capybara commands with client-side JavaScript and AJAX requests
|