rspec_error_summary 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +43 -0
- data/Rakefile +2 -0
- data/bin/rspec_error_summary +28 -0
- data/lib/rspec_error_summary/version.rb +3 -0
- data/lib/rspec_error_summary.rb +99 -0
- data/rspec_error_summary.gemspec +25 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 36e53006f1753aaf214b962f5e764c5eea08d575
|
4
|
+
data.tar.gz: 68f5ddb87096f1aa2d5eb4af2badbe0e87fbcb06
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 89ce3e4908daa45f7772cd2354d0120d77d3ecb92fd883f905f318ddfdc4cc26fd9a65192732e47bf53d066f5a4f7dbeeb664df1694c6e19701b6df5cf40eeb6
|
7
|
+
data.tar.gz: 2b3e23dc07ec5e3de9ff3b0019c57011d45024efbaa46528a680d220e5545d4c4214577de977f4e2ee3c7802113e101ff69c3e702faea3737a8e794650a66612
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Jose Santiago
|
2
|
+
|
3
|
+
MIT License
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# RSpec Error Summary
|
2
|
+
|
3
|
+
Parses RSpec error output to provide a summary showing what errors were encountered, the number of occurrences per error, and file path and line number locations.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rspec_error_summary'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install rspec_error_summary
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
$ ruby rspec-counter.rb [options]
|
24
|
+
|
25
|
+
-p, --path [ARG]
|
26
|
+
Path to the directory of spec files or individual spec file to be tested
|
27
|
+
|
28
|
+
-s, --search [ARG]
|
29
|
+
Search for a specific string of text in the error message
|
30
|
+
|
31
|
+
-v, --verbose
|
32
|
+
Verbose output. Displays full error messages
|
33
|
+
|
34
|
+
-h, --help
|
35
|
+
Show this message
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
1. Fork it ( https://github.com/[my-github-username]/rspec_error_summary/fork )
|
40
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
41
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
42
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
43
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rspec_error_summary'
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
options = {}
|
6
|
+
OptionParser.new do |opts|
|
7
|
+
opts.banner = "Usage: ruby rspec-counter.rb [options]"
|
8
|
+
|
9
|
+
opts.on("-p [ARG]", "--path [ARG]", "Path to the directory of spec files or individual spec file to be tested") do |p|
|
10
|
+
options[:path] = p
|
11
|
+
end
|
12
|
+
|
13
|
+
opts.on("-s [ARG]", "--search [ARG]", "Search for a specific string of text in the error message") do |s|
|
14
|
+
options[:search] = s
|
15
|
+
end
|
16
|
+
|
17
|
+
options[:verbose] = false
|
18
|
+
opts.on("-v", "--verbose", "Verbose output. Displays full error messages") do |s|
|
19
|
+
options[:verbose] = true
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
23
|
+
puts opts
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
end.parse!
|
27
|
+
|
28
|
+
RspecErrorSummary::Parser.parse_spec_report(options)
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require "rspec_error_summary/version"
|
2
|
+
require 'rspec'
|
3
|
+
require 'colorize'
|
4
|
+
|
5
|
+
module RspecErrorSummary
|
6
|
+
#!/usr/bin/env ruby
|
7
|
+
class Parser
|
8
|
+
|
9
|
+
def self.parse_spec_report(options = {})
|
10
|
+
config = RSpec.configuration
|
11
|
+
|
12
|
+
formatter = RSpec::Core::Formatters::JsonFormatter.new(config.output_stream)
|
13
|
+
|
14
|
+
# create reporter with json formatter
|
15
|
+
reporter = RSpec::Core::Reporter.new(config)
|
16
|
+
config.instance_variable_set(:@reporter, reporter)
|
17
|
+
|
18
|
+
# internal hack
|
19
|
+
# api may not be stable, works on Rspec version 3.1
|
20
|
+
loader = config.send(:formatter_loader)
|
21
|
+
notifications = loader.send(:notifications_for, RSpec::Core::Formatters::JsonFormatter)
|
22
|
+
|
23
|
+
reporter.register_listener(formatter, *notifications)
|
24
|
+
|
25
|
+
path = options[:path] || "./spec/"
|
26
|
+
desired_failure_string = options[:search] || ""
|
27
|
+
be_verbose = options[:verbose] || false
|
28
|
+
|
29
|
+
puts "Running tests... This may take a few minutes..."
|
30
|
+
|
31
|
+
RSpec::Core::Runner.run([path])
|
32
|
+
|
33
|
+
json = formatter.output_hash
|
34
|
+
|
35
|
+
|
36
|
+
failed_tests = json[:examples].select { |test| test[:status] == "failed" && test[:exception][:message].include?(desired_failure_string) }
|
37
|
+
|
38
|
+
failure_messages = failed_tests.map do |test|
|
39
|
+
# Consume the failed tests and provide a more simplified hash with just the required info
|
40
|
+
msg = test[:exception][:message].gsub("\n", " ").gsub(" ", "\n\t\t ").strip
|
41
|
+
test_split = msg.split("#<")
|
42
|
+
|
43
|
+
if(test_split.count > 1 && test_split[0] != "")
|
44
|
+
msg = test_split[0] + "..."
|
45
|
+
end
|
46
|
+
|
47
|
+
{
|
48
|
+
message: msg,
|
49
|
+
file_path: test[:file_path],
|
50
|
+
line_number: test[:line_number]
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
uniq_failure_messages = failure_messages.uniq { |test| test[:message] }
|
55
|
+
uniq_failure_messages_for_output = []
|
56
|
+
uniq_failure_messages.map do |failed_test|
|
57
|
+
matching_failures = failure_messages.select { |test| test[:message] == failed_test[:message] }
|
58
|
+
files = matching_failures.map{ |test| [test[:file_path],test[:line_number]]}
|
59
|
+
files.sort! do |a,b|
|
60
|
+
# Sort by file path first, then line number
|
61
|
+
comp = (a[0] <=> b[0])
|
62
|
+
comp.zero? ? (a[1] <=> b[1]) : comp
|
63
|
+
end
|
64
|
+
|
65
|
+
uniq_failure_messages_for_output << {
|
66
|
+
message: failed_test[:message],
|
67
|
+
count: matching_failures.count,
|
68
|
+
files: files
|
69
|
+
}
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
uniq_failure_messages_for_output.sort!{ |a,b| b[:count].to_i <=> a[:count].to_i }
|
74
|
+
|
75
|
+
# Empty space between any normal RSpec output and our custom text
|
76
|
+
puts " "
|
77
|
+
puts " "
|
78
|
+
puts "Failure message report:"
|
79
|
+
if uniq_failure_messages_for_output.count == 0
|
80
|
+
puts ("Either no failures in the specified tests, or the desired error you entered could not be found in the results").colorize(:green)
|
81
|
+
else
|
82
|
+
uniq_failure_messages_for_output.each do |failure|
|
83
|
+
puts " "
|
84
|
+
count_text = ("#{failure[:count]} #{ failure[:count] > 1 ? 'occurrences' : 'occurrence'}").colorize(:red)
|
85
|
+
msg_text = ((be_verbose ? failure[:message] : failure[:message].truncate(140,separator: /\s/))).colorize(:brown)
|
86
|
+
puts %Q~#{count_text} - #{msg_text}~
|
87
|
+
failure[:files].each do |file|
|
88
|
+
file_text = (file[0]).colorize(:blue)
|
89
|
+
line_text = ("#{file[1].to_s}").colorize(:green)
|
90
|
+
puts "\t\t#{file_text}:#{line_text}"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
puts " "
|
95
|
+
puts " "
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rspec_error_summary/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rspec_error_summary"
|
8
|
+
spec.version = RspecErrorSummary::VERSION
|
9
|
+
spec.authors = ["Jose Santiago"]
|
10
|
+
spec.email = ["contact@josesantiagojr.com"]
|
11
|
+
spec.summary = %q{Summarize RSpec error output}
|
12
|
+
spec.description = %q{Parses RSpec error output to provide a summary showing what errors were encountered, the number of occurrences per error, and file path and line number locations}
|
13
|
+
spec.homepage = "http://github.com/binarydev/rspec_error_summary"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = ["rspec_error_summary"]
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
|
24
|
+
spec.add_dependency 'colorize', '~> 0.7.5'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec_error_summary
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jose Santiago
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.7.5
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.7.5
|
55
|
+
description: Parses RSpec error output to provide a summary showing what errors were
|
56
|
+
encountered, the number of occurrences per error, and file path and line number
|
57
|
+
locations
|
58
|
+
email:
|
59
|
+
- contact@josesantiagojr.com
|
60
|
+
executables:
|
61
|
+
- rspec_error_summary
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- ".gitignore"
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/rspec_error_summary
|
71
|
+
- lib/rspec_error_summary.rb
|
72
|
+
- lib/rspec_error_summary/version.rb
|
73
|
+
- rspec_error_summary.gemspec
|
74
|
+
homepage: http://github.com/binarydev/rspec_error_summary
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.4.5
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Summarize RSpec error output
|
98
|
+
test_files: []
|