rspec-retry-0.4.3/0000755000004100000410000000000012573567647014053 5ustar www-datawww-datarspec-retry-0.4.3/Rakefile0000644000004100000410000000030312573567647015514 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.4.3/Gemfile0000644000004100000410000000014012573567647015341 0ustar www-datawww-datasource 'https://rubygems.org' # Specify your gem's dependencies in rspec-retry.gemspec gemspec rspec-retry-0.4.3/spec/0000755000004100000410000000000012573567647015005 5ustar www-datawww-datarspec-retry-0.4.3/spec/spec_helper.rb0000644000004100000410000000033012573567647017617 0ustar www-datawww-datarequire 'rspec' 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 end rspec-retry-0.4.3/spec/lib/0000755000004100000410000000000012573567647015553 5ustar www-datawww-datarspec-retry-0.4.3/spec/lib/rspec/0000755000004100000410000000000012573567647016667 5ustar www-datawww-datarspec-retry-0.4.3/spec/lib/rspec/retry_spec.rb0000600000004100000410000000565212573567647021373 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 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", :retry => 2, :exceptions_to_retry => [NameError] do context "the example throws an exception contained in the retry list" do it "retries the maximum number of times" do raise NameError 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 NoMethodError 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 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 end rspec-retry-0.4.3/.travis.yml0000644000004100000410000000020612573567647016162 0ustar www-datawww-datalanguage: ruby rvm: - 2.1 - 2.2 gemfile: - gemfiles/rspec_3.2.gemfile - gemfiles/rspec_3.3.gemfile cache: bundler sudo: false rspec-retry-0.4.3/lib/0000755000004100000410000000000012573567647014621 5ustar www-datawww-datarspec-retry-0.4.3/lib/rspec_ext/0000755000004100000410000000000012573567647016615 5ustar www-datawww-datarspec-retry-0.4.3/lib/rspec_ext/rspec_ext.rb0000644000004100000410000000063012573567647021135 0ustar www-datawww-datamodule RSpec module Core class Example def clear_exception @exception = nil 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.4.3/lib/rspec/0000755000004100000410000000000012573567647015735 5ustar www-datawww-datarspec-retry-0.4.3/lib/rspec/retry/0000755000004100000410000000000012573567647017102 5ustar www-datawww-datarspec-retry-0.4.3/lib/rspec/retry/version.rb0000644000004100000410000000007312573567647021114 0ustar www-datawww-datamodule RSpec class Retry VERSION = "0.4.3" end end rspec-retry-0.4.3/lib/rspec/retry.rb0000600000004100000410000000643212573567647017424 0ustar www-datawww-datarequire 'rspec/core' require 'rspec/retry/version' require 'rspec_ext/rspec_ext' module RSpec class Retry def self.apply 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 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 => [] # context.example is deprecated, but RSpec.current_example is not # available until RSpec 3.0. fetch_current_example = RSpec.respond_to?(:current_example) ? proc { RSpec.current_example } : proc { |context| context.example } config.around(:each) do |ex| example = fetch_current_example.call(self) retry_count = [ ( ENV['RSPEC_RETRY_RETRY_COUNT'] || ex.metadata[:retry] || RSpec.configuration.default_retry_count ).to_i, 1 ].max sleep_interval = ex.metadata[:retry_wait] || RSpec.configuration.default_sleep_interval exceptions_to_retry = ex.metadata[:exceptions_to_retry] || RSpec.configuration.exceptions_to_retry clear_lets = ex.metadata[:clear_lets_on_failure] clear_lets = RSpec.configuration.clear_lets_on_failure if clear_lets.nil? retry_count.times do |i| if RSpec.configuration.verbose_retry? if i > 0 message = "RSpec::Retry: #{RSpec::Retry.ordinalize(i + 1)} try #{example.location}" message = "\n" + message if i == 1 RSpec.configuration.reporter.message(message) end end example.clear_exception ex.run break if example.exception.nil? if exceptions_to_retry.any? break unless exceptions_to_retry.any? do |exception_klass| example.exception.is_a?(exception_klass) end end if RSpec.configuration.verbose_retry? && RSpec.configuration.display_try_failure_messages? if i != (retry_count-1) try_message = "#{RSpec::Retry.ordinalize(i + 1)} Try error in #{example.location}:\n #{example.exception.to_s} \n" RSpec.configuration.reporter.message(try_message) end end self.clear_lets if clear_lets sleep sleep_interval if sleep_interval.to_i > 0 end end end end # borrowed from ActiveSupport::Inflector def self.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 end end RSpec::Retry.apply rspec-retry-0.4.3/gemfiles/0000755000004100000410000000000012573567647015646 5ustar www-datawww-datarspec-retry-0.4.3/gemfiles/rspec_3.3.gemfile.lock0000644000004100000410000000317512573567647021634 0ustar www-datawww-dataPATH remote: ../ specs: rspec-retry (0.4.2) rspec-core GEM remote: https://rubygems.org/ specs: appraisal (2.0.2) bundler rake thor (>= 0.14.0) byebug (4.0.5) columnize (= 0.9.0) coderay (1.1.0) columnize (0.9.0) diff-lcs (1.2.5) ffi (1.9.9) formatador (0.2.5) guard (2.12.7) formatador (>= 0.2.4) listen (>= 2.7, <= 4.0) lumberjack (~> 1.0) nenv (~> 0.1) notiffany (~> 0.0) pry (>= 0.9.12) shellany (~> 0.0) thor (>= 0.18.1) guard-compat (1.2.1) guard-rspec (4.6.0) guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) listen (3.0.0) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) lumberjack (1.0.9) method_source (0.8.2) nenv (0.2.0) notiffany (0.0.6) nenv (~> 0.1) shellany (~> 0.0) pry (0.10.1) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) pry-byebug (3.1.0) byebug (~> 4.0) pry (~> 0.10) rake (10.4.2) rb-fsevent (0.9.5) rb-inotify (0.9.5) ffi (>= 0.5.0) rspec (3.3.0) rspec-core (~> 3.3.0) rspec-expectations (~> 3.3.0) rspec-mocks (~> 3.3.0) rspec-core (3.3.1) rspec-support (~> 3.3.0) rspec-expectations (3.3.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.3.0) rspec-mocks (3.3.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.3.0) rspec-support (3.3.0) shellany (0.0.1) slop (3.6.0) thor (0.19.1) PLATFORMS ruby DEPENDENCIES appraisal guard-rspec pry-byebug rspec (~> 3.3.0) rspec-retry! rspec-retry-0.4.3/gemfiles/rspec_3.2.gemfile.lock0000644000004100000410000000317512573567647021633 0ustar www-datawww-dataPATH remote: ../ specs: rspec-retry (0.4.2) rspec-core GEM remote: https://rubygems.org/ specs: appraisal (2.0.2) bundler rake thor (>= 0.14.0) byebug (4.0.5) columnize (= 0.9.0) coderay (1.1.0) columnize (0.9.0) diff-lcs (1.2.5) ffi (1.9.9) formatador (0.2.5) guard (2.12.7) formatador (>= 0.2.4) listen (>= 2.7, <= 4.0) lumberjack (~> 1.0) nenv (~> 0.1) notiffany (~> 0.0) pry (>= 0.9.12) shellany (~> 0.0) thor (>= 0.18.1) guard-compat (1.2.1) guard-rspec (4.6.0) guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) listen (3.0.0) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) lumberjack (1.0.9) method_source (0.8.2) nenv (0.2.0) notiffany (0.0.6) nenv (~> 0.1) shellany (~> 0.0) pry (0.10.1) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) pry-byebug (3.1.0) byebug (~> 4.0) pry (~> 0.10) rake (10.4.2) rb-fsevent (0.9.5) rb-inotify (0.9.5) ffi (>= 0.5.0) rspec (3.2.0) rspec-core (~> 3.2.0) rspec-expectations (~> 3.2.0) rspec-mocks (~> 3.2.0) rspec-core (3.2.3) rspec-support (~> 3.2.0) rspec-expectations (3.2.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.2.0) rspec-mocks (3.2.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.2.0) rspec-support (3.2.2) shellany (0.0.1) slop (3.6.0) thor (0.19.1) PLATFORMS ruby DEPENDENCIES appraisal guard-rspec pry-byebug rspec (~> 3.2.0) rspec-retry! rspec-retry-0.4.3/gemfiles/rspec_3.2.gemfile0000644000004100000410000000016712573567647020702 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "rspec", "~> 3.2.0" gemspec :path => "../" rspec-retry-0.4.3/gemfiles/rspec_3.3.gemfile0000644000004100000410000000016712573567647020703 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "rspec", "~> 3.3.0" gemspec :path => "../" rspec-retry-0.4.3/metadata.yml0000644000004100000410000000621312573567647016360 0ustar www-datawww-data--- !ruby/object:Gem::Specification name: rspec-retry version: !ruby/object:Gem::Version version: 0.4.3 platform: ruby authors: - Yusuke Mito - Michael Glass autorequire: bindir: bin cert_chain: [] date: 2015-08-30 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rspec-core requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: appraisal requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rspec requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: guard-rspec requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: pry-byebug requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' description: retry intermittently failing rspec examples email: - mike@noredink.com executables: [] extensions: [] extra_rdoc_files: [] files: - ".gitignore" - ".travis.yml" - Appraisals - Gemfile - Guardfile - LICENSE - README.md - Rakefile - changelog.md - gemfiles/rspec_3.2.gemfile - gemfiles/rspec_3.2.gemfile.lock - gemfiles/rspec_3.3.gemfile - gemfiles/rspec_3.3.gemfile.lock - lib/rspec/retry.rb - lib/rspec/retry/version.rb - lib/rspec_ext/rspec_ext.rb - rspec-retry.gemspec - spec/lib/rspec/retry_spec.rb - spec/spec_helper.rb homepage: http://github.com/NoRedInk/rspec-retry licenses: [] metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 2.2.2 signing_key: specification_version: 4 summary: retry intermittently failing rspec examples test_files: - spec/lib/rspec/retry_spec.rb - spec/spec_helper.rb rspec-retry-0.4.3/.gitignore0000644000004100000410000000023212573567647016040 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.4.3/LICENSE0000644000004100000410000000205312573567647015060 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.4.3/changelog.md0000644000004100000410000000132712573567647016327 0ustar www-datawww-data# 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.4.3/rspec-retry.gemspec0000644000004100000410000000207612573567647017704 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.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} gem.add_development_dependency %q{appraisal} gem.add_development_dependency %q{rspec} gem.add_development_dependency %q{guard-rspec} if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2') gem.add_development_dependency %q{pry-debugger} else gem.add_development_dependency %q{pry-byebug} end end rspec-retry-0.4.3/Appraisals0000644000004100000410000000015512573567647016076 0ustar www-datawww-dataappraise 'rspec-3.2' do gem 'rspec', '~> 3.2.0' end appraise 'rspec-3.3' do gem 'rspec', '~> 3.3.0' end rspec-retry-0.4.3/README.md0000644000004100000410000000426312573567647015337 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. ## 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 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 ``` ## 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 - __: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_retry__(default: *[]*) List of exceptions that will trigger a retry (when empty, all exceptions will) ## 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.4.3/Guardfile0000644000004100000410000000030512573567647015676 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