rspec-rerun 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2012, Art.sy Inc., Daniel Doubrovkine and Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,42 @@
1
+ RSpec-Rerun [![Build Status](https://secure.travis-ci.org/dblock/rspec-rerun.png)](http://travis-ci.org/dblock/rspec-rerun)
2
+ ===========
3
+
4
+ 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.
5
+
6
+ Usage
7
+ -----
8
+
9
+ Add `rspec-rerun` to `Gemfile`.
10
+
11
+ ``` ruby
12
+ gem "rspec-rerun"
13
+ ```
14
+
15
+ Require `rspec-rerun` and change the default task in `Rakefile`.
16
+
17
+ ``` ruby
18
+ require 'rspec-rerun'
19
+ task :default => "rspec-rerun:spec"
20
+ ```
21
+
22
+ It might also be a good idea to add `rspec.failures` to `.gitignore`.
23
+
24
+ History
25
+ -------
26
+
27
+ Rerunning failed specs has been a long requested feature in RSpec (see [#456](https://github.com/rspec/rspec-core/issues/456)). A viable approach has been finally implemented by [Matt Mitchell](https://github.com/antifun) in [#596](https://github.com/rspec/rspec-core/pull/596). The infrastructure from that pull request was released with RSpec 2.11, which made rerunning specs finally possible outside of RSpec, described in [this blog post](http://artsy.github.com/blog/2012/05/15/how-to-organize-over-3000-rspec-specs-and-retry-test-failures/).
28
+
29
+ The *rspec-rerun* gem is an attempt to package the parts that didn't make it into rspec-core.
30
+
31
+ Contributing
32
+ ------------
33
+
34
+ Fork the project. Make your feature addition or bug fix with tests. Send a pull request. Bonus points for topic branches.
35
+
36
+ Copyright and License
37
+ ---------------------
38
+
39
+ MIT License, see [LICENSE](https://github.com/dblock/rspec-rerun/blob/master/LICENSE.md) for details.
40
+
41
+ (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)
42
+
@@ -0,0 +1,9 @@
1
+ require 'rspec-rerun/version'
2
+
3
+ require 'rspec-rerun/formatters/failures_formatter.rb'
4
+
5
+ if defined?(Rake)
6
+ Dir[File.join(File.dirname(__FILE__), '../lib/tasks/**/*.rake')].each do |f|
7
+ load f
8
+ end
9
+ end
@@ -0,0 +1,33 @@
1
+ require 'rspec/core/formatters/base_formatter'
2
+
3
+ module RSpec
4
+ module Rerun
5
+ module Formatters
6
+ class FailuresFormatter < RSpec::Core::Formatters::BaseFormatter
7
+
8
+ FILENAME = "rspec.failures"
9
+
10
+ def dump_failures
11
+ return if failed_examples.empty?
12
+ f = File.new(FILENAME, "w+")
13
+ failed_examples.each do |example|
14
+ f.puts retry_command(example)
15
+ end
16
+ f.close
17
+ end
18
+
19
+ def retry_command(example)
20
+ example_name = example.full_description.gsub("\"", "\\\"")
21
+ "-e \"#{example_name}\""
22
+ end
23
+
24
+ def clean!
25
+ if File.exists? FILENAME
26
+ File.delete FILENAME
27
+ end
28
+ end
29
+
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,7 @@
1
+ module RSpec
2
+ module Rerun
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
6
+
7
+
@@ -0,0 +1,33 @@
1
+ desc "Run RSpec examples."
2
+ RSpec::Core::RakeTask.new("rspec-rerun:run") do |t|
3
+ t.pattern = "spec/**/*_spec.rb"
4
+ t.verbose = false
5
+ t.fail_on_error = false
6
+ t.rspec_opts = [
7
+ "--require", File.join(File.dirname(__FILE__), '../rspec-rerun'),
8
+ "--format", "RSpec::Rerun::Formatters::FailuresFormatter",
9
+ File.exist?(".rspec") ? File.read(".rspec").split(/\n+/).map { |l| l.shellsplit } : nil
10
+ ].flatten
11
+ end
12
+
13
+ desc "Re-run failed RSpec examples."
14
+ RSpec::Core::RakeTask.new("rspec-rerun:rerun") do |t|
15
+ t.pattern = "spec/**/*_spec.rb"
16
+ t.verbose = false
17
+ t.fail_on_error = false
18
+ t.rspec_opts = [
19
+ "-O", RSpec::Rerun::Formatters::FailuresFormatter::FILENAME,
20
+ File.exist?(".rspec") ? File.read(".rspec").split(/\n+/).map { |l| l.shellsplit } : nil
21
+ ].flatten
22
+ end
23
+
24
+ desc "Run RSpec code examples."
25
+ task "rspec-rerun:spec" do
26
+ FileUtils.rm_f RSpec::Rerun::Formatters::FailuresFormatter::FILENAME
27
+ Rake::Task["rspec-rerun:run"].execute
28
+ unless $?.success?
29
+ failed_count = File.read(RSpec::Rerun::Formatters::FailuresFormatter::FILENAME).split(/\n+/).count
30
+ puts "[#{Time.now}] Failed, rerunning #{failed_count} failure(s) ..."
31
+ Rake::Task["rspec-rerun:rerun"].execute
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-rerun
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Daniel Doubrovkine
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.11.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.11.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: jeweler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Re-run failed RSpec tests.
79
+ email: dblock@dblock.org
80
+ executables: []
81
+ extensions: []
82
+ extra_rdoc_files:
83
+ - LICENSE.md
84
+ - README.md
85
+ files:
86
+ - lib/rspec-rerun.rb
87
+ - lib/rspec-rerun/formatters/failures_formatter.rb
88
+ - lib/rspec-rerun/version.rb
89
+ - lib/tasks/rspec.rake
90
+ - LICENSE.md
91
+ - README.md
92
+ homepage: http://github.com/dblock/rspec-rerun
93
+ licenses:
94
+ - MIT
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ segments:
106
+ - 0
107
+ hash: 612347219
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 1.8.24
117
+ signing_key:
118
+ specification_version: 3
119
+ summary: Re-run failed RSpec tests.
120
+ test_files: []