rspec_html_formatter 0.2.0 → 0.2.1
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 +11 -15
- data/README.md +27 -6
- data/VERSION +1 -1
- data/lib/rspec_html_formatter.rb +17 -19
- data/rspec_html_formatter.gemspec +2 -2
- data/spec/penders_spec.rb +0 -1
- data/spec/rspec_html_formatter_spec.rb +1 -1
- data/spec/test2_spec.rb +10 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 852a43f9fda3ab51fc50d627dbd52c24b0a45dc7
|
4
|
+
data.tar.gz: 5d3b05098ec8b6afda47875a083f1bffd251ad7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fa14ad31349e734e9d7a96861379fa0128ba291c16892d72860f0c726f03ce7776f2db6d9b54a17bdd1e445fa2b7fe5d98e6959ffe8cb3edac1e02a3abecb74
|
7
|
+
data.tar.gz: 366a23ae7c6a347940608d2cd96a6a95fca531833d7f3a0bd9807dce025d83e42dce9ee71afca6d8c87a2395da569456782828a2bd59ed0b31793ce0071fe4dc
|
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', '>= 2.8.0'
|
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", "~> 2.8.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.1.3)
|
15
15
|
faraday (0.9.0)
|
16
16
|
multipart-post (>= 1.2, < 3)
|
17
17
|
git (1.2.8)
|
@@ -55,18 +55,14 @@ 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
|
-
|
66
|
-
rspec-support (~> 3.0.0)
|
67
|
-
rspec-mocks (3.0.3)
|
68
|
-
rspec-support (~> 3.0.0)
|
69
|
-
rspec-support (3.0.3)
|
58
|
+
rspec (2.8.0)
|
59
|
+
rspec-core (~> 2.8.0)
|
60
|
+
rspec-expectations (~> 2.8.0)
|
61
|
+
rspec-mocks (~> 2.8.0)
|
62
|
+
rspec-core (2.8.0)
|
63
|
+
rspec-expectations (2.8.0)
|
64
|
+
diff-lcs (~> 1.1.2)
|
65
|
+
rspec-mocks (2.8.0)
|
70
66
|
thread_safe (0.3.4)
|
71
67
|
tzinfo (1.2.1)
|
72
68
|
thread_safe (~> 0.1)
|
@@ -80,5 +76,5 @@ DEPENDENCIES
|
|
80
76
|
jeweler (~> 2.0.1)
|
81
77
|
rdoc (~> 3.12)
|
82
78
|
rouge (>= 1.6.1)
|
83
|
-
rspec (~>
|
84
|
-
rspec-core (>=
|
79
|
+
rspec (~> 2.8.0)
|
80
|
+
rspec-core (>= 2.8.0)
|
data/README.md
CHANGED
@@ -1,26 +1,25 @@
|
|
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 2.x.x If you want to use it with newer
|
4
|
+
versions of Rspec then you should use the rspec_reports_formatter 0.3.x (master) or use this 0.2.x version with the rspec legacy formatters - see below for instructions.
|
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
|
-
|
10
9
|
## Install
|
11
10
|
|
12
11
|
```
|
13
|
-
gem install rspec_reports_formatter -v 0.
|
12
|
+
gem install rspec_reports_formatter -v 0.2.0
|
14
13
|
```
|
15
14
|
|
16
15
|
ideally just add it to your bundler Gemfile as follows:
|
17
16
|
|
18
17
|
```ruby
|
19
|
-
|
18
|
+
gem 'rspec-legacy_formatters', '~> 0.2.0'
|
20
19
|
```
|
21
20
|
|
22
21
|
## Use
|
23
|
-
When running your rspec tests with rspec
|
22
|
+
When running your rspec tests with rspec 2.8.0 just use the custom formatter:
|
24
23
|
|
25
24
|
This should work:
|
26
25
|
|
@@ -34,6 +33,28 @@ If not you can explicitly add in a require as follows:
|
|
34
33
|
rspec --require rspec_html_formatter.rb --format RspecHtmlFormatter spec
|
35
34
|
```
|
36
35
|
|
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.0'
|
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
|
+
|
37
58
|
![example overview report]
|
38
59
|
(https://raw.githubusercontent.com/kingsleyh/rspec_reports_formatter/master/.README/rspec_reports_overview.png)
|
39
60
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.1
|
data/lib/rspec_html_formatter.rb
CHANGED
@@ -57,9 +57,9 @@ class Example
|
|
57
57
|
@description = example.description
|
58
58
|
@full_description = example.full_description
|
59
59
|
@execution_result = example.execution_result
|
60
|
-
@run_time = (@execution_result
|
61
|
-
@duration = @execution_result
|
62
|
-
@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
|
63
63
|
@metadata = example.metadata
|
64
64
|
@file_path = @metadata[:file_path]
|
65
65
|
@exception = Oopsy.new(example.exception, @file_path)
|
@@ -111,8 +111,6 @@ end
|
|
111
111
|
|
112
112
|
class RspecHtmlFormatter < RSpec::Core::Formatters::BaseFormatter
|
113
113
|
|
114
|
-
RSpec::Core::Formatters.register self, :example_started, :example_passed, :example_failed, :example_pending, :example_group_finished
|
115
|
-
|
116
114
|
REPORT_PATH = './rspec_html_reports'
|
117
115
|
|
118
116
|
def initialize(io_standard_out)
|
@@ -122,7 +120,7 @@ class RspecHtmlFormatter < RSpec::Core::Formatters::BaseFormatter
|
|
122
120
|
@all_groups = {}
|
123
121
|
end
|
124
122
|
|
125
|
-
def example_group_started(
|
123
|
+
def example_group_started(example_group)
|
126
124
|
@example_group = {}
|
127
125
|
@group_examples = []
|
128
126
|
@group_example_count = 0
|
@@ -131,27 +129,27 @@ class RspecHtmlFormatter < RSpec::Core::Formatters::BaseFormatter
|
|
131
129
|
@group_example_pending_count = 0
|
132
130
|
end
|
133
131
|
|
134
|
-
def example_started(
|
132
|
+
def example_started(example)
|
135
133
|
@group_example_count += 1
|
136
134
|
end
|
137
135
|
|
138
|
-
def example_passed(
|
136
|
+
def example_passed(example)
|
139
137
|
@group_example_success_count += 1
|
140
|
-
@group_examples << Example.new(
|
138
|
+
@group_examples << Example.new(example)
|
141
139
|
end
|
142
140
|
|
143
|
-
def example_failed(
|
141
|
+
def example_failed(example)
|
144
142
|
@group_example_failure_count += 1
|
145
|
-
@group_examples << Example.new(
|
143
|
+
@group_examples << Example.new(example)
|
146
144
|
end
|
147
145
|
|
148
|
-
def example_pending(
|
146
|
+
def example_pending(example)
|
149
147
|
@group_example_pending_count += 1
|
150
|
-
@group_examples << Example.new(
|
148
|
+
@group_examples << Example.new(example)
|
151
149
|
end
|
152
150
|
|
153
|
-
def example_group_finished(
|
154
|
-
File.open("#{REPORT_PATH}/#{
|
151
|
+
def example_group_finished(example_group)
|
152
|
+
File.open("#{REPORT_PATH}/#{example_group.description.parameterize}.html", 'w') do |f|
|
155
153
|
|
156
154
|
@passed = @group_example_success_count
|
157
155
|
@failed = @group_example_failure_count
|
@@ -165,7 +163,7 @@ class RspecHtmlFormatter < RSpec::Core::Formatters::BaseFormatter
|
|
165
163
|
duration_keys = duration_keys << 1
|
166
164
|
end
|
167
165
|
|
168
|
-
@title =
|
166
|
+
@title = example_group.description
|
169
167
|
@durations = duration_keys.zip(duration_values)
|
170
168
|
@summary_duration = duration_values.inject(0) { |sum, i| sum + i }.to_s(:rounded, precision: 5)
|
171
169
|
@examples = Specify.new(@group_examples).process
|
@@ -173,8 +171,8 @@ class RspecHtmlFormatter < RSpec::Core::Formatters::BaseFormatter
|
|
173
171
|
class_map = {passed: 'success', failed: 'danger', pending: 'warning'}
|
174
172
|
statuses = @examples.map { |e| e.status }
|
175
173
|
status = statuses.include?('failed') ? 'failed' : (statuses.include?('passed') ? 'passed' : 'pending')
|
176
|
-
@all_groups[
|
177
|
-
group:
|
174
|
+
@all_groups[example_group.description.parameterize] = {
|
175
|
+
group: example_group.description,
|
178
176
|
examples: @examples.size,
|
179
177
|
status: status,
|
180
178
|
klass: class_map[status.to_sym],
|
@@ -192,7 +190,7 @@ class RspecHtmlFormatter < RSpec::Core::Formatters::BaseFormatter
|
|
192
190
|
|
193
191
|
end
|
194
192
|
|
195
|
-
def close
|
193
|
+
def close
|
196
194
|
File.open("#{REPORT_PATH}/overview.html", 'w') do |f|
|
197
195
|
@overview = @all_groups
|
198
196
|
|
@@ -2,11 +2,11 @@
|
|
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.2.
|
5
|
+
# stub: rspec_html_formatter 0.2.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "rspec_html_formatter"
|
9
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.1"
|
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"]
|
data/spec/penders_spec.rb
CHANGED
data/spec/test2_spec.rb
CHANGED
@@ -5,23 +5,22 @@ describe 'The second Test' do
|
|
5
5
|
|
6
6
|
it 'should do cool test stuff' do
|
7
7
|
pending('coming soon')
|
8
|
-
fail
|
9
8
|
end
|
10
9
|
|
11
10
|
it 'should do amazing test stuff' do
|
12
|
-
|
11
|
+
'boats'.should == 'boats'
|
13
12
|
end
|
14
13
|
|
15
14
|
it 'should do superb test stuff' do
|
16
15
|
#-> Given there are some ships
|
17
16
|
#-> When I sail one
|
18
17
|
#-> Then it should go fast
|
19
|
-
|
18
|
+
'ships'.should == 'ships'
|
20
19
|
end
|
21
20
|
|
22
21
|
it 'should do example stuff' do
|
23
|
-
|
24
|
-
|
22
|
+
'apple'.should == 'apple'
|
23
|
+
'pear'.should == 1
|
25
24
|
#-> Given I have some stuff to do
|
26
25
|
#-> And I like to do is wait here for a while
|
27
26
|
#-> Then I do it real good!!
|
@@ -29,29 +28,28 @@ describe 'The second Test' do
|
|
29
28
|
|
30
29
|
it 'should do very cool test stuff' do
|
31
30
|
#-> Given I have some cars
|
32
|
-
|
31
|
+
'cars'.should == 'cars'
|
33
32
|
#-> And I drive one of them
|
34
|
-
|
33
|
+
'diesel'.should == 'diesels'
|
35
34
|
#-> Then I should go fast
|
36
|
-
|
35
|
+
'apple'.should == 'apple'
|
37
36
|
end
|
38
37
|
|
39
38
|
it 'should do very amazing test stuff' do
|
40
|
-
|
39
|
+
'boats'.should == 'boats'
|
41
40
|
end
|
42
41
|
|
43
42
|
it 'should do very superb test stuff' do
|
44
|
-
|
43
|
+
'ships'.should == 'ships'
|
45
44
|
end
|
46
45
|
|
47
46
|
it 'should do very rawesome test stuff' do
|
48
47
|
#-> Given I have some cars
|
49
48
|
pending('give me a woop')
|
50
|
-
fail
|
51
49
|
end
|
52
50
|
|
53
51
|
it 'should do insane and cool test stuff' do
|
54
|
-
|
52
|
+
'ships'.should == 'ships'
|
55
53
|
end
|
56
54
|
|
57
55
|
|