integration-tests-rails 1.1.1 → 1.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 553221dfadfcf7e5cbba780de7ffc994a118b8c10f623097cb11cef2afce16c7
4
- data.tar.gz: b51152ab46d5e9f11916bbf3a7758c4134bc049142d5087b811f41abf742b106
3
+ metadata.gz: 8d0f4c5aac87998a36e8c05f73d976f4ca20b3e782c15de1774a313fe5910dab
4
+ data.tar.gz: cc3be55a934b98c6a0ce9e636b46ec51f330c754fa2b4b1f0b81fcb2f3dbfafe
5
5
  SHA512:
6
- metadata.gz: 2394d82b9a73ae09d7f9956054f88954e510fff8e4a60db1ab43a5d1f592edd569ed30cd46895b6a45b0ee1ca68b9313ea88ea53cdaed48643ffe9d2cb1b3ac3
7
- data.tar.gz: a7534bfe6db6205d27dace38fc6535c44a6bb0c7b27d954177e6e613e37ea40d9eb739a2015d269c8745d53bcb37a55c4ceda6fa50a9584cf3db7f4bc4a8ca9e
6
+ metadata.gz: '01837084f1a0c65d194c6ff3ddd303478319e7e043d3bd4a9fb378b0b9ede402570397ee855f321741d005d458bb411f4ce5913f0bd815f1ac395bb6d4a683e4'
7
+ data.tar.gz: bd5fe9d65e56eff6717a961e49028548fc2eb400622512af4902ae7cbead76a9eb9c1ff557977b381bd69abee263e6c0e41d60d8b8f71c7e03a29d7269823f20
data/README.md CHANGED
@@ -67,6 +67,7 @@ IntegrationTestsRails.setup do |config|
67
67
  config.puma_threads = '1:1' # Number of threads for the Puma server used by Cuprite.
68
68
  config.remote = false # Whether to use a remote Chrome instance.
69
69
  config.retry_attempts = 1 # Number of times to retry a test if an example fails inside a retry_on_fail block.
70
+ config.retry_capture_exceptions = [RSpec::Expectations::ExpectationNotMetError, Capybara::ElementNotFound] # Exceptions to capture when retrying inside a retry_on_fail block.
70
71
  config.retry_sleep_duration = 0 # Number of seconds to wait between retries inside a retry_on_fail block.
71
72
  config.server_host = '0.0.0.0' # Host for the Puma server used by Cuprite.
72
73
  config.server_port = nil # Port for the Puma server used by Cuprite.
@@ -243,10 +244,10 @@ RSpec.describe 'Flaky Test', type: :feature do
243
244
  end
244
245
  ```
245
246
 
246
- The above will retry the test if the browser was not able to find the checkbox or the page was not able to find the animated element. The number of retries and sleep duration between retries can be configured through `retry_attempts` and `retry_sleep_duration` configuration options respectively. The default number of retries is 1 and the default sleep duration is 0 seconds. You can also pass them as arguments:
247
+ The above will retry the test if the browser was not able to find the checkbox or the page was not able to find the animated element. The number of retries, exceptions to capture and sleep duration between retries can be configured through `retry_attempts`, `retry_capture_exceptions` and `retry_sleep_duration` configuration options respectively. The default number of retries is 1 and the default sleep duration is 0 seconds. The default exceptions to capture are `RSpec::Expectations::ExpectationNotMetError` and `Capybara::ElementNotFound`. You can also pass them as arguments:
247
248
 
248
249
  ```ruby
249
- retry_on_fail(retry_attempts: 3, retry_sleep_duration: 1) do
250
+ retry_on_fail(retry_attempts: 3, retry_sleep_duration: 1, capture_exceptions: [StandardError]) do
250
251
  expect(page).to have_css('div#animated-element', visible: :visible, wait: 5)
251
252
  end
252
253
  ```
@@ -4,15 +4,16 @@ module IntegrationTestsRails
4
4
  module Capybara
5
5
  # This module provides the main DSL for writing integration tests with Capybara.
6
6
  module Dsl
7
- def retry_on_fail(attempts: nil, sleep_duration: nil)
7
+ def retry_on_fail(attempts: nil, sleep_duration: nil, capture_exceptions: nil)
8
8
  config = IntegrationTestsRails.configuration
9
9
  attempts ||= config.retry_attempts
10
10
  sleep_duration ||= config.retry_sleep_duration
11
+ capture_exceptions ||= config.retry_capture_exceptions
11
12
  counter = 0
12
13
 
13
14
  begin
14
15
  yield
15
- rescue RSpec::Expectations::ExpectationNotMetError, Capybara::ElementNotFound => e
16
+ rescue *capture_exceptions => e
16
17
  counter += 1
17
18
  Util.log("Attempt #{counter} for #{RSpec.current_example.full_description} failed!")
18
19
  raise e if counter > attempts
@@ -40,7 +40,7 @@ module IntegrationTestsRails
40
40
  attr_accessor :source_dir, :output_dir, :backup_dir, :coverage_path, :wait_time, :remote,
41
41
  :chrome_url, :tests_page_html, :window_size, :max_server_retries,
42
42
  :verbose, :timeout, :server_host, :server_port, :puma_threads, :experimental_features,
43
- :retry_attempts, :retry_sleep_duration
43
+ :retry_attempts, :retry_sleep_duration, :retry_capture_exceptions
44
44
 
45
45
  def initialize
46
46
  @backup_dir = 'tmp/js_backup'
@@ -52,6 +52,7 @@ module IntegrationTestsRails
52
52
  @puma_threads = '1:1'
53
53
  @remote = false
54
54
  @retry_attempts = 1
55
+ @retry_capture_exceptions = [RSpec::Expectations::ExpectationNotMetError, Capybara::ElementNotFound]
55
56
  @retry_sleep_duration = 0
56
57
  @server_host = '0.0.0.0' # rubocop:disable Style/IpAddresses
57
58
  @server_port = nil
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IntegrationTestsRails
4
- VERSION = '1.1.1'
4
+ VERSION = '1.1.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: integration-tests-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tien