rspec-blame 0.1.1 → 0.1.2
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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile +9 -0
- data/README.md +67 -0
- data/Rakefile +5 -0
- data/lib/rspec/blame.rb +3 -6
- data/rspec-blame.gemspec +19 -0
- data/spec/lib/rspec/blame_spec.rb +46 -0
- data/spec/spec_helper.rb +5 -0
- metadata +18 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f2581ea0444b1dbf50a23c0afe9e37342b4b4ea
|
4
|
+
data.tar.gz: a17c38ba2013978c08549b6733cf6400b3c9664f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fab4bc385d851a834e6354b8f8525871c3424538aa9dad1c48c351f4320dd4060d8a0d86de8c95015838aea024818cf63094a308aa534fb5b960d391a9e433f7
|
7
|
+
data.tar.gz: 4abad81e752070ddf79b9361a884bd88ea1a86ac43b7b1c6606c36f1970c69641bff35fa3f07ca85fb1de87743cf7cca5b83b0d7c761a7ac3682363a07338b14
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Gemfile.lock
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# rspec-blame
|
2
|
+
|
3
|
+
rspec-blame provides a Blame RSpec foramtter that outputs the author, commit hash, and
|
4
|
+
commit date for the slowest examples when profiling with RSpec in a **git** project.
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
|
8
|
+
gem 'rspec-blame'
|
9
|
+
|
10
|
+
After including the above line in your Gemfile and running `bundle install`, there are
|
11
|
+
several ways to use the formatter:
|
12
|
+
|
13
|
+
### Command Line
|
14
|
+
|
15
|
+
`rspec --require rspec/blame --profile --format Blame file_spec.rb` or `rspec -r rspec/blame -p -f Blame file_spec.rb`
|
16
|
+
|
17
|
+
### Rake Task
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
require "rspec/blame"
|
21
|
+
require "rspec/core/rake_task"
|
22
|
+
|
23
|
+
RSpec::Core::RakeTask.new(:spec) { |t| t.rspec_opts = "-p -f Blame" }
|
24
|
+
```
|
25
|
+
|
26
|
+
### Configure RSpec
|
27
|
+
|
28
|
+
Add `--require "rspec/blame"`, `--profile`, and `--format Blame` to your `.rspec` file.
|
29
|
+
|
30
|
+
Alternatively, add `require "spec_helper"` to any spec files and add the following to
|
31
|
+
your spec_helper.rb:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
Rspec.configure do |config|
|
35
|
+
config.profile_examples = true
|
36
|
+
config.format = Blame
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
## Output
|
41
|
+
|
42
|
+
```
|
43
|
+
......
|
44
|
+
|
45
|
+
Slowest 6 examples finished in 0.0074 secs (100.0% of total time: 0.0074 secs).
|
46
|
+
Blame dump_profile_slowest_examples prints the number of examples to profile
|
47
|
+
0.0016 secs ./spec/lib/rspec/blame_spec.rb:21 Author: dseeto (i0r2i2s5), Date: 2014-05-28
|
48
|
+
Blame dump_profile_slowest_examples prints summary including author, commit, and date
|
49
|
+
0.0012 secs ./spec/lib/rspec/blame_spec.rb:42 Author: dseeto (i0r2i2s5), Date: 2014-05-28
|
50
|
+
Blame dump_profile_slowest_examples prints the time taken for the slowest tests
|
51
|
+
0.0012 secs ./spec/lib/rspec/blame_spec.rb:25 Author: dseeto (i0r2i2s5), Date: 2014-05-28
|
52
|
+
Blame dump_profile_slowest_examples prints the path to test example
|
53
|
+
0.0012 secs ./spec/lib/rspec/blame_spec.rb:37 Author: dseeto (i0r2i2s5), Date: 2014-05-28
|
54
|
+
Blame dump_profile_slowest_examples prints the percentage taken from the total time
|
55
|
+
0.0011 secs ./spec/lib/rspec/blame_spec.rb:33 Author: dseeto (i0r2i2s5), Date: 2014-05-28
|
56
|
+
Blame dump_profile_slowest_examples prints the name of the examples
|
57
|
+
0.0011 secs ./spec/lib/rspec/blame_spec.rb:29 Author: dseeto (i0r2i2s5), Date: 2014-05-28
|
58
|
+
|
59
|
+
Finished in 0.00792 seconds
|
60
|
+
6 examples, 0 failures
|
61
|
+
```
|
62
|
+
|
63
|
+
## Author
|
64
|
+
|
65
|
+
[David Seeto](https://github.com/dseeto)
|
66
|
+
|
67
|
+
seeto.david@gmail.com
|
data/Rakefile
ADDED
data/lib/rspec/blame.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require "rspec/core/formatters/progress_formatter"
|
2
2
|
|
3
|
-
# Formatter that ouputs
|
4
|
-
# Requirements: Project must be version controlled with git.
|
5
|
-
# Usage: `rspec --profile --formatter Blame rspec_file.rb` or `rspec -p -f Blame rspec_file.rb`
|
6
|
-
# Alternative Usage: RSpec::Core::RakeTask.new(:task) { |t| t.rspec_opts = "-p -f Blame" }
|
3
|
+
# Formatter that ouputs git blame details for the slowest examples.
|
7
4
|
class Blame < RSpec::Core::Formatters::ProgressFormatter
|
8
|
-
#
|
5
|
+
# Appends to ProgressFormatter's output by executing git blame in a subprocess and parsing its output.
|
9
6
|
def dump_profile_slowest_examples
|
10
7
|
number_of_examples_to_profile = RSpec.configuration.profile_examples
|
11
8
|
|
data/rspec-blame.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "rspec-blame"
|
3
|
+
s.version = "0.1.2"
|
4
|
+
s.date = "2014-05-23"
|
5
|
+
s.license = "MIT"
|
6
|
+
|
7
|
+
s.authors = ["David Seeto"]
|
8
|
+
s.email = "seeto.david@gmail.com"
|
9
|
+
s.homepage = "https://github.com/dseeto/rspec-blame"
|
10
|
+
|
11
|
+
s.summary = "Git blame when profiling your slowest RSpec examples."
|
12
|
+
s.description = %q{rspec-blame provides a Blame formatter that outputs git blame details for the slowest examples when profiling with RSpec.}
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
|
15
|
+
s.add_runtime_dependency "rspec-core", ["~> 2.14"]
|
16
|
+
s.add_development_dependency "rake"
|
17
|
+
s.add_development_dependency "rspec"
|
18
|
+
s.add_development_dependency "mocha"
|
19
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "rspec"
|
3
|
+
require "rspec/blame"
|
4
|
+
|
5
|
+
describe Blame do
|
6
|
+
let(:output) { StringIO.new }
|
7
|
+
|
8
|
+
describe "dump_profile_slowest_examples" do
|
9
|
+
before do
|
10
|
+
RSpec.configuration.stubs(:profile_examples).returns(1)
|
11
|
+
group = RSpec::Core::ExampleGroup.describe("group") { example("example") { sleep 0.001 } }
|
12
|
+
group.examples.each { |example| example.execution_result[:run_time] = 0.42 }
|
13
|
+
|
14
|
+
formatter = Blame.new(output)
|
15
|
+
formatter.stubs(:examples).returns(group.examples)
|
16
|
+
formatter.expects(:`).returns("i0r2i2s5 ( dseeto 2014-05-23 10)")
|
17
|
+
|
18
|
+
formatter.dump_profile_slowest_examples
|
19
|
+
end
|
20
|
+
|
21
|
+
it "prints the number of examples to profile" do
|
22
|
+
expect(output.string).to match(/Slowest 1 examples/)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "prints the time taken for the slowest tests" do
|
26
|
+
expect(output.string).to match(/finished in 0\.42 secs/)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "prints the name of the examples" do
|
30
|
+
expect(output.string).to match(/group example/m)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "prints the percentage taken from the total time" do
|
34
|
+
expect(output.string).to match(/100.0% of total time/)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "prints the path to test example" do
|
38
|
+
filename = __FILE__.split(File::SEPARATOR).last
|
39
|
+
expect(output.string).to match(/#{filename}\:11/)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "prints summary including author, commit, and date" do
|
43
|
+
expect(output.string).to match(/Author:.*\(.*\), Date:/)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-blame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Seeto
|
@@ -28,52 +28,59 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: mocha
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description: rspec-blame provides a Blame formatter that outputs
|
70
|
-
|
69
|
+
description: rspec-blame provides a Blame formatter that outputs git blame details
|
70
|
+
for the slowest examples when profiling with RSpec.
|
71
71
|
email: seeto.david@gmail.com
|
72
72
|
executables: []
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
76
80
|
- lib/rspec/blame.rb
|
81
|
+
- rspec-blame.gemspec
|
82
|
+
- spec/lib/rspec/blame_spec.rb
|
83
|
+
- spec/spec_helper.rb
|
77
84
|
homepage: https://github.com/dseeto/rspec-blame
|
78
85
|
licenses:
|
79
86
|
- MIT
|
@@ -84,12 +91,12 @@ require_paths:
|
|
84
91
|
- lib
|
85
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
93
|
requirements:
|
87
|
-
- -
|
94
|
+
- - '>='
|
88
95
|
- !ruby/object:Gem::Version
|
89
96
|
version: '0'
|
90
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
98
|
requirements:
|
92
|
-
- -
|
99
|
+
- - '>='
|
93
100
|
- !ruby/object:Gem::Version
|
94
101
|
version: '0'
|
95
102
|
requirements: []
|