rspec_html_formatter 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +15 -11
- data/README.md +6 -27
- data/VERSION +1 -1
- data/lib/rspec_html_formatter.rb +23 -45
- data/rspec_html_formatter.gemspec +9 -9
- data/spec/penders_spec.rb +1 -0
- data/spec/rspec_html_formatter_spec.rb +1 -1
- data/spec/test2_spec.rb +12 -10
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efdf12a1f84026c3df35a259d0b847a6b5359fca
|
4
|
+
data.tar.gz: 680e387bbd65cefde7d9451501647e0d8d434aa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5ba8437ba3133e9d6b48a4b32e32dafae6a9954e6937da0f5c435a1ea34b439a54fe0cb28329ac5d39bfb914d68e15fa03d4ff4da994c05612a4c3db17f0183
|
7
|
+
data.tar.gz: 4ff194e998df173d1373689d41eae2234f1468f1917ff34243d9c66a38a676888e1249228ae4499fa3b226187e3e4495ebebcee4fb9cb99fe7a7ef38fa74bc1b
|
data/Gemfile
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
# Add dependencies required to use your gem here.
|
3
|
-
gem 'rspec-core', '>=
|
3
|
+
gem 'rspec-core', '>= 3.0.3'
|
4
4
|
gem 'rouge', '>= 1.6.1'
|
5
5
|
gem 'activesupport', '>= 4.1.4'
|
6
6
|
|
7
7
|
# Add dependencies to develop your gem here.
|
8
8
|
# Include everything needed to run rake, tests, features, etc.
|
9
9
|
group :development do
|
10
|
-
gem "rspec", "~>
|
10
|
+
gem "rspec", "~> 3.0.0"
|
11
11
|
gem "rdoc", "~> 3.12"
|
12
12
|
gem "bundler", "~> 1.0"
|
13
13
|
gem "jeweler", "~> 2.0.1"
|
data/Gemfile.lock
CHANGED
@@ -11,7 +11,7 @@ GEM
|
|
11
11
|
builder (3.2.2)
|
12
12
|
descendants_tracker (0.0.4)
|
13
13
|
thread_safe (~> 0.3, >= 0.3.1)
|
14
|
-
diff-lcs (1.
|
14
|
+
diff-lcs (1.2.5)
|
15
15
|
faraday (0.9.0)
|
16
16
|
multipart-post (>= 1.2, < 3)
|
17
17
|
git (1.2.8)
|
@@ -55,14 +55,18 @@ GEM
|
|
55
55
|
rdoc (3.12.2)
|
56
56
|
json (~> 1.4)
|
57
57
|
rouge (1.6.1)
|
58
|
-
rspec (
|
59
|
-
rspec-core (~>
|
60
|
-
rspec-expectations (~>
|
61
|
-
rspec-mocks (~>
|
62
|
-
rspec-core (
|
63
|
-
|
64
|
-
|
65
|
-
|
58
|
+
rspec (3.0.0)
|
59
|
+
rspec-core (~> 3.0.0)
|
60
|
+
rspec-expectations (~> 3.0.0)
|
61
|
+
rspec-mocks (~> 3.0.0)
|
62
|
+
rspec-core (3.0.3)
|
63
|
+
rspec-support (~> 3.0.0)
|
64
|
+
rspec-expectations (3.0.3)
|
65
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
+
rspec-support (~> 3.0.0)
|
67
|
+
rspec-mocks (3.0.3)
|
68
|
+
rspec-support (~> 3.0.0)
|
69
|
+
rspec-support (3.0.3)
|
66
70
|
thread_safe (0.3.4)
|
67
71
|
tzinfo (1.2.1)
|
68
72
|
thread_safe (~> 0.1)
|
@@ -76,5 +80,5 @@ DEPENDENCIES
|
|
76
80
|
jeweler (~> 2.0.1)
|
77
81
|
rdoc (~> 3.12)
|
78
82
|
rouge (>= 1.6.1)
|
79
|
-
rspec (~>
|
80
|
-
rspec-core (>=
|
83
|
+
rspec (~> 3.0.0)
|
84
|
+
rspec-core (>= 3.0.3)
|
data/README.md
CHANGED
@@ -1,25 +1,26 @@
|
|
1
1
|
# Publish pretty [rspec](http://rspec.info/) reports
|
2
2
|
|
3
|
-
This is a ruby Rspec custom formatter which generates pretty html reports showing the results of rspec tests. This gem was build to use Rspec
|
4
|
-
versions of Rspec then you should use the rspec_reports_formatter 0.
|
3
|
+
This is a ruby Rspec custom formatter which generates pretty html reports showing the results of rspec tests. This gem was build to use Rspec 3.x.x If you want to use it with older
|
4
|
+
versions of Rspec then you should use the rspec_reports_formatter 0.2.x (2.8.0 branch)
|
5
5
|
|
6
6
|
* For Rspec 2.x.x please use rspec_reports_formatter version starting with 0.2.x
|
7
7
|
* For Rspec 3.x.x please use the rspec_reports_formatter version starting with 0.3.x
|
8
8
|
|
9
|
+
|
9
10
|
## Install
|
10
11
|
|
11
12
|
```
|
12
|
-
gem install rspec_reports_formatter -v 0.
|
13
|
+
gem install rspec_reports_formatter -v 0.3.0
|
13
14
|
```
|
14
15
|
|
15
16
|
ideally just add it to your bundler Gemfile as follows:
|
16
17
|
|
17
18
|
```ruby
|
18
|
-
|
19
|
+
gem 'rspec_reports_formatter','~> 0.3.0'
|
19
20
|
```
|
20
21
|
|
21
22
|
## Use
|
22
|
-
When running your rspec tests with rspec
|
23
|
+
When running your rspec tests with rspec 3.0.0 just use the custom formatter:
|
23
24
|
|
24
25
|
This should work:
|
25
26
|
|
@@ -33,28 +34,6 @@ If not you can explicitly add in a require as follows:
|
|
33
34
|
rspec --require rspec_html_formatter.rb --format RspecHtmlFormatter spec
|
34
35
|
```
|
35
36
|
|
36
|
-
If you are using a more recent version of Rspec (3.0.0 onwards) but for some reason don't want to use the rspec_reports_formatter v 0.3.x then you must include the legacy formatter gem into your project by adding it to your Gemfile:
|
37
|
-
|
38
|
-
```ruby
|
39
|
-
|
40
|
-
# Your gemfile
|
41
|
-
group :development do
|
42
|
-
gem 'rspec','~> 3.0.0.rc1'
|
43
|
-
gem 'bundler', '~> 1.0'
|
44
|
-
gem 'rspec-legacy_formatters', '~> 0.2.1'
|
45
|
-
gem 'rspec_html_formatter'
|
46
|
-
end
|
47
|
-
|
48
|
-
```
|
49
|
-
|
50
|
-
Then use it at the command line:
|
51
|
-
|
52
|
-
```
|
53
|
-
rspec --require rspec/legacy_formatters -f RspecHtmlFormatter spec
|
54
|
-
```
|
55
|
-
It will probably throw out some deprecation warnings. Sorry. I will probably make a version of this reporting specifically for rspec 3.0.0 and onwards at some point.
|
56
|
-
|
57
|
-
|
58
37
|
![example overview report]
|
59
38
|
(https://raw.githubusercontent.com/kingsleyh/rspec_reports_formatter/master/.README/rspec_reports_overview.png)
|
60
39
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/rspec_html_formatter.rb
CHANGED
@@ -26,34 +26,10 @@ class Oopsy
|
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
-
def os
|
30
|
-
@os ||= (
|
31
|
-
host_os = RbConfig::CONFIG['host_os']
|
32
|
-
case host_os
|
33
|
-
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
34
|
-
:windows
|
35
|
-
when /darwin|mac os/
|
36
|
-
:macosx
|
37
|
-
when /linux/
|
38
|
-
:linux
|
39
|
-
when /solaris|bsd/
|
40
|
-
:unix
|
41
|
-
else
|
42
|
-
raise Exception, "unknown os: #{host_os.inspect}"
|
43
|
-
end
|
44
|
-
)
|
45
|
-
end
|
46
|
-
|
47
29
|
def process_source
|
48
30
|
data = @backtrace_message.split(':')
|
49
|
-
|
50
|
-
|
51
|
-
file_path = data[0] + ':' + data[1]
|
52
|
-
line_number = data[2].to_i
|
53
|
-
else
|
54
|
-
file_path = data.first
|
55
|
-
line_number = data[1].to_i
|
56
|
-
end
|
31
|
+
file_path = data.first
|
32
|
+
line_number = data[1].to_i
|
57
33
|
lines = File.readlines(file_path)
|
58
34
|
start_line = line_number-2
|
59
35
|
end_line = line_number+3
|
@@ -61,8 +37,8 @@ def os
|
|
61
37
|
|
62
38
|
formatter = Rouge::Formatters::HTML.new(css_class: 'highlight', line_numbers: true, start_line: start_line+1)
|
63
39
|
lexer = Rouge::Lexers::Ruby.new
|
64
|
-
formatter.format(lexer.lex(source
|
65
|
-
|
40
|
+
formatter.format(lexer.lex(source))
|
41
|
+
|
66
42
|
end
|
67
43
|
|
68
44
|
def process_message
|
@@ -81,9 +57,9 @@ class Example
|
|
81
57
|
@description = example.description
|
82
58
|
@full_description = example.full_description
|
83
59
|
@execution_result = example.execution_result
|
84
|
-
@run_time = (@execution_result
|
85
|
-
@duration = @execution_result
|
86
|
-
@status = @execution_result
|
60
|
+
@run_time = (@execution_result.run_time).round(5)
|
61
|
+
@duration = @execution_result.run_time.to_s(:rounded, precision: 5)
|
62
|
+
@status = @execution_result.status.to_s
|
87
63
|
@metadata = example.metadata
|
88
64
|
@file_path = @metadata[:file_path]
|
89
65
|
@exception = Oopsy.new(example.exception, @file_path)
|
@@ -135,6 +111,8 @@ end
|
|
135
111
|
|
136
112
|
class RspecHtmlFormatter < RSpec::Core::Formatters::BaseFormatter
|
137
113
|
|
114
|
+
RSpec::Core::Formatters.register self, :example_started, :example_passed, :example_failed, :example_pending, :example_group_finished
|
115
|
+
|
138
116
|
REPORT_PATH = './rspec_html_reports'
|
139
117
|
|
140
118
|
def initialize(io_standard_out)
|
@@ -144,7 +122,7 @@ class RspecHtmlFormatter < RSpec::Core::Formatters::BaseFormatter
|
|
144
122
|
@all_groups = {}
|
145
123
|
end
|
146
124
|
|
147
|
-
def example_group_started(
|
125
|
+
def example_group_started(notification)
|
148
126
|
@example_group = {}
|
149
127
|
@group_examples = []
|
150
128
|
@group_example_count = 0
|
@@ -153,27 +131,27 @@ class RspecHtmlFormatter < RSpec::Core::Formatters::BaseFormatter
|
|
153
131
|
@group_example_pending_count = 0
|
154
132
|
end
|
155
133
|
|
156
|
-
def example_started(
|
134
|
+
def example_started(notification)
|
157
135
|
@group_example_count += 1
|
158
136
|
end
|
159
137
|
|
160
|
-
def example_passed(
|
138
|
+
def example_passed(notification)
|
161
139
|
@group_example_success_count += 1
|
162
|
-
@group_examples << Example.new(example)
|
140
|
+
@group_examples << Example.new(notification.example)
|
163
141
|
end
|
164
142
|
|
165
|
-
def example_failed(
|
143
|
+
def example_failed(notification)
|
166
144
|
@group_example_failure_count += 1
|
167
|
-
@group_examples << Example.new(example)
|
145
|
+
@group_examples << Example.new(notification.example)
|
168
146
|
end
|
169
147
|
|
170
|
-
def example_pending(
|
148
|
+
def example_pending(notification)
|
171
149
|
@group_example_pending_count += 1
|
172
|
-
@group_examples << Example.new(example)
|
150
|
+
@group_examples << Example.new(notification.example)
|
173
151
|
end
|
174
152
|
|
175
|
-
def example_group_finished(
|
176
|
-
File.open("#{REPORT_PATH}/#{
|
153
|
+
def example_group_finished(notification)
|
154
|
+
File.open("#{REPORT_PATH}/#{notification.group.description.parameterize}.html", 'w') do |f|
|
177
155
|
|
178
156
|
@passed = @group_example_success_count
|
179
157
|
@failed = @group_example_failure_count
|
@@ -187,7 +165,7 @@ class RspecHtmlFormatter < RSpec::Core::Formatters::BaseFormatter
|
|
187
165
|
duration_keys = duration_keys << 1
|
188
166
|
end
|
189
167
|
|
190
|
-
@title =
|
168
|
+
@title = notification.group.description
|
191
169
|
@durations = duration_keys.zip(duration_values)
|
192
170
|
@summary_duration = duration_values.inject(0) { |sum, i| sum + i }.to_s(:rounded, precision: 5)
|
193
171
|
@examples = Specify.new(@group_examples).process
|
@@ -195,8 +173,8 @@ class RspecHtmlFormatter < RSpec::Core::Formatters::BaseFormatter
|
|
195
173
|
class_map = {passed: 'success', failed: 'danger', pending: 'warning'}
|
196
174
|
statuses = @examples.map { |e| e.status }
|
197
175
|
status = statuses.include?('failed') ? 'failed' : (statuses.include?('passed') ? 'passed' : 'pending')
|
198
|
-
@all_groups[
|
199
|
-
group:
|
176
|
+
@all_groups[notification.group.description.parameterize] = {
|
177
|
+
group: notification.group.description,
|
200
178
|
examples: @examples.size,
|
201
179
|
status: status,
|
202
180
|
klass: class_map[status.to_sym],
|
@@ -214,7 +192,7 @@ class RspecHtmlFormatter < RSpec::Core::Formatters::BaseFormatter
|
|
214
192
|
|
215
193
|
end
|
216
194
|
|
217
|
-
def close
|
195
|
+
def close(notification)
|
218
196
|
File.open("#{REPORT_PATH}/overview.html", 'w') do |f|
|
219
197
|
@overview = @all_groups
|
220
198
|
|
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: rspec_html_formatter 0.
|
5
|
+
# stub: rspec_html_formatter 0.3.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "rspec_html_formatter"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.3.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Kingsley Hendrickse"]
|
14
|
-
s.date = "2014-
|
14
|
+
s.date = "2014-08-03"
|
15
15
|
s.description = "Rspec custom formatter to generate pretty html results"
|
16
16
|
s.email = "kingsleyhendrickse@me.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -55,27 +55,27 @@ Gem::Specification.new do |s|
|
|
55
55
|
s.specification_version = 4
|
56
56
|
|
57
57
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
58
|
-
s.add_runtime_dependency(%q<rspec-core>, [">=
|
58
|
+
s.add_runtime_dependency(%q<rspec-core>, [">= 3.0.3"])
|
59
59
|
s.add_runtime_dependency(%q<rouge>, [">= 1.6.1"])
|
60
60
|
s.add_runtime_dependency(%q<activesupport>, [">= 4.1.4"])
|
61
|
-
s.add_development_dependency(%q<rspec>, ["~>
|
61
|
+
s.add_development_dependency(%q<rspec>, ["~> 3.0.0"])
|
62
62
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
63
63
|
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
64
64
|
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
65
65
|
else
|
66
|
-
s.add_dependency(%q<rspec-core>, [">=
|
66
|
+
s.add_dependency(%q<rspec-core>, [">= 3.0.3"])
|
67
67
|
s.add_dependency(%q<rouge>, [">= 1.6.1"])
|
68
68
|
s.add_dependency(%q<activesupport>, [">= 4.1.4"])
|
69
|
-
s.add_dependency(%q<rspec>, ["~>
|
69
|
+
s.add_dependency(%q<rspec>, ["~> 3.0.0"])
|
70
70
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
71
71
|
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
72
72
|
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
73
73
|
end
|
74
74
|
else
|
75
|
-
s.add_dependency(%q<rspec-core>, [">=
|
75
|
+
s.add_dependency(%q<rspec-core>, [">= 3.0.3"])
|
76
76
|
s.add_dependency(%q<rouge>, [">= 1.6.1"])
|
77
77
|
s.add_dependency(%q<activesupport>, [">= 4.1.4"])
|
78
|
-
s.add_dependency(%q<rspec>, ["~>
|
78
|
+
s.add_dependency(%q<rspec>, ["~> 3.0.0"])
|
79
79
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
80
80
|
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
81
81
|
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
data/spec/penders_spec.rb
CHANGED
data/spec/test2_spec.rb
CHANGED
@@ -5,22 +5,23 @@ describe 'The second Test' do
|
|
5
5
|
|
6
6
|
it 'should do cool test stuff' do
|
7
7
|
pending('coming soon')
|
8
|
+
fail
|
8
9
|
end
|
9
10
|
|
10
11
|
it 'should do amazing test stuff' do
|
11
|
-
'boats'.
|
12
|
+
expect('boats').to eq 'boats'
|
12
13
|
end
|
13
14
|
|
14
15
|
it 'should do superb test stuff' do
|
15
16
|
#-> Given there are some ships
|
16
17
|
#-> When I sail one
|
17
18
|
#-> Then it should go fast
|
18
|
-
'ships'.
|
19
|
+
expect('ships').to eq 'ships'
|
19
20
|
end
|
20
21
|
|
21
22
|
it 'should do example stuff' do
|
22
|
-
'apple'.
|
23
|
-
'pear'.
|
23
|
+
expect('apple').to eq 'apple'
|
24
|
+
expect('pear').to eq 1
|
24
25
|
#-> Given I have some stuff to do
|
25
26
|
#-> And I like to do is wait here for a while
|
26
27
|
#-> Then I do it real good!!
|
@@ -28,28 +29,29 @@ describe 'The second Test' do
|
|
28
29
|
|
29
30
|
it 'should do very cool test stuff' do
|
30
31
|
#-> Given I have some cars
|
31
|
-
'cars'.
|
32
|
+
expect('cars').to eq 'cars'
|
32
33
|
#-> And I drive one of them
|
33
|
-
'diesel'.
|
34
|
+
expect('diesel').to eq 'diesels'
|
34
35
|
#-> Then I should go fast
|
35
|
-
'apple'.
|
36
|
+
expect('apple').to eq 'apple'
|
36
37
|
end
|
37
38
|
|
38
39
|
it 'should do very amazing test stuff' do
|
39
|
-
'boats'.
|
40
|
+
expect('boats').to eq 'boats'
|
40
41
|
end
|
41
42
|
|
42
43
|
it 'should do very superb test stuff' do
|
43
|
-
'ships'.
|
44
|
+
expect('ships').to eq 'ships'
|
44
45
|
end
|
45
46
|
|
46
47
|
it 'should do very rawesome test stuff' do
|
47
48
|
#-> Given I have some cars
|
48
49
|
pending('give me a woop')
|
50
|
+
fail
|
49
51
|
end
|
50
52
|
|
51
53
|
it 'should do insane and cool test stuff' do
|
52
|
-
'ships'.
|
54
|
+
expect('ships').to eq 'ships'
|
53
55
|
end
|
54
56
|
|
55
57
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_html_formatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kingsley Hendrickse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.0.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.0.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rouge
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 3.0.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
|
-
version:
|
68
|
+
version: 3.0.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rdoc
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|