Use retriable to retry code blocks, not examples

pull/4945/head
Oliver Günther 8 years ago
parent b87e6ef900
commit 8de452b006
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 1
      Gemfile
  2. 2
      Gemfile.lock
  3. 1
      spec/support/capybara.rb
  4. 8
      spec/support/pages/work_packages_table.rb
  5. 8
      spec/support/rspec_retry.rb
  6. 14
      spec/support/work_packages/work_package_field.rb

@ -173,6 +173,7 @@ group :test do
# Retry failures within the same environment
gem 'rspec-retry', '~> 0.5.2'
gem 'retriable', '~> 2.1'
gem 'rspec-example_disabler', git: 'https://github.com/finnlabs/rspec-example_disabler.git'
gem 'rspec-legacy_formatters', '~> 1.0.1', require: false

@ -461,6 +461,7 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
retriable (2.1.0)
roar (1.0.4)
representable (>= 2.0.1, < 2.4.0)
rspec (3.5.0)
@ -668,6 +669,7 @@ DEPENDENCIES
reform (~> 1.2.6)
request_store (~> 1.3.1)
responders (~> 2.3)
retriable (~> 2.1)
roar (~> 1.0.0)
rspec (~> 3.5.0)
rspec-activemodel-mocks (~> 1.0.3)!

@ -1,4 +1,5 @@
require 'capybara/rspec'
require 'capybara-screenshot/rspec'
require 'rack_session_access/capybara'
RSpec.configure do

@ -156,11 +156,13 @@ module Pages
end
def get_filter_name(label)
filter_container = page
.find('.advanced-filters--filter-name', text: label)
.first(:xpath, './..')
Retriable.retriable do
label_field = page.find('.advanced-filters--filter-name', text: label)
filter_container = label_field.find(:xpath, '..')
raise 'Missing ID on Filter (Angular not ready?)' if filter_container['id'].nil?
filter_container['id'].gsub('filter_', '')
end
end
end
end

@ -1,4 +1,5 @@
require 'rspec/retry'
require 'retriable'
##
# Enable specs to mark metadata retry: <count> to retry that given example
@ -16,3 +17,10 @@ RSpec.configure do |config|
# By default, do not retry specs
config.default_retry_count = 0
end
##
# Allow specific code blocks to retry on specific errors
Retriable.configure do |c|
# Three tries in that block
c.tries = 3
end

@ -91,22 +91,16 @@ class WorkPackageField
def update(value, save: true, expect_failure: false)
# Retry to set attributes due to reloading the page after setting
# an attribute, which may cause an input not to open properly.
retries = 0
begin
print_failure = ->() do
$stderr.puts "Failed to set attribute #{property_name}: #{e.message}. Retrying"
end
Retriable.retriable(on_retry: print_failure) do
activate_edition
set_value value
# select fields are saved on change
save! if save && field_type != 'select'
expect_state! open: expect_failure
rescue => e
if retries > 2
raise e
end
$stderr.puts "Failed to set attribute #{property_name}: #{e.message}. Retrying"
retries += 1
sleep 1
retry
end
end

Loading…
Cancel
Save