rspec-nice-html-formatter 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +32 -0
- data/README.md +10 -0
- data/lib/nice_html_formatter.rb +73 -0
- data/lib/template.html.erb +148 -0
- data/public/example.png +0 -0
- data/rspec-nice-html-formatter.gemspec +20 -0
- data/spec/nice_html_formatter_spec.rb +24 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1671bc33252a3408a2e7b6afa80c5dac64443d25
|
4
|
+
data.tar.gz: 8e9141910735a47124edebddd1800d51be873346
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e11d6c1cd538a76e995c57cccd2026e7bf1852507a3ddd51e42b746e598bbde85398adc46908de2e176fe409e792e4a30fe6301ff969f5257d0fe6ee65d4d742
|
7
|
+
data.tar.gz: 337b15c84520c169660c7d74de643ca5d57dd98add3caa25ae3d2060a7a6f9b934e4448591f4e78545165d43a303b2d5ccdcc5462fcd35d36b361796d9114e4c
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rspec-nice-html-formatter (1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.3)
|
10
|
+
rspec (3.7.0)
|
11
|
+
rspec-core (~> 3.7.0)
|
12
|
+
rspec-expectations (~> 3.7.0)
|
13
|
+
rspec-mocks (~> 3.7.0)
|
14
|
+
rspec-core (3.7.0)
|
15
|
+
rspec-support (~> 3.7.0)
|
16
|
+
rspec-expectations (3.7.0)
|
17
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
18
|
+
rspec-support (~> 3.7.0)
|
19
|
+
rspec-mocks (3.7.0)
|
20
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
21
|
+
rspec-support (~> 3.7.0)
|
22
|
+
rspec-support (3.7.0)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
rspec
|
29
|
+
rspec-nice-html-formatter!
|
30
|
+
|
31
|
+
BUNDLED WITH
|
32
|
+
1.15.4
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require "erb"
|
2
|
+
require "irb"
|
3
|
+
|
4
|
+
class NiceHTMLFormatter
|
5
|
+
include ERB::Util
|
6
|
+
|
7
|
+
RSpec::Core::Formatters.register self,
|
8
|
+
:dump_failures,
|
9
|
+
:dump_pending,
|
10
|
+
:dump_summary,
|
11
|
+
:close,
|
12
|
+
:example_passed,
|
13
|
+
:example_failed,
|
14
|
+
:example_pending,
|
15
|
+
:example_started,
|
16
|
+
:example_group_finished
|
17
|
+
|
18
|
+
TEMPLATE = File.read(File.dirname(__FILE__) + "/template.html.erb").freeze
|
19
|
+
|
20
|
+
def initialize(output)
|
21
|
+
@passed = []
|
22
|
+
@failed = []
|
23
|
+
@pending = []
|
24
|
+
|
25
|
+
@output = output
|
26
|
+
end
|
27
|
+
|
28
|
+
def example_started(notification)
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
def example_group_finished(notification)
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def example_passed(notification)
|
37
|
+
@passed << notification
|
38
|
+
end
|
39
|
+
|
40
|
+
def example_failed(notification)
|
41
|
+
@failed << notification
|
42
|
+
end
|
43
|
+
|
44
|
+
def example_pending(notification)
|
45
|
+
@pending << notification
|
46
|
+
end
|
47
|
+
|
48
|
+
def dump_pending(notification)
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
def dump_failures(notification)
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
def dump_summary(notification)
|
57
|
+
@summary = notification
|
58
|
+
end
|
59
|
+
|
60
|
+
def close(notification)
|
61
|
+
@output << render
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def render
|
67
|
+
ERB.new(TEMPLATE).result(binding)
|
68
|
+
end
|
69
|
+
|
70
|
+
def pluralize(count, string)
|
71
|
+
"#{count} #{string}#{'s' unless count.to_f == 1}"
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%= @title %></title>
|
5
|
+
<style>
|
6
|
+
* {
|
7
|
+
font-family: "Helvetica Neue", sans-serif;
|
8
|
+
color: rgb(6, 7, 8);
|
9
|
+
}
|
10
|
+
|
11
|
+
body {
|
12
|
+
margin-top: 4em;
|
13
|
+
display: flex;
|
14
|
+
align-items: center;
|
15
|
+
justify-content: center;
|
16
|
+
flex-direction: column;
|
17
|
+
}
|
18
|
+
|
19
|
+
ol {
|
20
|
+
list-style: none;
|
21
|
+
margin-bottom: 4em;
|
22
|
+
}
|
23
|
+
|
24
|
+
ol.backtrace {
|
25
|
+
margin-bottom: 0;
|
26
|
+
padding: 1em;
|
27
|
+
}
|
28
|
+
|
29
|
+
ol.backtrace li {
|
30
|
+
color: orangered;
|
31
|
+
line-height: 1.5em;
|
32
|
+
}
|
33
|
+
|
34
|
+
ol.backtrace li.exception {
|
35
|
+
font-weight: 600;
|
36
|
+
}
|
37
|
+
|
38
|
+
button {
|
39
|
+
font-weight: bold;
|
40
|
+
color: yellowgreen;
|
41
|
+
cursor: pointer;
|
42
|
+
border: 1px solid;
|
43
|
+
border-radius: 1em;
|
44
|
+
margin: 0 0.5em;
|
45
|
+
position: relative;
|
46
|
+
top: -2px;
|
47
|
+
}
|
48
|
+
|
49
|
+
.count {
|
50
|
+
font-weight: 600;
|
51
|
+
font-size: 1.5em;
|
52
|
+
margin-bottom: 0.5em;
|
53
|
+
}
|
54
|
+
|
55
|
+
.count button {
|
56
|
+
position: relative;
|
57
|
+
top: -5px;
|
58
|
+
}
|
59
|
+
|
60
|
+
#copy-all {
|
61
|
+
opacity: 0;
|
62
|
+
}
|
63
|
+
|
64
|
+
ol li {
|
65
|
+
padding-left: 1em;
|
66
|
+
}
|
67
|
+
|
68
|
+
.path {
|
69
|
+
position: absolute;
|
70
|
+
top: -100em;
|
71
|
+
left: -100em;
|
72
|
+
opacity: 0;
|
73
|
+
}
|
74
|
+
|
75
|
+
#summary {
|
76
|
+
opacity: 0.5;
|
77
|
+
margin-bottom: 20px;
|
78
|
+
}
|
79
|
+
</style>
|
80
|
+
</head>
|
81
|
+
<body>
|
82
|
+
<div id="summary">
|
83
|
+
<%= @summary.totals_line %> in <%= @summary.duration.round(2) %> seconds
|
84
|
+
</div>
|
85
|
+
<div id="results">
|
86
|
+
<ol>
|
87
|
+
<div class="count">
|
88
|
+
<%= pluralize(@failed.length, "Test") %> Failed
|
89
|
+
<button id="copy-all-button">Copy All</button>
|
90
|
+
</div>
|
91
|
+
<% @failed.each do |failure| %>
|
92
|
+
<li class="rerun">
|
93
|
+
🔥<button>Copy</button><span><%= h failure.example.full_description %></span>
|
94
|
+
<span class="path">
|
95
|
+
bundle exec rspec <%= h failure.example.rerun_argument%>
|
96
|
+
</span>
|
97
|
+
<ol class="backtrace">
|
98
|
+
<li class="exception"><%= failure.exception %></li>
|
99
|
+
<% failure.formatted_backtrace.each do |line| %>
|
100
|
+
<li>
|
101
|
+
<%= h line %>
|
102
|
+
</li>
|
103
|
+
<% end %>
|
104
|
+
</ol>
|
105
|
+
</li>
|
106
|
+
<% end %>
|
107
|
+
</ol>
|
108
|
+
<ol>
|
109
|
+
<div class="count"><%= pluralize(@pending.length, "Test") %> Pending</div>
|
110
|
+
<% @pending.each do |pending| %>
|
111
|
+
<li>☔️ <%= h pending.example.full_description %></li>
|
112
|
+
<% end %>
|
113
|
+
</ol>
|
114
|
+
<ol>
|
115
|
+
<div class="count"><%= pluralize(@passed.length, "Test") %> Passed</div>
|
116
|
+
<% @passed.each do |success| %>
|
117
|
+
<li>🌈 <%= h success.example.full_description %></li>
|
118
|
+
<% end %>
|
119
|
+
</ol>
|
120
|
+
</div>
|
121
|
+
<div id="copy-all">
|
122
|
+
bundle exec rspec <%= h @failed.map { |failure| failure.example.rerun_argument }.join(" ") %>
|
123
|
+
</div>
|
124
|
+
<script>
|
125
|
+
var copy = function(element) {
|
126
|
+
var range = document.createRange();
|
127
|
+
range.selectNodeContents(element);
|
128
|
+
|
129
|
+
var selection = document.getSelection();
|
130
|
+
selection.removeAllRanges();
|
131
|
+
selection.addRange(range);
|
132
|
+
document.execCommand("copy");
|
133
|
+
}
|
134
|
+
|
135
|
+
document.querySelectorAll(".rerun button").forEach(function(node) {
|
136
|
+
node.addEventListener("click", function() {
|
137
|
+
copy(node.parentNode.querySelector(".path"));
|
138
|
+
});
|
139
|
+
});
|
140
|
+
|
141
|
+
document.querySelectorAll("#copy-all-button").forEach(function(node) {
|
142
|
+
node.addEventListener("click", function() {
|
143
|
+
copy(document.querySelector("#copy-all"));
|
144
|
+
});
|
145
|
+
});
|
146
|
+
</script>
|
147
|
+
</body>
|
148
|
+
</html>
|
data/public/example.png
ADDED
Binary file
|
@@ -0,0 +1,20 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "rspec-nice-html-formatter"
|
6
|
+
spec.version = "1.0"
|
7
|
+
spec.authors = ["ecin"]
|
8
|
+
spec.email = ["ecin@copypastel.com"]
|
9
|
+
spec.description = "A nice HTML formatter for your RSpec tests 🌈"
|
10
|
+
spec.summary = "Output your RSpec test results to a pretty HTML page for all to enjoy."
|
11
|
+
spec.homepage = "https://github.com/ecin/rspec-nice-html-formatter"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split($/)
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "rspec"
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "rspec"
|
2
|
+
|
3
|
+
require "nice_html_formatter"
|
4
|
+
|
5
|
+
RSpec.describe NiceHTMLFormatter do
|
6
|
+
|
7
|
+
it "passes" do
|
8
|
+
expect(true).to eql(true)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "fails" do
|
12
|
+
expect(true).to eql(false)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "fails again" do
|
16
|
+
raise RuntimeError
|
17
|
+
end
|
18
|
+
|
19
|
+
it "is pending"
|
20
|
+
|
21
|
+
xit "is disabled" do
|
22
|
+
expect(true).to eql(false)
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-nice-html-formatter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ecin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-12-28 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: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: "A nice HTML formatter for your RSpec tests \U0001F308"
|
28
|
+
email:
|
29
|
+
- ecin@copypastel.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- Gemfile
|
35
|
+
- Gemfile.lock
|
36
|
+
- README.md
|
37
|
+
- lib/nice_html_formatter.rb
|
38
|
+
- lib/template.html.erb
|
39
|
+
- public/example.png
|
40
|
+
- rspec-nice-html-formatter.gemspec
|
41
|
+
- spec/nice_html_formatter_spec.rb
|
42
|
+
homepage: https://github.com/ecin/rspec-nice-html-formatter
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata: {}
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 2.6.12
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: Output your RSpec test results to a pretty HTML page for all to enjoy.
|
66
|
+
test_files:
|
67
|
+
- spec/nice_html_formatter_spec.rb
|