rspec-html-formatter 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/README.md +10 -3
- data/lib/splithtml_formatter.rb +58 -53
- data/spec/sample_spec.rb +4 -0
- metadata +22 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 982bf172aa7aeaa7696664ed17e1704f81cbf94b
|
4
|
+
data.tar.gz: 01e2b555f5676e2840a0d2377c2eccd12857efd2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2a0cfa23f39c68fb356004edc056581750b29ba67e3c6161174fa13185959702445acef2f75213f765588d69f3806b4cfaf8f52e165bd6995331335f02b28db4
|
7
|
+
data.tar.gz: 18e1c7acbfe7ca13f34cdad6cf2e4d01574f8d956f70f55147f36f3ca3197a9d490b151bca4a25aa4ffe353c7ec547c6a54ef0836ea29291522ea4c78a6f6575
|
data/README.md
CHANGED
@@ -4,11 +4,18 @@ rspec-html-formator
|
|
4
4
|
Extended html formator for rspec. It create seperate html file for each rspec test script.
|
5
5
|
It is useful when you have large number of rspec testcases with different owners.
|
6
6
|
|
7
|
+
### install
|
8
|
+
`gem install rspec-html-formatter`
|
9
|
+
|
7
10
|
### how to use
|
8
11
|
```
|
9
|
-
|
10
|
-
rspec
|
12
|
+
export HTML_REPORTS=/tmp/reports
|
13
|
+
rspec -f SplithtmlFormatter -r splithtml_formatter -r splithtml_printer spec/sample_spec.rb
|
11
14
|
```
|
15
|
+
The log files will be created into $HTML_REPORTS
|
16
|
+
If it is not set, use "`pwd`/spec/reports"
|
12
17
|
|
13
18
|
### Dependence
|
14
|
-
rspec
|
19
|
+
rspec 3 since version 0.0.1
|
20
|
+
|
21
|
+
for rspec 2.14, `gem install rspec-html-formatter -v 0.0.0`
|
data/lib/splithtml_formatter.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'rspec/core/formatters/
|
1
|
+
require 'rspec/core/formatters/base_formatter'
|
2
2
|
|
3
3
|
PREFIX = "spec"
|
4
4
|
|
@@ -18,10 +18,16 @@ class FileOutput
|
|
18
18
|
|
19
19
|
end
|
20
20
|
|
21
|
-
class SplithtmlFormatter < RSpec::Core::Formatters::
|
22
|
-
|
21
|
+
class SplithtmlFormatter < RSpec::Core::Formatters::BaseFormatter
|
22
|
+
|
23
|
+
RSpec::Core::Formatters.register self, :start, :example_group_started, :start_dump,
|
24
|
+
:example_started, :example_passed, :example_failed,
|
25
|
+
:example_pending, :dump_summary
|
26
|
+
|
27
|
+
|
23
28
|
def initialize(output)
|
24
29
|
super(output)
|
30
|
+
@failed_examples = []
|
25
31
|
@example_group_number = 0
|
26
32
|
@example_number = 0
|
27
33
|
@failure_number = 0
|
@@ -70,8 +76,8 @@ public
|
|
70
76
|
super(example_count)
|
71
77
|
end
|
72
78
|
|
73
|
-
def example_group_started(
|
74
|
-
super
|
79
|
+
def example_group_started(notification)
|
80
|
+
super
|
75
81
|
@start_time = Time.now().to_f()
|
76
82
|
@example_number = 0
|
77
83
|
@failure_number = 0
|
@@ -80,40 +86,38 @@ public
|
|
80
86
|
@run_time = 0.0
|
81
87
|
@example_group_red = false
|
82
88
|
@example_group_number += 1
|
83
|
-
test_file_name = File.basename(
|
84
|
-
@printer = new_html(
|
89
|
+
test_file_name = File.basename(notification.group.file_path)
|
90
|
+
@printer = new_html(notification.group.description.to_s)
|
85
91
|
@printer.print_html_start(test_file_name)
|
86
|
-
@printer.print_example_group_start(
|
92
|
+
@printer.print_example_group_start(notification.group.description)
|
87
93
|
@printer.flush()
|
88
94
|
debug_print("start:" + @printer.object_id.to_s)
|
89
95
|
end
|
90
96
|
|
91
|
-
def example_group_finished(
|
92
|
-
super
|
97
|
+
def example_group_finished(notification)
|
98
|
+
super
|
93
99
|
@printer.print_example_group_end()
|
94
|
-
test_file_path = File.expand_path(
|
100
|
+
test_file_path = File.expand_path(notification.group.file_path)
|
95
101
|
@end_time = Time.now().to_f()
|
96
102
|
@printer.print_summary(false, @run_time, @example_number, @failure_number, @pending_number, test_file_path, @start_time, @end_time)
|
97
103
|
@printer.flush()
|
98
104
|
debug_print("finished:" + @printer.object_id.to_s)
|
99
105
|
end
|
100
106
|
|
101
|
-
def example_started(
|
102
|
-
super(example)
|
107
|
+
def example_started(notification)
|
103
108
|
@example_number += 1
|
104
109
|
@printer.print_example_start()
|
105
110
|
end
|
106
111
|
|
107
|
-
def example_passed(
|
112
|
+
def example_passed(passed)
|
108
113
|
@printer.move_progress(100)
|
109
|
-
@printer.print_example_passed( example.description, example.execution_result
|
114
|
+
@printer.print_example_passed( passed.example.description, passed.example.execution_result.run_time )
|
110
115
|
@printer.flush()
|
111
|
-
@run_time += example.execution_result
|
116
|
+
@run_time += passed.example.execution_result.run_time
|
112
117
|
end
|
113
118
|
|
114
|
-
def example_failed(
|
115
|
-
|
116
|
-
|
119
|
+
def example_failed(failure)
|
120
|
+
@failed_examples << failure.example
|
117
121
|
unless @header_red
|
118
122
|
@header_red = true
|
119
123
|
@printer.make_header_red
|
@@ -126,43 +130,44 @@ public
|
|
126
130
|
|
127
131
|
@printer.move_progress(100)
|
128
132
|
|
129
|
-
|
133
|
+
example = failure.example
|
134
|
+
exception = failure.exception
|
130
135
|
exception_details = if exception
|
131
136
|
{
|
132
137
|
:message => exception.message,
|
133
|
-
:backtrace =>
|
138
|
+
:backtrace => failure.formatted_backtrace.join("\n")
|
134
139
|
}
|
135
140
|
else
|
136
141
|
false
|
137
142
|
end
|
138
|
-
|
139
143
|
extra = extra_failure_content(exception)
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
144
|
+
debug_print("extra: #{extra}")
|
145
|
+
@printer.print_example_failed(
|
146
|
+
example.execution_result.pending_fixed,
|
147
|
+
example.description,
|
148
|
+
example.execution_result.run_time,
|
149
|
+
@failed_examples.size,
|
150
|
+
exception_details,
|
151
|
+
(extra == "") ? false : extra,
|
152
|
+
true
|
153
|
+
)
|
151
154
|
@printer.flush()
|
152
155
|
@failure_number += 1
|
153
|
-
@run_time += example.execution_result
|
156
|
+
@run_time += example.execution_result.run_time
|
154
157
|
end
|
155
158
|
|
156
|
-
def example_pending(
|
159
|
+
def example_pending(pending)
|
160
|
+
example = pending.example
|
157
161
|
@printer.make_header_yellow unless @header_red
|
158
162
|
@printer.make_example_group_header_yellow(example_group_number) unless @example_group_red
|
159
163
|
@printer.move_progress(100)
|
160
|
-
@printer.print_example_pending( example.description, example.
|
164
|
+
@printer.print_example_pending( example.description, example.execution_result.pending_message)
|
161
165
|
@printer.flush()
|
162
166
|
@pending_number += 1
|
163
|
-
@run_time += example.execution_result
|
167
|
+
@run_time += example.execution_result.run_time
|
164
168
|
end
|
165
169
|
|
170
|
+
# support for https://github.com/railsware/rspec-example_steps
|
166
171
|
def example_step_started(example, type, message, options)
|
167
172
|
example_started(example)
|
168
173
|
end
|
@@ -187,7 +192,7 @@ public
|
|
187
192
|
|
188
193
|
@printer.move_progress(100)
|
189
194
|
|
190
|
-
exception = example.
|
195
|
+
exception = example.exception
|
191
196
|
exception_details = if exception
|
192
197
|
{
|
193
198
|
:message => exception.message,
|
@@ -198,7 +203,7 @@ public
|
|
198
203
|
end
|
199
204
|
|
200
205
|
@printer.print_example_failed(
|
201
|
-
example.execution_result
|
206
|
+
example.execution_result.pending_fixed,
|
202
207
|
type.to_s().upcase() + ' ' + message,
|
203
208
|
0,
|
204
209
|
@failed_examples.size,
|
@@ -220,24 +225,24 @@ public
|
|
220
225
|
@pending_number += 1
|
221
226
|
end
|
222
227
|
|
223
|
-
def extra_failure_content(
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
228
|
+
def extra_failure_content(failure)
|
229
|
+
RSpec::Support.require_rspec_core "formatters/snippet_extractor"
|
230
|
+
backtrace = failure.exception.backtrace.map {|line| RSpec.configuration.backtrace_formatter.backtrace_line(line)}
|
231
|
+
backtrace.compact!
|
232
|
+
@snippet_extractor ||= RSpec::Core::Formatters::SnippetExtractor.new
|
233
|
+
" <pre class=\"ruby\"><code>#{@snippet_extractor.snippet(backtrace)}</code></pre>"
|
229
234
|
end
|
230
235
|
|
231
|
-
def start_dump
|
232
|
-
end
|
236
|
+
#def start_dump
|
237
|
+
#end
|
233
238
|
|
234
|
-
def dump_failures
|
235
|
-
end
|
239
|
+
#def dump_failures
|
240
|
+
#end
|
236
241
|
|
237
|
-
def dump_pending
|
238
|
-
end
|
242
|
+
#def dump_pending
|
243
|
+
#end
|
239
244
|
|
240
|
-
def dump_summary(duration, example_count, failure_count, pending_count)
|
241
|
-
end
|
245
|
+
#def dump_summary(duration, example_count, failure_count, pending_count)
|
246
|
+
#end
|
242
247
|
|
243
248
|
end
|
data/spec/sample_spec.rb
CHANGED
@@ -18,10 +18,12 @@ describe "Two failed cases test" do
|
|
18
18
|
|
19
19
|
it "failed test1" do
|
20
20
|
puts "this line from failed test1"
|
21
|
+
0/0
|
21
22
|
end
|
22
23
|
|
23
24
|
it "failed test2" do
|
24
25
|
puts "this line from failed test2"
|
26
|
+
0/0
|
25
27
|
end
|
26
28
|
|
27
29
|
it "passed test2" do
|
@@ -72,6 +74,8 @@ describe "Logger test" do
|
|
72
74
|
puts "this line from passed test7"
|
73
75
|
end
|
74
76
|
|
77
|
+
it "pending test1"
|
78
|
+
|
75
79
|
end
|
76
80
|
|
77
81
|
|
metadata
CHANGED
@@ -1,58 +1,51 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-html-formatter
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- chenhaiq
|
8
8
|
- Zhang Yuan
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
date: 2014-09-16 00:00:00 Z
|
12
|
+
date: 2014-09-16 00:00:00.000000000 Z
|
14
13
|
dependencies: []
|
15
|
-
|
16
|
-
|
14
|
+
description: Extended html formator for rspec. It create seperate html file for each
|
15
|
+
rspec test script.
|
17
16
|
email: chocean@gmail.com
|
18
17
|
executables: []
|
19
|
-
|
20
18
|
extensions: []
|
21
|
-
|
22
19
|
extra_rdoc_files: []
|
23
|
-
|
24
|
-
|
25
|
-
- .gitignore
|
20
|
+
files:
|
21
|
+
- ".gitignore"
|
26
22
|
- LICENSE
|
27
23
|
- README.md
|
28
24
|
- lib/splithtml_formatter.rb
|
29
25
|
- lib/splithtml_printer.rb
|
30
26
|
- spec/sample_spec.rb
|
31
27
|
homepage: https://github.com/chenhaiq/rspec-html-formatter
|
32
|
-
licenses:
|
28
|
+
licenses:
|
33
29
|
- MIT
|
34
30
|
metadata: {}
|
35
|
-
|
36
31
|
post_install_message:
|
37
32
|
rdoc_options: []
|
38
|
-
|
39
|
-
require_paths:
|
33
|
+
require_paths:
|
40
34
|
- lib
|
41
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
-
requirements:
|
43
|
-
-
|
44
|
-
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
50
45
|
requirements: []
|
51
|
-
|
52
46
|
rubyforge_project:
|
53
|
-
rubygems_version: 2.
|
47
|
+
rubygems_version: 2.2.2
|
54
48
|
signing_key:
|
55
49
|
specification_version: 4
|
56
50
|
summary: create seperate html file for each rspec script
|
57
51
|
test_files: []
|
58
|
-
|