rspec-redo 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +84 -0
- data/Rakefile +10 -0
- data/bin/rspec-redo +4 -0
- data/lib/rspec-redo/rake_task.rb +42 -0
- data/lib/rspec-redo/runner.rb +56 -0
- data/lib/rspec-redo/version.rb +3 -0
- data/rspec-redo.gemspec +27 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6e5da77ce68d89df82c445a848fbbc87f9234a06
|
4
|
+
data.tar.gz: 3f21197b1b80652ef9b19ff157319ac154564e04
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 500af6d6a179a05115ee4c8503f7289e0f5075c3ff7e412045930726cedf733323ecae7d5f38173f7dd0ce210fad636aca5c200b4cc16190f3e8db63278b9f22
|
7
|
+
data.tar.gz: 9b612e79d7390352ab55f1e57c15bb7cc2fd9010989b7e5573ae47658348f2f896c13ae92f80a4e38acc9176bd0c09457839c5cf6f3fa04a2db689241f18197d
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Ray Zane
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# RSpec Redo
|
2
|
+
|
3
|
+
In RSpec 3.3, the `--only-failures` option was added. This means you can have RSpec dump the failures to a file, and rerun them.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rspec-redo'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install rspec-redo
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
First, you'll need to tell RSpec where to persist a list of failed examples. To do this, you'll have to add a line to your `spec_helper.rb`. You'll want to add this file to your `.gitignore`.
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
RSpec.configure do |c|
|
27
|
+
c.example_status_persistence_file_path = 'tmp/rspec-failures.txt'
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
Okay, now you're ready. Simply execute:
|
32
|
+
|
33
|
+
```shell
|
34
|
+
$ rspec-redo
|
35
|
+
```
|
36
|
+
|
37
|
+
You can also pass options you'd typically pass to RSpec. For example:
|
38
|
+
|
39
|
+
```shell
|
40
|
+
$ rspec-redo spec/models/person_spec.rb --format doc
|
41
|
+
```
|
42
|
+
|
43
|
+
By default, the program will retry failed specs only once. You can retry multiple times like so:
|
44
|
+
|
45
|
+
```shell
|
46
|
+
$ rspec-redo --retry-count 5
|
47
|
+
```
|
48
|
+
|
49
|
+
## Rake Integration
|
50
|
+
|
51
|
+
RSpec Redo includes a build in Rake task generator. To create a new Rake task, add the following to your Rakefile:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
require 'rspec-redo/rake_task'
|
55
|
+
RSpecRedo::RakeTask.new 'spec:redo'
|
56
|
+
```
|
57
|
+
|
58
|
+
Cool, now you can run:
|
59
|
+
|
60
|
+
```shell
|
61
|
+
$ rake spec:redo
|
62
|
+
```
|
63
|
+
|
64
|
+
You can customize the command by providing a block:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
RSpecRedo::RakeTask.new 'spec:redo:models' do |t|
|
68
|
+
t.pattern = 'spec/models/*_spec.rb'
|
69
|
+
end
|
70
|
+
```
|
71
|
+
|
72
|
+
Read [RSpec's documentation](http://www.rubydoc.info/gems/rspec-core/RSpec/Core/RakeTask) for available options.
|
73
|
+
|
74
|
+
## Contributing
|
75
|
+
|
76
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rspec_redo.
|
77
|
+
|
78
|
+
## Thanks
|
79
|
+
|
80
|
+
Inspired by `rspec-rerun`.
|
81
|
+
|
82
|
+
## License
|
83
|
+
|
84
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec-redo/rake_task'
|
3
|
+
|
4
|
+
RSpecRedo::RakeTask.new
|
5
|
+
|
6
|
+
desc 'Run fixtures with RSpecRedo (used in integration tests)'
|
7
|
+
RSpecRedo::RakeTask.new :fixtures do |t|
|
8
|
+
t.pattern = 'spec/fixtures/*_spec_fixture.rb'
|
9
|
+
t.rspec_opts = ENV['RSPEC_OPTS']
|
10
|
+
end
|
data/bin/rspec-redo
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
|
3
|
+
module RSpecRedo
|
4
|
+
class RakeTask < ::RSpec::Core::RakeTask
|
5
|
+
RSPEC_REDO_PATH = File.expand_path('../../../bin/rspec-redo', __FILE__)
|
6
|
+
|
7
|
+
attr_accessor :retry_count
|
8
|
+
|
9
|
+
def initialize(name = 'spec:redo', *args, &block)
|
10
|
+
@retry_count = ENV['RETRY_COUNT']
|
11
|
+
|
12
|
+
unless ::Rake.application.last_comment
|
13
|
+
desc 'Run RSpec code examples with RSpecRedo'
|
14
|
+
end
|
15
|
+
|
16
|
+
super(name, :retry_count, *args) do |t, args|
|
17
|
+
@retry_count = args.retry_count
|
18
|
+
yield self if block_given?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# @override
|
23
|
+
# Swap out RSpec for the Redo CLI
|
24
|
+
def rspec_path
|
25
|
+
RSPEC_REDO_PATH
|
26
|
+
end
|
27
|
+
|
28
|
+
# @override
|
29
|
+
# Include the retry_count if it's provided
|
30
|
+
def rspec_opts
|
31
|
+
return super unless retry_count
|
32
|
+
[*super, '--retry-count', retry_count]
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
# @override
|
38
|
+
# We don't need to require rspec libs for this command
|
39
|
+
def rspec_load_path
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rspec-redo/rake_task'
|
2
|
+
|
3
|
+
module RSpecRedo
|
4
|
+
class Runner
|
5
|
+
class << self
|
6
|
+
def invoke(args = ARGV.dup)
|
7
|
+
opts = extract!(args)
|
8
|
+
new(args, opts).invoke
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def extract!(args)
|
14
|
+
{}.tap do |opts|
|
15
|
+
if index = args.index('--retry-count')
|
16
|
+
opts['retry-count'] = Integer(args.delete_at(index + 1))
|
17
|
+
args.delete_at(index)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
rescue ArgumentError
|
21
|
+
abort '--retry-count must be an integer'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
attr_accessor :retry_count
|
26
|
+
attr_reader :redo_opts, :rspec_opts, :total_retries
|
27
|
+
|
28
|
+
def initialize(rspec_opts, redo_opts = {})
|
29
|
+
@rspec_opts = rspec_opts
|
30
|
+
@redo_opts = redo_opts
|
31
|
+
@total_retries = @retry_count = redo_opts.fetch('retry-count', 1)
|
32
|
+
end
|
33
|
+
|
34
|
+
def invoke
|
35
|
+
run # Invoke rspec for the first time
|
36
|
+
rerun until $?.success? || retry_count.zero?
|
37
|
+
abort! unless $?.success?
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def run(*extra_opts)
|
43
|
+
system('rspec', *rspec_opts, *extra_opts)
|
44
|
+
end
|
45
|
+
|
46
|
+
def rerun
|
47
|
+
$stderr.puts "*** Failures occurred. Attempting #{retry_count} more time(s)...\n\n"
|
48
|
+
self.retry_count -= 1
|
49
|
+
run '--only-failures'
|
50
|
+
end
|
51
|
+
|
52
|
+
def abort!
|
53
|
+
abort "Failures still occurred after #{total_retries} retries"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/rspec-redo.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rspec-redo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rspec-redo"
|
8
|
+
spec.version = RSpecRedo::VERSION
|
9
|
+
spec.authors = ["Ray Zane"]
|
10
|
+
spec.email = ["ray@promptworks.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Rerun RSpec failures automatically}
|
13
|
+
spec.description = %q{Automatically rerun RSpec failures using RSpec 3.3.0's built-in --only-failures option}
|
14
|
+
spec.homepage = "http://promptworks.com"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'bin'
|
19
|
+
spec.executables = 'rspec-redo'
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_runtime_dependency 'rspec', '>= 3.3.0'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "simplecov"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-redo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ray Zane
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.3.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.3.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Automatically rerun RSpec failures using RSpec 3.3.0's built-in --only-failures
|
70
|
+
option
|
71
|
+
email:
|
72
|
+
- ray@promptworks.com
|
73
|
+
executables:
|
74
|
+
- rspec-redo
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- ".travis.yml"
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/rspec-redo
|
85
|
+
- lib/rspec-redo/rake_task.rb
|
86
|
+
- lib/rspec-redo/runner.rb
|
87
|
+
- lib/rspec-redo/version.rb
|
88
|
+
- rspec-redo.gemspec
|
89
|
+
homepage: http://promptworks.com
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.4.8
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Rerun RSpec failures automatically
|
113
|
+
test_files: []
|