rspec-retry-0.2.0/0000755000175000017500000000000012124356132013013 5ustar lunarlunarrspec-retry-0.2.0/metadata.yml0000644000175000017500000000407712124356132015326 0ustar lunarlunar--- !ruby/object:Gem::Specification name: rspec-retry version: !ruby/object:Gem::Version version: 0.2.0 prerelease: platform: ruby authors: - Yusuke Mito autorequire: bindir: bin cert_chain: [] date: 2013-02-11 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rspec requirement: &70095924091300 !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' type: :runtime prerelease: false version_requirements: *70095924091300 - !ruby/object:Gem::Dependency name: guard-rspec requirement: &70095924090880 !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: *70095924090880 - !ruby/object:Gem::Dependency name: pry-debugger requirement: &70095924090460 !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: *70095924090460 description: retry randomly failing example email: - y310.1984@gmail.com executables: [] extensions: [] extra_rdoc_files: [] files: - .gitignore - Gemfile - Guardfile - LICENSE - README.md - Rakefile - 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/y310/rspec-retry licenses: [] post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 1.8.15 signing_key: specification_version: 3 summary: retry randomly failing example test_files: - spec/lib/rspec/retry_spec.rb - spec/spec_helper.rb rspec-retry-0.2.0/spec/0000755000175000017500000000000012124356132013745 5ustar lunarlunarrspec-retry-0.2.0/spec/spec_helper.rb0000644000175000017500000000017412124356132016565 0ustar lunarlunarrequire 'rspec' require 'rspec/retry' require 'pry-debugger' RSpec.configure do |config| config.verbose_retry = true end rspec-retry-0.2.0/spec/lib/0000755000175000017500000000000012124356132014513 5ustar lunarlunarrspec-retry-0.2.0/spec/lib/rspec/0000755000175000017500000000000012124356132015627 5ustar lunarlunarrspec-retry-0.2.0/spec/lib/rspec/retry_spec.rb0000644000175000017500000000270312124356132020335 0ustar lunarlunarrequire '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 context 'no retry option' do it 'should work' do true.should 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 true.should == shift_expectation count.should == 3 end end context do before(:all) { set_expectations([false, true, false]) } it 'should stop retrying if example is succeeded', :retry => 3 do true.should == shift_expectation count.should == 2 end end it 'should success randomly', :retry => 3 do rand(3).should == 1 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 let_based_on_control.should == false end it 'should not clear the let when the test fails', :retry => 2, :clear_lets_on_failure => false do let_based_on_control.should == !@control end end end rspec-retry-0.2.0/rspec-retry.gemspec0000644000175000017500000000146512124356132016645 0ustar lunarlunar# -*- encoding: utf-8 -*- require File.expand_path('../lib/rspec/retry/version', __FILE__) Gem::Specification.new do |gem| gem.authors = ["Yusuke Mito"] gem.email = ["y310.1984@gmail.com"] gem.description = %q{retry randomly failing example} gem.summary = %q{retry randomly failing example} gem.homepage = "http://github.com/y310/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} gem.add_development_dependency %q{guard-rspec} gem.add_development_dependency %q{pry-debugger} end rspec-retry-0.2.0/lib/0000755000175000017500000000000012124356132013561 5ustar lunarlunarrspec-retry-0.2.0/lib/rspec_ext/0000755000175000017500000000000012124356132015555 5ustar lunarlunarrspec-retry-0.2.0/lib/rspec_ext/rspec_ext.rb0000644000175000017500000000037212124356132020100 0ustar lunarlunarmodule RSpec module Core class Example def clear_exception @exception = nil end end end end module RSpec module Core class ExampleGroup def clear_lets @__memoized = {} end end end end rspec-retry-0.2.0/lib/rspec/0000755000175000017500000000000012124356132014675 5ustar lunarlunarrspec-retry-0.2.0/lib/rspec/retry/0000755000175000017500000000000012124356132016042 5ustar lunarlunarrspec-retry-0.2.0/lib/rspec/retry/version.rb0000644000175000017500000000007312124356132020054 0ustar lunarlunarmodule RSpec class Retry VERSION = "0.2.0" end end rspec-retry-0.2.0/lib/rspec/retry.rb0000644000175000017500000000277712124356132016404 0ustar lunarlunarrequire '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 :clear_lets_on_failure, :default => true config.around(:each) do |example| retry_count = example.metadata[:retry] || RSpec.configuration.default_retry_count clear_lets = example.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 example.run break if @example.exception.nil? self.clear_lets if clear_lets 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.2.0/Rakefile0000644000175000017500000000006012124356132014454 0ustar lunarlunar#!/usr/bin/env rake require "bundler/gem_tasks" rspec-retry-0.2.0/README.md0000644000175000017500000000246512124356132014301 0ustar lunarlunar# RSpec::Retry RSpec::Retry adds ``:retry`` option to rspec example. It is for randomly failing example. If example has ``:retry``, rspec retry specified times until success. ## 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| config.verbose_retry = true # show retry status in spec process end ``` ## Usage ```ruby it 'should randomly success', :retry => 3 do rand(2).should == 1 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 - __:default_retry_count__(default: *1*) If retry count is not set in example, this value is used by default - __:clear_lets_on_failure__(default: *true*) Clear memoized value for ``let`` before retrying ## 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 new Pull Request rspec-retry-0.2.0/LICENSE0000644000175000017500000000205312124356132014020 0ustar lunarlunarCopyright (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.2.0/Guardfile0000644000175000017500000000030512124356132014636 0ustar lunarlunarguard '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 rspec-retry-0.2.0/Gemfile0000644000175000017500000000014012124356132014301 0ustar lunarlunarsource 'https://rubygems.org' # Specify your gem's dependencies in rspec-retry.gemspec gemspec rspec-retry-0.2.0/.gitignore0000644000175000017500000000023212124356132015000 0ustar lunarlunar*.gem *.rbc .bundle .config .yardoc Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp