rspec-retry-0.5.7/0000755000004100000410000000000013252761546014045 5ustar www-datawww-datarspec-retry-0.5.7/Rakefile0000644000004100000410000000030313252761546015506 0ustar www-datawww-data#!/usr/bin/env rake require 'bundler/setup' require "bundler/gem_tasks" begin require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) task :default => :spec rescue LoadError end rspec-retry-0.5.7/Gemfile0000644000004100000410000000014013252761546015333 0ustar www-datawww-datasource 'https://rubygems.org' # Specify your gem's dependencies in rspec-retry.gemspec gemspec rspec-retry-0.5.7/spec/0000755000004100000410000000000013252761546014777 5ustar www-datawww-datarspec-retry-0.5.7/spec/spec_helper.rb0000644000004100000410000000077113252761546017622 0ustar www-datawww-datarequire 'rspec' require 'rspec/core/sandbox' require 'rspec/retry' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2') require "pry-debugger" else require "pry-byebug" end RSpec.configure do |config| config.verbose_retry = true config.display_try_failure_messages = true config.around :example do |ex| RSpec::Core::Sandbox.sandboxed do |config| RSpec::Retry.setup ex.run end end config.around :each, :overridden do |ex| ex.run_with_retry retry: 3 end end rspec-retry-0.5.7/spec/lib/0000755000004100000410000000000013252761546015545 5ustar www-datawww-datarspec-retry-0.5.7/spec/lib/rspec/0000755000004100000410000000000013252761546016661 5ustar www-datawww-datarspec-retry-0.5.7/spec/lib/rspec/retry_spec.rb0000644000004100000410000002150013252761546021363 0ustar www-datawww-datarequire 'spec_helper' describe RSpec::Retry do def count @count ||= 0 @count end def count_up @count ||= 0 @count += 1 end def set_expectations(expectations) @expectations = expectations end def shift_expectation @expectations.shift end class RetryError < StandardError; end class RetryChildError < RetryError; end class HardFailError < StandardError; end class HardFailChildError < HardFailError; end class OtherError < StandardError; end class SharedError < StandardError; end before(:all) do ENV.delete('RSPEC_RETRY_RETRY_COUNT') end context 'no retry option' do it 'should work' do expect(true).to be(true) end end context 'with retry option' do before(:each) { count_up } context do before(:all) { set_expectations([false, false, true]) } it 'should run example until :retry times', :retry => 3 do expect(true).to be(shift_expectation) expect(count).to eq(3) end end context do before(:all) { set_expectations([false, true, false]) } it 'should stop retrying if example is succeeded', :retry => 3 do expect(true).to be(shift_expectation) expect(count).to eq(2) end end context 'with :retry => 0' do after(:all) { @@this_ran_once = nil } it 'should still run once', retry: 0 do @@this_ran_once = true end it 'should run have run once' do expect(@@this_ran_once).to be true end end context 'with the environment variable RSPEC_RETRY_RETRY_COUNT' do before(:all) do set_expectations([false, false, true]) ENV['RSPEC_RETRY_RETRY_COUNT'] = '3' end after(:all) do ENV.delete('RSPEC_RETRY_RETRY_COUNT') end it 'should override the retry count set in an example', :retry => 2 do expect(true).to be(shift_expectation) expect(count).to eq(3) end end describe "with a list of exceptions to immediately fail on", :retry => 2, :exceptions_to_hard_fail => [HardFailError] do context "the example throws an exception contained in the hard fail list" do it "does not retry" do expect(count).to be < 2 pending "This should fail with a count of 1: Count was #{count}" raise HardFailError unless count > 1 end end context "the example throws a child of an exception contained in the hard fail list" do it "does not retry" do expect(count).to be < 2 pending "This should fail with a count of 1: Count was #{count}" raise HardFailChildError unless count > 1 end end context "the throws an exception not contained in the hard fail list" do it "retries the maximum number of times" do raise OtherError unless count > 1 expect(count).to eq(2) end end end describe "with a list of exceptions to retry on", :retry => 2, :exceptions_to_retry => [RetryError] do context "the example throws an exception contained in the retry list" do it "retries the maximum number of times" do raise RetryError unless count > 1 expect(count).to eq(2) end end context "the example throws a child of an exception contained in the retry list" do it "retries the maximum number of times" do raise RetryChildError unless count > 1 expect(count).to eq(2) end end context "the example fails (with an exception not in the retry list)" do it "only runs once" do set_expectations([false]) expect(count).to eq(1) end end context 'the example retries exceptions which match with case equality' do class CaseEqualityError < StandardError def self.===(other) # An example of dynamic matching other.message == 'Rescue me!' end end it 'retries the maximum number of times', exceptions_to_retry: [CaseEqualityError] do raise StandardError, 'Rescue me!' unless count > 1 expect(count).to eq(2) end end end describe "with both hard fail and retry list of exceptions", :retry => 2, :exceptions_to_retry => [SharedError, RetryError], :exceptions_to_hard_fail => [SharedError, HardFailError] do context "the exception thrown exists in both lists" do it "does not retry because the hard fail list takes precedence" do expect(count).to be < 2 pending "This should fail with a count of 1: Count was #{count}" raise SharedError unless count > 1 end end context "the example throws an exception contained in the hard fail list" do it "does not retry because the hard fail list takes precedence" do expect(count).to be < 2 pending "This should fail with a count of 1: Count was #{count}" raise HardFailError unless count > 1 end end context "the example throws an exception contained in the retry list" do it "retries the maximum number of times because the hard fail list doesn't affect this exception" do raise RetryError unless count > 1 expect(count).to eq(2) end end context "the example throws an exception contained in neither list" do it "does not retry because the the exception is not in the retry list" do expect(count).to be < 2 pending "This should fail with a count of 1: Count was #{count}" raise OtherError unless count > 1 end end end end describe 'clearing lets' do before(:all) do @control = true end let(:let_based_on_control) { @control } after do @control = false end it 'should clear the let when the test fails so it can be reset', :retry => 2 do expect(let_based_on_control).to be(false) end it 'should not clear the let when the test fails', :retry => 2, :clear_lets_on_failure => false do expect(let_based_on_control).to be(!@control) end end describe 'running example.run_with_retry in an around filter', retry: 2 do before(:each) { count_up } before(:all) do set_expectations([false, false, true]) end it 'allows retry options to be overridden', :overridden do expect(RSpec.current_example.metadata[:retry]).to eq(3) end it 'uses the overridden options', :overridden do expect(true).to be(shift_expectation) expect(count).to eq(3) end end describe 'calling retry_callback between retries', retry: 2 do before(:all) do RSpec.configuration.retry_callback = proc do |example| @retry_callback_called = true @example = example end end after(:all) do RSpec.configuration.retry_callback = nil end context 'if failure' do before(:all) do @retry_callback_called = false @example = nil @retry_attempts = 0 end it 'should call retry callback', with_some: 'metadata' do |example| if @retry_attempts == 0 @retry_attempts += 1 expect(@retry_callback_called).to be(false) expect(@example).to eq(nil) raise "let's retry once!" elsif @retry_attempts > 0 expect(@retry_callback_called).to be(true) expect(@example).to eq(example) expect(@example.metadata[:with_some]).to eq('metadata') end end end context 'does not call retry_callback if no errors' do before(:all) do @retry_callback_called = false @example = nil end after do expect(@retry_callback_called).to be(false) expect(@example).to be_nil end it { true } end end describe 'output in verbose mode' do line_1 = __LINE__ + 8 line_2 = __LINE__ + 11 let(:group) do RSpec.describe 'ExampleGroup', retry: 2 do after do fail 'broken after hook' end it 'passes' do true end it 'fails' do fail 'broken spec' end end end it 'outputs failures correctly' do RSpec.configuration.output_stream = output = StringIO.new RSpec.configuration.verbose_retry = true RSpec.configuration.display_try_failure_messages = true expect { group.run RSpec.configuration.reporter }.to change { output.string }.to a_string_including <<-STRING.gsub(/^\s+\| ?/, '') | 1st Try error in ./spec/lib/rspec/retry_spec.rb:#{line_1}: | broken after hook | | RSpec::Retry: 2nd try ./spec/lib/rspec/retry_spec.rb:#{line_1} | F | 1st Try error in ./spec/lib/rspec/retry_spec.rb:#{line_2}: | broken spec | broken after hook | | RSpec::Retry: 2nd try ./spec/lib/rspec/retry_spec.rb:#{line_2} STRING end end end rspec-retry-0.5.7/.travis.yml0000644000004100000410000000040113252761546016151 0ustar www-datawww-datalanguage: ruby rvm: - 2.1 - 2.2 - 2.3.3 - 2.4.3 - 2.5.0 gemfile: - gemfiles/rspec_3.3.gemfile - gemfiles/rspec_3.4.gemfile - gemfiles/rspec_3.5.gemfile - gemfiles/rspec_3.6.gemfile - gemfiles/rspec_3.7.gemfile cache: bundler sudo: false rspec-retry-0.5.7/lib/0000755000004100000410000000000013252761546014613 5ustar www-datawww-datarspec-retry-0.5.7/lib/rspec_ext/0000755000004100000410000000000013252761546016607 5ustar www-datawww-datarspec-retry-0.5.7/lib/rspec_ext/rspec_ext.rb0000644000004100000410000000106213252761546021127 0ustar www-datawww-datamodule RSpec module Core class Example attr_accessor :attempts def clear_exception @exception = nil end class Procsy def run_with_retry(opts = {}) RSpec::Retry.new(self, opts).run end end end end end module RSpec module Core class ExampleGroup def clear_memoized if respond_to? :__init_memoized, true __init_memoized else @__memoized = nil end end def clear_lets clear_memoized end end end end rspec-retry-0.5.7/lib/rspec/0000755000004100000410000000000013252761546015727 5ustar www-datawww-datarspec-retry-0.5.7/lib/rspec/retry/0000755000004100000410000000000013252761546017074 5ustar www-datawww-datarspec-retry-0.5.7/lib/rspec/retry/formatter.rb0000644000004100000410000000275213252761546021432 0ustar www-datawww-datarequire 'rspec/core/formatters/base_text_formatter' class RSpec::Retry::Formatter < RSpec::Core::Formatters::BaseTextFormatter RSpec::Core::Formatters.register self, :example_passed def initialize(output) super(output) @tries = Hash.new { |h, k| h[k] = { successes: 0, tries: 0 } } end def seed(_); end def message(_message); end def close(_); end def dump_failures(_); end def dump_pending(_); end def dump_summary(notification) summary = "\nRSpec Retry Summary:\n" @tries.each do |key, retry_data| next if retry_data[:successes] < 1 || retry_data[:tries] <= 1 summary += "\t#{key.location}: #{key.full_description}: passed at attempt #{retry_data[:tries]}\n" end retried = @tries.count { |_, v| v[:tries] > 1 && v[:successes] > 0 } summary += "\n\t#{retried} of #{notification.example_count} tests passed with retries.\n" summary += "\t#{notification.failure_count} tests failed all retries.\n" output.puts summary end def example_passed(notification) increment_success notification.example end def retry(example) increment_tries example end private def increment_success(example) # debugger previous = @tries[example] @tries[example] = { successes: previous[:successes] + 1, tries: previous[:tries] + 1 } end def increment_tries(example) # debugger previous = @tries[example] @tries[example] = { successes: previous[:successes], tries: previous[:tries] + 1 } end end rspec-retry-0.5.7/lib/rspec/retry/version.rb0000644000004100000410000000007313252761546021106 0ustar www-datawww-datamodule RSpec class Retry VERSION = "0.5.7" end end rspec-retry-0.5.7/lib/rspec/retry.rb0000644000004100000410000001223213252761546017421 0ustar www-datawww-datarequire 'rspec/core' require 'rspec/retry/version' require 'rspec_ext/rspec_ext' module RSpec class Retry def self.setup RSpec.configure do |config| config.add_setting :verbose_retry, :default => false config.add_setting :default_retry_count, :default => 1 config.add_setting :default_sleep_interval, :default => 0 config.add_setting :clear_lets_on_failure, :default => true config.add_setting :display_try_failure_messages, :default => false # If a list of exceptions is provided and 'retry' > 1, we only retry if # the exception that was raised by the example is NOT in that list. Otherwise # we ignore the 'retry' value and fail immediately. # # If no list of exceptions is provided and 'retry' > 1, we always retry. config.add_setting :exceptions_to_hard_fail, :default => [] # If a list of exceptions is provided and 'retry' > 1, we only retry if # the exception that was raised by the example is in that list. Otherwise # we ignore the 'retry' value and fail immediately. # # If no list of exceptions is provided and 'retry' > 1, we always retry. config.add_setting :exceptions_to_retry, :default => [] # Callback between retries config.add_setting :retry_callback, :default => nil config.around(:each) do |ex| ex.run_with_retry end end end attr_reader :context, :ex def initialize(ex, opts = {}) @ex = ex @ex.metadata.merge!(opts) current_example.attempts ||= 0 end # context.example is deprecated, but RSpec.current_example is not # available until RSpec 3.0. def current_example RSpec.respond_to?(:current_example) ? RSpec.current_example : @ex.example end def retry_count [ ( ENV['RSPEC_RETRY_RETRY_COUNT'] || ex.metadata[:retry] || RSpec.configuration.default_retry_count ).to_i, 1 ].max end def attempts current_example.attempts ||= 0 end def attempts=(val) current_example.attempts = val end def clear_lets !ex.metadata[:clear_lets_on_failure].nil? ? ex.metadata[:clear_lets_on_failure] : RSpec.configuration.clear_lets_on_failure end def sleep_interval ex.metadata[:retry_wait] || RSpec.configuration.default_sleep_interval end def exceptions_to_hard_fail ex.metadata[:exceptions_to_hard_fail] || RSpec.configuration.exceptions_to_hard_fail end def exceptions_to_retry ex.metadata[:exceptions_to_retry] || RSpec.configuration.exceptions_to_retry end def verbose_retry? RSpec.configuration.verbose_retry? end def display_try_failure_messages? RSpec.configuration.display_try_failure_messages? end def run example = current_example loop do if attempts > 0 RSpec.configuration.formatters.each { |f| f.retry(example) if f.respond_to? :retry } if verbose_retry? message = "RSpec::Retry: #{ordinalize(attempts + 1)} try #{example.location}" message = "\n" + message if attempts == 1 RSpec.configuration.reporter.message(message) end end example.clear_exception ex.run self.attempts += 1 break if example.exception.nil? break if attempts >= retry_count if exceptions_to_hard_fail.any? break if exception_exists_in?(exceptions_to_hard_fail, example.exception) end if exceptions_to_retry.any? break unless exception_exists_in?(exceptions_to_retry, example.exception) end if verbose_retry? && display_try_failure_messages? if attempts != retry_count exception_strings = if ::RSpec::Core::MultipleExceptionError::InterfaceTag === example.exception example.exception.all_exceptions.map(&:to_s) else [example.exception.to_s] end try_message = "\n#{ordinalize(attempts)} Try error in #{example.location}:\n#{exception_strings.join "\n"}\n" RSpec.configuration.reporter.message(try_message) end end example.example_group_instance.clear_lets if clear_lets # If the callback is defined, let's call it if RSpec.configuration.retry_callback example.example_group_instance.instance_exec(example, &RSpec.configuration.retry_callback) end sleep sleep_interval if sleep_interval.to_i > 0 end end private # borrowed from ActiveSupport::Inflector def ordinalize(number) if (11..13).include?(number.to_i % 100) "#{number}th" else case number.to_i % 10 when 1; "#{number}st" when 2; "#{number}nd" when 3; "#{number}rd" else "#{number}th" end end end def exception_exists_in?(list, exception) list.any? do |exception_klass| exception.is_a?(exception_klass) || exception_klass === exception end end end end RSpec::Retry.setup rspec-retry-0.5.7/gemfiles/0000755000004100000410000000000013252761546015640 5ustar www-datawww-datarspec-retry-0.5.7/gemfiles/rspec_3.4.gemfile0000644000004100000410000000016413252761546020673 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "rspec", "~> 3.4.0" gemspec path: "../" rspec-retry-0.5.7/gemfiles/rspec_3.3.gemfile.lock0000644000004100000410000000174413252761546021626 0ustar www-datawww-dataPATH remote: .. specs: rspec-retry (0.5.7) rspec-core (> 3.3) GEM remote: https://rubygems.org/ specs: appraisal (2.2.0) bundler rake thor (>= 0.14.0) byebug (9.0.6) coderay (1.1.1) diff-lcs (1.3) method_source (0.8.2) pry (0.10.4) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) pry-byebug (3.4.2) byebug (~> 9.0) pry (~> 0.10) rake (11.3.0) rspec (3.3.0) rspec-core (~> 3.3.0) rspec-expectations (~> 3.3.0) rspec-mocks (~> 3.3.0) rspec-core (3.3.2) rspec-support (~> 3.3.0) rspec-expectations (3.3.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.3.0) rspec-mocks (3.3.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.3.0) rspec-support (3.3.0) slop (3.6.0) thor (0.20.0) PLATFORMS ruby DEPENDENCIES appraisal byebug (~> 9.0.6) pry-byebug rspec (~> 3.3.0) rspec-retry! BUNDLED WITH 1.16.1 rspec-retry-0.5.7/gemfiles/rspec_3.7.gemfile0000644000004100000410000000016413252761546020676 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "rspec", "~> 3.7.0" gemspec path: "../" rspec-retry-0.5.7/gemfiles/rspec_3.4.gemfile.lock0000644000004100000410000000174413252761546021627 0ustar www-datawww-dataPATH remote: .. specs: rspec-retry (0.5.7) rspec-core (> 3.3) GEM remote: https://rubygems.org/ specs: appraisal (2.2.0) bundler rake thor (>= 0.14.0) byebug (9.0.6) coderay (1.1.1) diff-lcs (1.3) method_source (0.8.2) pry (0.10.4) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) pry-byebug (3.4.2) byebug (~> 9.0) pry (~> 0.10) rake (12.0.0) rspec (3.4.0) rspec-core (~> 3.4.0) rspec-expectations (~> 3.4.0) rspec-mocks (~> 3.4.0) rspec-core (3.4.4) rspec-support (~> 3.4.0) rspec-expectations (3.4.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.4.0) rspec-mocks (3.4.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.4.0) rspec-support (3.4.1) slop (3.6.0) thor (0.20.0) PLATFORMS ruby DEPENDENCIES appraisal byebug (~> 9.0.6) pry-byebug rspec (~> 3.4.0) rspec-retry! BUNDLED WITH 1.16.1 rspec-retry-0.5.7/gemfiles/rspec_3.5.gemfile.lock0000644000004100000410000000174413252761546021630 0ustar www-datawww-dataPATH remote: .. specs: rspec-retry (0.5.7) rspec-core (> 3.3) GEM remote: https://rubygems.org/ specs: appraisal (2.2.0) bundler rake thor (>= 0.14.0) byebug (9.0.6) coderay (1.1.1) diff-lcs (1.3) method_source (0.8.2) pry (0.10.4) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) pry-byebug (3.4.2) byebug (~> 9.0) pry (~> 0.10) rake (12.0.0) rspec (3.5.0) rspec-core (~> 3.5.0) rspec-expectations (~> 3.5.0) rspec-mocks (~> 3.5.0) rspec-core (3.5.4) rspec-support (~> 3.5.0) rspec-expectations (3.5.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.5.0) rspec-mocks (3.5.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.5.0) rspec-support (3.5.0) slop (3.6.0) thor (0.20.0) PLATFORMS ruby DEPENDENCIES appraisal byebug (~> 9.0.6) pry-byebug rspec (~> 3.5.0) rspec-retry! BUNDLED WITH 1.16.1 rspec-retry-0.5.7/gemfiles/rspec_3.7.gemfile.lock0000644000004100000410000000170613252761546021630 0ustar www-datawww-dataPATH remote: .. specs: rspec-retry (0.5.7) rspec-core (> 3.3) GEM remote: https://rubygems.org/ specs: appraisal (2.2.0) bundler rake thor (>= 0.14.0) byebug (9.0.6) coderay (1.1.2) diff-lcs (1.3) method_source (0.9.0) pry (0.11.1) coderay (~> 1.1.0) method_source (~> 0.9.0) pry-byebug (3.4.3) byebug (>= 9.0, < 9.1) pry (~> 0.10) rake (12.1.0) rspec (3.7.0) rspec-core (~> 3.7.0) rspec-expectations (~> 3.7.0) rspec-mocks (~> 3.7.0) rspec-core (3.7.0) rspec-support (~> 3.7.0) rspec-expectations (3.7.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.7.0) rspec-mocks (3.7.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.7.0) rspec-support (3.7.0) thor (0.20.0) PLATFORMS ruby DEPENDENCIES appraisal byebug (~> 9.0.6) pry-byebug rspec (~> 3.7.0) rspec-retry! BUNDLED WITH 1.16.1 rspec-retry-0.5.7/gemfiles/rspec_3.5.gemfile0000644000004100000410000000016413252761546020674 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "rspec", "~> 3.5.0" gemspec path: "../" rspec-retry-0.5.7/gemfiles/rspec_3.3.gemfile0000644000004100000410000000016413252761546020672 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "rspec", "~> 3.3.0" gemspec path: "../" rspec-retry-0.5.7/gemfiles/rspec_3.6.gemfile0000644000004100000410000000016413252761546020675 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "rspec", "~> 3.6.0" gemspec path: "../" rspec-retry-0.5.7/gemfiles/rspec_3.6.gemfile.lock0000644000004100000410000000174413252761546021631 0ustar www-datawww-dataPATH remote: .. specs: rspec-retry (0.5.7) rspec-core (> 3.3) GEM remote: https://rubygems.org/ specs: appraisal (2.2.0) bundler rake thor (>= 0.14.0) byebug (9.0.6) coderay (1.1.1) diff-lcs (1.3) method_source (0.8.2) pry (0.10.4) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) pry-byebug (3.4.2) byebug (~> 9.0) pry (~> 0.10) rake (12.0.0) rspec (3.6.0) rspec-core (~> 3.6.0) rspec-expectations (~> 3.6.0) rspec-mocks (~> 3.6.0) rspec-core (3.6.0) rspec-support (~> 3.6.0) rspec-expectations (3.6.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.6.0) rspec-mocks (3.6.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.6.0) rspec-support (3.6.0) slop (3.6.0) thor (0.20.0) PLATFORMS ruby DEPENDENCIES appraisal byebug (~> 9.0.6) pry-byebug rspec (~> 3.6.0) rspec-retry! BUNDLED WITH 1.16.1 rspec-retry-0.5.7/.gitignore0000644000004100000410000000023213252761546016032 0ustar www-datawww-data*.gem *.rbc .bundle .config .yardoc Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp rspec-retry-0.5.7/LICENSE0000644000004100000410000000205313252761546015052 0ustar www-datawww-dataCopyright (c) 2012 Yusuke Mito MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.rspec-retry-0.5.7/changelog.md0000644000004100000410000000400713252761546016317 0ustar www-datawww-data# 0.5.7 - 2018-03-13 ## enhancements remove <3.8 constraint on rspec-core to prevent breaking when rspec-core upgrades (thanks @dthorsen / #89) # 0.5.6 - 2017-10-17 ## enhancements added support for rspec 3.7.0 # 0.5.5 - 2017-08-22 ## enhancements added retry_callback to help with cleanup between runs (thanks @abrom / #80) # 0.5.4 - 2017-05-08 ## enhancements added support for rspec 3.6.0 (thanks @dthorsen / #76) # 0.5.3 - 2017-01-11 ## enhancements printing summary of rspec to output not STDOUT (thanks @trevorcreech / #68) removing some development dependencies # 0.5.2 - 2016-10-03 ## bugfixes supports versions > 3.5.0 (thanks @y-yagi / #65) # 0.5.1 - 2016-9-30 ## enhancements better failure message for multiple failures in one test (thanks @JonRowe / #62) # 0.5.0 - 2016-8-8 drop support for rspec 3.2, added support for 3.4, 3.5 # 0.4.6 - 2016-8-8 ## bugfixes failure message was off by 1 (thanks @anthonywoo, @vgrigoruk / #57) ## enhancements add the `exceptions_to_hard_fail` options (thanks @james-dominy, @ShockwaveNN / #59) add retry reporter & api for accessing retry from reporter (thanks @tdeo / #54) # 0.4.5 - 2015-11-4 ## enhancements retry can be called programmatically (thanks, @dwbutler / #45) # 0.4.4 - 2015-9-9 ## bugfixes fix gem permissions to be readable (thanks @jdelStrother / #42) # 0.4.3 - 2015-8-29 ## bugfixes will retry on children of exceptions in the `exceptions_to_retry` list (thanks @dwbutler! #40, #41) ## enhancements setting `config.display_try_failure_messages` (and `config.verbose_retry`) will spit out some debug information about why an exception is being retried (thanks @mmorast, #24) # 0.4.2 - 2015-7-10 ## bugfixes setting retry to 0 will still run tests (#34) ## enhancements can set env variable RSPEC_RETRY_RETRY_COUNT to override anything specified in code (thanks @sunflat, #28, #36) # 0.4.1 - 2015-7-9 ## bugfixes rspec-retry now supports rspec 3.3. (thanks @eitoball, #32) ## dev changes include travis configuration for testing rspec 3.2.* and 3.3.* (thanks @eitoball, #31) rspec-retry-0.5.7/rspec-retry.gemspec0000644000004100000410000000200413252761546017665 0ustar www-datawww-data# -*- encoding: utf-8 -*- require File.expand_path('../lib/rspec/retry/version', __FILE__) Gem::Specification.new do |gem| gem.authors = ["Yusuke Mito", 'Michael Glass'] gem.email = ["mike@noredink.com"] gem.description = %q{retry intermittently failing rspec examples} gem.summary = %q{retry intermittently failing rspec examples} gem.homepage = "http://github.com/NoRedInk/rspec-retry" gem.license = "MIT" gem.files = `git ls-files`.split($\) gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.name = "rspec-retry" gem.require_paths = ["lib"] gem.version = RSpec::Retry::VERSION gem.add_runtime_dependency(%{rspec-core}, '>3.3') gem.add_development_dependency %q{appraisal} gem.add_development_dependency %q{rspec} gem.add_development_dependency %q{byebug}, '~>9.0.6' # 9.1 deprecates ruby 2.1 gem.add_development_dependency %q{pry-byebug} end rspec-retry-0.5.7/Appraisals0000644000004100000410000000042213252761546016065 0ustar www-datawww-dataappraise 'rspec-3.3' do gem 'rspec', '~> 3.3.0' end appraise 'rspec-3.4' do gem 'rspec', '~> 3.4.0' end appraise 'rspec-3.5' do gem 'rspec', '~> 3.5.0' end appraise 'rspec-3.6' do gem 'rspec', '~> 3.6.0' end appraise 'rspec-3.7' do gem 'rspec', '~> 3.7.0' end rspec-retry-0.5.7/README.md0000644000004100000410000000632713252761546015334 0ustar www-datawww-data# RSpec::Retry ![Build Status](https://secure.travis-ci.org/NoRedInk/rspec-retry.svg?branch=master) RSpec::Retry adds a ``:retry`` option for intermittently failing rspec examples. If an example has the ``:retry`` option, rspec will retry the example the specified number of times until the example succeeds. ### Compatibility | Rspec Version | Rspec-Retry Version | |---------------|---------------------| | > 3.8 | 0.5.7 but untested | | > 3.3, <= 3.8 | 0.5.7             | | 3.2       | 0.4.6             | | 2.14.8       | 0.4.4             | ## Installation Add this line to your application's Gemfile: gem 'rspec-retry' And then execute: $ bundle Or install it yourself as: $ gem install rspec-retry require in ``spec_helper.rb`` ```ruby # spec/spec_helper.rb require 'rspec/retry' RSpec.configure do |config| # show retry status in spec process config.verbose_retry = true # show exception that triggers a retry if verbose_retry is set to true config.display_try_failure_messages = true # run retry only on features config.around :each, :js do |ex| ex.run_with_retry retry: 3 end # callback to be run between retries config.retry_callback = proc do |ex| # run some additional clean up task - can be filtered by example metadata if ex.metadata[:js] Capybara.reset! end end end ``` ## Usage ```ruby it 'should randomly succeed', :retry => 3 do expect(rand(2)).to eq(1) end it 'should succeed after a while', :retry => 3, :retry_wait => 10 do expect(command('service myservice status')).to eq('started') end # run spec (following log is shown if verbose_retry options is true) # RSpec::Retry: 2nd try ./spec/lib/random_spec.rb:49 # RSpec::Retry: 3rd try ./spec/lib/random_spec.rb:49 ``` ### Calling `run_with_retry` programmatically You can call `ex.run_with_retry(opts)` on an individual example. ## Configuration - __:verbose_retry__(default: *false*) Print retry status - __:display_try_failure_messages__ (default: *false*) If verbose retry is enabled, print what reason forced the retry - __:default_retry_count__(default: *1*) If retry count is not set in an example, this value is used by default. Note: If this is changed from the default of 0, all examples will be retried. - __:default_sleep_interval__(default: *0*) Seconds to wait between retries - __:clear_lets_on_failure__(default: *true*) Clear memoized values for ``let``s before retrying - __:exceptions_to_hard_fail__(default: *[]*) List of exceptions that will trigger an immediate test failure without retry. Takes precedence over __:exceptions_to_retry__ - __:exceptions_to_retry__(default: *[]*) List of exceptions that will trigger a retry (when empty, all exceptions will) - __:retry_callback__(default: *nil*) Callback function to be called between retries ## Environment Variables - __RSPEC_RETRY_RETRY_COUNT__ can override the retry counts even if a retry count is set in an example or default_retry_count is set in a configuration. ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Added some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create a pull request rspec-retry-0.5.7/Guardfile0000644000004100000410000000030513252761546015670 0ustar www-datawww-dataguard 'rspec', :version => 2, :cli => '-c -f d' do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec" } end