capybara-lockstep 1.2.0 → 1.3.0

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: ec0d3874212ec29a338fa16ef831e76c0b8dc65b4a200f3a305b7ce41bd76957
4
- data.tar.gz: b5d48346fb7224b2154512534757ef96638f1df9cc62f9d0f911aac8d6a5f846
3
+ metadata.gz: 5496cc79e785bf2ce69669e7a8a6d8ae6f862289f5151487c27a33caa20aa9f7
4
+ data.tar.gz: 635cb396a2ceccbf550a44b2331b3cf1a2340f555557c3eac9440cc6231f5033
5
5
  SHA512:
6
- metadata.gz: 4d44c17fa50ca0fd386b34ecea302148989f4d48d63c48820bcfff75bcd51c63cfbacea0053e63fc1c27f6347fbe252f14be83372aed123a6a1c2574328fe42e
7
- data.tar.gz: 9e7f5cfcbb6b3750277bc55c37484e17859aa4d96f1b8f7b6c1865f4467ae00fad5311e11ea0bfc73d5b8ec5c925df5c8ec6bb2473da6b431296736c89972794
6
+ metadata.gz: e69a2f28e913cef9913825fe1b2594bda44ad31af54a1041978adcd437e8f17518d91d8b3b4e4c0dc71f4259780427288db9ba474f39607e39f60e362a143a9f
7
+ data.tar.gz: 2bb6122c49734c852b3ed64486cbe00dc0c10d51d9de8311c7c11ce5aff85482b97105e2d8c4d6acccfb70efbd2f6855526c8a7d58e36e10237e49a15b746af8
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file.
2
2
 
3
3
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
4
4
 
5
+
6
+ ## 1.2.1 - 2022-09-12
7
+
8
+ - Synchronize with pages constructed from non-empty [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)
9
+
5
10
  ## 1.2.0 - 2022-09-12
6
11
 
7
12
  ### Synchronization around history navigation
data/Gemfile CHANGED
@@ -14,3 +14,5 @@ gem 'chrome_remote'
14
14
 
15
15
  gem 'byebug'
16
16
  gem 'gemika'
17
+
18
+ gem 'activesupport', '~> 6.0'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capybara-lockstep (1.2.0)
4
+ capybara-lockstep (1.3.0)
5
5
  activesupport (>= 3.2)
6
6
  capybara (>= 2.0)
7
7
  ruby2_keywords
@@ -10,15 +10,16 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- activesupport (7.0.1)
13
+ activesupport (6.1.7)
14
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
15
  i18n (>= 1.6, < 2)
16
16
  minitest (>= 5.1)
17
17
  tzinfo (~> 2.0)
18
- addressable (2.8.0)
19
- public_suffix (>= 2.0.2, < 5.0)
18
+ zeitwerk (~> 2.3)
19
+ addressable (2.8.1)
20
+ public_suffix (>= 2.0.2, < 6.0)
20
21
  byebug (11.1.3)
21
- capybara (3.36.0)
22
+ capybara (3.37.1)
22
23
  addressable
23
24
  matrix
24
25
  mini_mime (>= 0.1.3)
@@ -35,7 +36,7 @@ GEM
35
36
  diff-lcs (1.3)
36
37
  eventmachine (1.2.7)
37
38
  gemika (0.6.0)
38
- i18n (1.10.0)
39
+ i18n (1.12.0)
39
40
  concurrent-ruby (~> 1.0)
40
41
  jasmine (3.6.0)
41
42
  jasmine-core (~> 3.6.0)
@@ -45,17 +46,17 @@ GEM
45
46
  jasmine-core (3.6.0)
46
47
  matrix (0.4.2)
47
48
  mini_mime (1.1.2)
48
- minitest (5.15.0)
49
- nokogiri (1.13.0-x86_64-linux)
49
+ minitest (5.16.3)
50
+ nokogiri (1.13.8-x86_64-linux)
50
51
  racc (~> 1.4)
51
52
  phantomjs (2.1.1.0)
52
- public_suffix (4.0.6)
53
+ public_suffix (5.0.0)
53
54
  racc (1.6.0)
54
55
  rack (2.2.3)
55
- rack-test (1.1.0)
56
- rack (>= 1.0, < 3)
56
+ rack-test (2.0.2)
57
+ rack (>= 1.3)
57
58
  rake (13.0.1)
58
- regexp_parser (2.2.0)
59
+ regexp_parser (2.5.0)
59
60
  rexml (3.2.5)
60
61
  rspec (3.7.0)
61
62
  rspec-core (~> 3.7.0)
@@ -72,26 +73,30 @@ GEM
72
73
  rspec-support (3.7.0)
73
74
  ruby2_keywords (0.0.5)
74
75
  rubyzip (2.3.2)
75
- selenium-webdriver (4.1.0)
76
+ selenium-webdriver (4.4.0)
76
77
  childprocess (>= 0.5, < 5.0)
77
78
  rexml (~> 3.2, >= 3.2.5)
78
- rubyzip (>= 1.2.2)
79
+ rubyzip (>= 1.2.2, < 3.0)
80
+ websocket (~> 1.0)
79
81
  thin (1.8.0)
80
82
  daemons (~> 1.0, >= 1.0.9)
81
83
  eventmachine (~> 1.0, >= 1.0.4)
82
84
  rack (>= 1, < 3)
83
- tzinfo (2.0.4)
85
+ tzinfo (2.0.5)
84
86
  concurrent-ruby (~> 1.0)
87
+ websocket (1.2.9)
85
88
  websocket-driver (0.7.3)
86
89
  websocket-extensions (>= 0.1.0)
87
90
  websocket-extensions (0.1.5)
88
91
  xpath (3.2.0)
89
92
  nokogiri (~> 1.8)
93
+ zeitwerk (2.6.0)
90
94
 
91
95
  PLATFORMS
92
96
  ruby
93
97
 
94
98
  DEPENDENCIES
99
+ activesupport (~> 6.0)
95
100
  byebug
96
101
  capybara-lockstep!
97
102
  chrome_remote
data/README.md CHANGED
@@ -345,6 +345,17 @@ Waiting additional tasks will have a negative performance impact on your test su
345
345
  > **Note:** When capybara-lockstep detects jQuery on the page, it will automatically patch [`$.ajax()`](https://api.jquery.com/jQuery.ajax/) to wait an additional task after the response was received. If your only concern is callbacks to `$.ajax()` you do not need so set `Capybara::Lockstep.wait_tasks`.
346
346
 
347
347
 
348
+ ## Running code after synchronization
349
+
350
+ You can configure a proc to run after successful synchronization:
351
+
352
+ ```ruby
353
+ Capybara::Lockstep.after_synchronize do
354
+ puts "Synchronized!"
355
+ end
356
+ ````
357
+
358
+
348
359
  ## Contributing
349
360
 
350
361
  Pull requests are welcome on GitHub at <https://github.com/makandra/capybara-lockstep>.
@@ -77,8 +77,22 @@ module Capybara
77
77
  @wait_tasks
78
78
  end
79
79
 
80
+ def after_synchronize(&callback)
81
+ after_synchronize_callbacks << callback
82
+ end
83
+
80
84
  private
81
85
 
86
+ def after_synchronize_callbacks
87
+ @before_synchronize_callbacks ||= []
88
+ end
89
+
90
+ def run_after_synchronize_callbacks
91
+ after_synchronize_callbacks.each do |callback|
92
+ instance_eval(&callback)
93
+ end
94
+ end
95
+
82
96
  def javascript_driver?
83
97
  driver.is_a?(Capybara::Selenium::Driver)
84
98
  end
@@ -1,7 +1,7 @@
1
1
  module Capybara
2
2
  module Lockstep
3
3
  ERROR_SNIPPET_MISSING = 'Cannot synchronize: capybara-lockstep JavaScript snippet is missing'
4
- ERROR_PAGE_MISSING = 'Cannot synchronize before initial Capybara visit'
4
+ ERROR_PAGE_MISSING = 'Cannot synchronize with empty page'
5
5
  ERROR_ALERT_OPEN = 'Cannot synchronize while an alert is open'
6
6
  ERROR_NAVIGATED_AWAY = "Browser navigated away while synchronizing"
7
7
 
@@ -53,6 +53,8 @@ module Capybara
53
53
  end
54
54
 
55
55
  synchronize_now(log: log)
56
+
57
+ run_after_synchronize_callbacks
56
58
  end
57
59
 
58
60
  # Automatic synchronization from within the capybara-lockstep should always call #auto_synchronize.
@@ -85,8 +87,8 @@ module Capybara
85
87
  done(#{ERROR_SNIPPET_MISSING.to_json})
86
88
  }
87
89
  }
88
- let protocol = location.protocol
89
- if (protocol === 'data:' || protocol == 'about:') {
90
+ const emptyDataURL = /^data:[^,]*,?$/
91
+ if (emptyDataURL.test(location.href) || location.protocol === 'about:') {
90
92
  done(#{ERROR_PAGE_MISSING.to_json})
91
93
  } else if (document.readyState === 'complete') {
92
94
  // WebDriver always waits for the `load` event after a visit(),
@@ -136,9 +138,10 @@ module Capybara
136
138
  end
137
139
  rescue StandardError => e
138
140
  unhandled_synchronize_error(e)
139
- ensure
140
- self.synchronizing = false
141
141
  end
142
+
143
+ ensure
144
+ self.synchronizing = false
142
145
  end
143
146
 
144
147
  def unhandled_synchronize_error(e)
@@ -1,5 +1,5 @@
1
1
  module Capybara
2
2
  module Lockstep
3
- VERSION = "1.2.0"
3
+ VERSION = "1.3.0"
4
4
  end
5
5
  end
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: 1.2.0
4
+ version: 1.3.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: 2022-09-12 00:00:00.000000000 Z
11
+ date: 2023-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara