rspec-rerun 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2012, Art.sy Inc., Daniel Doubrovkine and Contributors
3
+ Copyright (c) 2012-2013, Artsy Inc., Daniel Doubrovkine and Contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Build Status](https://secure.travis-ci.org/dblock/rspec-rerun.png)](http://travis-ci.org/dblock/rspec-rerun)
4
4
 
5
- The **rspec-rerun** gem is a drop-in solution to retry (rerun) failed RSpec examples. It may be useful, for example, with finicky Capybara tests. The strategy to rerun failed specs is to output a file called `rspec.failures` that contains a list of failed examples and to feed that file back to RSpec via `-e`.
5
+ The **rspec-rerun** gem is a drop-in solution to retry (rerun) failed RSpec examples. It may be useful, for example, with finicky Capybara tests. The strategy to rerun failed specs is to output a file called `rspec.failures` that contains a list of failed examples and to feed that file back to RSpec via `-e`.
6
6
 
7
7
  Usage
8
8
  -----
@@ -24,7 +24,22 @@ task :default => "rspec-rerun:spec"
24
24
 
25
25
  Run `rake` or `rake rspec-rerun:spec`. Failed examples will be rerun automatically.
26
26
 
27
- It might also be a good idea to add `rspec.failures` to `.gitignore`.
27
+ Parameters
28
+ ----------
29
+
30
+ The `rspec-rerun:spec` task accepts the following parameters:
31
+
32
+ * `retry_count`: number of retries, defaults to 1, also available by setting
33
+
34
+ You can set the following global environment variables:
35
+
36
+ * `RSPEC_RERUN_RETRY_COUNT`: number of retries, defaults to the value of `retry_count` or 1
37
+ * `RSPEC_RERUN_PATTERN`: spec file pattern, defaults to the value defined by `RSpec::Core::RakeTask`
38
+
39
+ Git Ignore
40
+ ----------
41
+
42
+ A list of failed examples is stored in a file called `rspec.failures`. It might also be a good idea that you add `rspec.failures` to `.gitignore`.
28
43
 
29
44
  History
30
45
  -------
@@ -41,5 +56,5 @@ Copyright and License
41
56
 
42
57
  MIT License, see [LICENSE](https://github.com/dblock/rspec-rerun/blob/master/LICENSE.md) for details.
43
58
 
44
- (c) 2012 [Art.sy Inc.](http://artsy.github.com), [Daniel Doubrovkine](https://github.com/dblock) and [Contributors](https://github.com/dblock/rspec-rerun/blob/master/CHANGELOG.md)
59
+ (c) 2012-2013 [Artsy Inc.](http://artsy.github.com), [Daniel Doubrovkine](https://github.com/dblock) and [Contributors](https://github.com/dblock/rspec-rerun/blob/master/CHANGELOG.md)
45
60
 
@@ -1,6 +1,6 @@
1
1
  module RSpec
2
2
  module Rerun
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
  end
5
5
  end
6
6
 
data/lib/tasks/rspec.rake CHANGED
@@ -2,7 +2,8 @@ require 'rspec/core/rake_task'
2
2
 
3
3
  desc "Run RSpec examples."
4
4
  RSpec::Core::RakeTask.new("rspec-rerun:run") do |t|
5
- t.pattern = "spec/**/*_spec.rb"
5
+ t.pattern = ENV['RSPEC_RERUN_PATTERN'] if ENV['RSPEC_RERUN_PATTERN']
6
+ t.fail_on_error = false
6
7
  t.rspec_opts = [
7
8
  "--require", File.join(File.dirname(__FILE__), '../rspec-rerun'),
8
9
  "--format", "RSpec::Rerun::Formatters::FailuresFormatter",
@@ -12,23 +13,33 @@ end
12
13
 
13
14
  desc "Re-run failed RSpec examples."
14
15
  RSpec::Core::RakeTask.new("rspec-rerun:rerun") do |t|
15
- t.pattern = "spec/**/*_spec.rb"
16
+ t.pattern = ENV['RSPEC_RERUN_PATTERN'] if ENV['RSPEC_RERUN_PATTERN']
17
+ t.fail_on_error = false
16
18
  t.rspec_opts = [
17
19
  "-O", RSpec::Rerun::Formatters::FailuresFormatter::FILENAME,
20
+ "--require", File.join(File.dirname(__FILE__), '../rspec-rerun'),
21
+ "--format", "RSpec::Rerun::Formatters::FailuresFormatter",
18
22
  File.exist?(".rspec") ? File.read(".rspec").split(/\n+/).map { |l| l.shellsplit } : nil
19
23
  ].flatten
20
24
  end
21
25
 
22
26
  desc "Run RSpec code examples."
23
- task "rspec-rerun:spec" do
27
+ task "rspec-rerun:spec", :retry_count do |t, args|
28
+ retry_count = (args[:retry_count] || ENV['RSPEC_RERUN_RETRY_COUNT'] || 1).to_i
29
+ fail "retry count must be >= 1" if retry_count <= 0
24
30
  FileUtils.rm_f RSpec::Rerun::Formatters::FailuresFormatter::FILENAME
25
-
26
- begin
27
- Rake::Task["rspec-rerun:run"].execute
28
- rescue
31
+ Rake::Task["rspec-rerun:run"].execute
32
+ while !$?.success? && retry_count > 0
33
+ retry_count -= 1
29
34
  failed_count = File.read(RSpec::Rerun::Formatters::FailuresFormatter::FILENAME).split(/\n+/).count
30
- puts "[#{Time.now}] Failed, rerunning #{failed_count} failure(s) ..."
31
-
35
+ msg = "[#{Time.now}] Failed, re-running #{failed_count} failure#{failed_count == 1 ? '' : 's'}"
36
+ msg += ", #{retry_count} #{retry_count == 1 ? 'retry' : 'retries'} left" if retry_count > 0
37
+ $stderr.puts "#{msg} ..."
32
38
  Rake::Task["rspec-rerun:rerun"].execute
33
39
  end
40
+ if !$?.success?
41
+ failed_count = File.read(RSpec::Rerun::Formatters::FailuresFormatter::FILENAME).split(/\n+/).count
42
+ $stderr.puts "[#{Time.now}] #{failed_count} failure#{failed_count == 1 ? '' : 's'}."
43
+ fail "#{failed_count} failure#{failed_count == 1 ? '' : 's'}"
44
+ end
34
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rerun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-03 00:00:00.000000000 Z
12
+ date: 2013-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -104,7 +104,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
104
  version: '0'
105
105
  segments:
106
106
  - 0
107
- hash: 669204179948237564
107
+ hash: 1999651866923544881
108
108
  required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  none: false
110
110
  requirements: