turnip_formatter 0.1.2 → 0.2.0
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.
- data/.gitignore +1 -1
- data/{spec/examples → example}/README.md +8 -8
- data/{spec/examples → example}/features/battle.feature +0 -0
- data/{spec/examples → example}/features/battle2.feature +0 -0
- data/{spec/examples → example}/features/battle3.feature +0 -0
- data/{spec/examples → example}/features/songs.feature +0 -0
- data/{spec/examples → example}/images/background.png +0 -0
- data/{spec/examples → example}/images/basic_step.png +0 -0
- data/{spec/examples → example}/images/failed_step.png +0 -0
- data/{spec/examples → example}/images/multiline.png +0 -0
- data/{spec/examples → example}/images/outline.png +0 -0
- data/{spec/examples → example}/images/pending_step.png +0 -0
- data/{spec/examples → example}/images/tag_step.png +0 -0
- data/{spec/examples → example}/spec_helper.rb +0 -0
- data/{spec/examples → example}/steps/spell_steps.rb +0 -0
- data/{spec/examples → example}/steps/steps.rb +0 -0
- data/lib/turnip_formatter/formatter.css +0 -21
- data/lib/turnip_formatter/formatter.scss +0 -32
- data/lib/turnip_formatter/scenario.rb +5 -0
- data/lib/turnip_formatter/step/dsl.rb +5 -5
- data/lib/turnip_formatter/step/failure.rb +0 -8
- data/lib/turnip_formatter/step/pending.rb +0 -7
- data/lib/turnip_formatter/step.rb +4 -4
- data/lib/turnip_formatter/step_template/exception.rb +61 -0
- data/lib/turnip_formatter/step_template/source.rb +46 -0
- data/lib/turnip_formatter/step_template.rb +8 -0
- data/lib/turnip_formatter/template/exception.erb +26 -0
- data/lib/turnip_formatter/template/exception_backtrace.erb +7 -0
- data/lib/turnip_formatter/template/scenario.erb +24 -0
- data/lib/turnip_formatter/template/scenario_tags.erb +5 -0
- data/lib/turnip_formatter/template/section_report.erb +15 -0
- data/lib/turnip_formatter/template/step_multiline.erb +1 -0
- data/lib/turnip_formatter/template/step_outline.erb +9 -0
- data/lib/turnip_formatter/template.rb +88 -125
- data/lib/turnip_formatter/version.rb +1 -1
- data/lib/turnip_formatter.rb +1 -0
- data/spec/turnip_formatter/step/failure_spec.rb +19 -4
- data/spec/turnip_formatter/step/pending_spec.rb +18 -4
- data/spec/turnip_formatter/step_spec.rb +37 -24
- data/spec/turnip_formatter/{template/step_exception_spec.rb → step_template/exception_spec.rb} +4 -4
- data/spec/turnip_formatter/{template/step_source_spec.rb → step_template/source_spec.rb} +5 -5
- data/spec/turnip_formatter/template_spec.rb +60 -40
- data/turnip_formatter.gemspec +2 -1
- metadata +47 -44
- data/lib/turnip_formatter/template/step_exception.rb +0 -30
- data/lib/turnip_formatter/template/step_multiline.rb +0 -13
- data/lib/turnip_formatter/template/step_outline.rb +0 -29
- data/lib/turnip_formatter/template/step_source.rb +0 -15
- data/spec/turnip_formatter/template/step_multiline_spec.rb +0 -18
- data/spec/turnip_formatter/template/step_outline_spec.rb +0 -31
data/.gitignore
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
$ cd /path/to/turnip_formatter
|
6
6
|
$ bundle install --path vendor/bundle
|
7
|
-
$ bundle exec rspec -r ./
|
7
|
+
$ bundle exec rspec -r ./example/spec_helper example
|
8
8
|
$ open report.html
|
9
9
|
|
10
10
|
## Screenshot
|
@@ -19,7 +19,7 @@ Scenario: normal monster
|
|
19
19
|
And Fanfare
|
20
20
|
```
|
21
21
|
|
22
|
-

|
23
23
|
|
24
24
|
### Failed step
|
25
25
|
|
@@ -35,7 +35,7 @@ Scenario: strong monster
|
|
35
35
|
And Fanfare
|
36
36
|
```
|
37
37
|
|
38
|
-

|
39
39
|
|
40
40
|
### Pending step and specify tag
|
41
41
|
|
@@ -60,9 +60,9 @@ Scenario: strong monster
|
|
60
60
|
And Fanfare
|
61
61
|
```
|
62
62
|
|
63
|
-

|
64
64
|
|
65
|
-

|
66
66
|
|
67
67
|
### Background
|
68
68
|
|
@@ -85,7 +85,7 @@ Feature: Battle a monster with weapon
|
|
85
85
|
And Fanfare
|
86
86
|
```
|
87
87
|
|
88
|
-

|
89
89
|
|
90
90
|
### Outline
|
91
91
|
|
@@ -108,7 +108,7 @@ Feature: Battle monsters
|
|
108
108
|
Then I could not escape
|
109
109
|
```
|
110
110
|
|
111
|
-

|
112
112
|
|
113
113
|
### Multiline
|
114
114
|
|
@@ -123,4 +123,4 @@ Feature: A feature with multiline strings
|
|
123
123
|
Then the song should have 2 lines
|
124
124
|
```
|
125
125
|
|
126
|
-

|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -136,27 +136,6 @@ div#steps-statistics section.scenario {
|
|
136
136
|
margin-top: 2em;
|
137
137
|
font-size: 13px;
|
138
138
|
color: #586e75; }
|
139
|
-
div#steps-statistics section.scenario ul.steps div.step_exception {
|
140
|
-
margin: 1em 0em;
|
141
|
-
padding: 1em 0em 1em 1em;
|
142
|
-
border: 1px solid #999999;
|
143
|
-
background-color: #eee8d5;
|
144
|
-
color: #586e75; }
|
145
|
-
div#steps-statistics section.scenario ul.steps div.step_exception > pre {
|
146
|
-
margin-left: 1em; }
|
147
|
-
div#steps-statistics section.scenario ul.steps pre.source {
|
148
|
-
font-size: 12px;
|
149
|
-
font-family: monospace;
|
150
|
-
background-color: #073642;
|
151
|
-
color: #dddddd; }
|
152
|
-
div#steps-statistics section.scenario ul.steps pre.source code.ruby {
|
153
|
-
padding: 0.1em 0 0.2em 0; }
|
154
|
-
div#steps-statistics section.scenario ul.steps pre.source code.ruby .linenum {
|
155
|
-
width: 75px;
|
156
|
-
color: #fffbd3;
|
157
|
-
padding-right: 1em; }
|
158
|
-
div#steps-statistics section.scenario ul.steps pre.source code.ruby .offending {
|
159
|
-
background-color: gray; }
|
160
139
|
|
161
140
|
div#speed-statistics table,
|
162
141
|
div#feature-statistics table,
|
@@ -180,38 +180,6 @@ div#steps-statistics section.scenario {
|
|
180
180
|
font-size: 13px;
|
181
181
|
color: #586e75;
|
182
182
|
}
|
183
|
-
|
184
|
-
div.step_exception {
|
185
|
-
margin: 1em 0em;
|
186
|
-
padding: 1em 0em 1em 1em;
|
187
|
-
border: 1px solid #999999;
|
188
|
-
background-color: #eee8d5;
|
189
|
-
color: #586e75;
|
190
|
-
|
191
|
-
> pre {
|
192
|
-
margin-left: 1em;
|
193
|
-
}
|
194
|
-
}
|
195
|
-
|
196
|
-
pre.source {
|
197
|
-
font-size: 12px;
|
198
|
-
font-family: monospace;
|
199
|
-
background-color: #073642;
|
200
|
-
color: #dddddd;
|
201
|
-
|
202
|
-
code.ruby {
|
203
|
-
padding: 0.1em 0 0.2em 0;
|
204
|
-
|
205
|
-
.linenum {
|
206
|
-
width: 75px;
|
207
|
-
color: #fffbd3;
|
208
|
-
padding-right: 1em;
|
209
|
-
}
|
210
|
-
|
211
|
-
.offending { background-color: gray; }
|
212
|
-
}
|
213
|
-
}
|
214
|
-
|
215
183
|
}
|
216
184
|
}
|
217
185
|
|
@@ -53,6 +53,11 @@ module TurnipFormatter
|
|
53
53
|
example.execution_result[:run_time]
|
54
54
|
end
|
55
55
|
|
56
|
+
def feature_info
|
57
|
+
path = RSpec::Core::Metadata::relative_path(feature_file_path)
|
58
|
+
"\"#{feature_name}\" in #{path}"
|
59
|
+
end
|
60
|
+
|
56
61
|
def feature_name
|
57
62
|
example.example_group.metadata[:example_group][:example_group][:description]
|
58
63
|
end
|
@@ -17,16 +17,16 @@ module TurnipFormatter
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def add_template(
|
21
|
-
::TurnipFormatter::Step.add_template(status,
|
20
|
+
def add_template(klass, &block)
|
21
|
+
::TurnipFormatter::Step.add_template(status, klass, &block)
|
22
22
|
end
|
23
23
|
|
24
|
-
def remove_template(
|
25
|
-
::TurnipFormatter::Step.remove_template(status,
|
24
|
+
def remove_template(klass)
|
25
|
+
::TurnipFormatter::Step.remove_template(status, klass)
|
26
26
|
end
|
27
27
|
|
28
28
|
def templates
|
29
|
-
::TurnipFormatter::Step.templates[status]
|
29
|
+
::TurnipFormatter::Step.templates[status] || []
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -14,13 +14,6 @@ module TurnipFormatter
|
|
14
14
|
def status
|
15
15
|
Pending.status
|
16
16
|
end
|
17
|
-
|
18
|
-
add_template :exception do
|
19
|
-
message = example.execution_result[:pending_message]
|
20
|
-
exception = RSpec::Core::Pending::PendingDeclaredInExample.new(message)
|
21
|
-
exception.set_backtrace(example.location)
|
22
|
-
exception
|
23
|
-
end
|
24
17
|
end
|
25
18
|
end
|
26
19
|
end
|
@@ -9,13 +9,13 @@ module TurnipFormatter
|
|
9
9
|
@templates ||= {}
|
10
10
|
end
|
11
11
|
|
12
|
-
def add_template(status,
|
12
|
+
def add_template(status, klass = nil, &block)
|
13
13
|
templates[status] ||= {}
|
14
|
-
templates[status][
|
14
|
+
templates[status][klass] = { klass: klass, block: block }
|
15
15
|
end
|
16
16
|
|
17
|
-
def remove_template(status,
|
18
|
-
templates[status].delete(
|
17
|
+
def remove_template(status, klass)
|
18
|
+
templates[status].delete(klass)
|
19
19
|
templates.delete(status.to_sym) if templates[status.to_sym].empty?
|
20
20
|
end
|
21
21
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'turnip_formatter/step/failure'
|
4
|
+
require 'turnip_formatter/step/pending'
|
5
|
+
require 'erb'
|
6
|
+
|
7
|
+
module TurnipFormatter
|
8
|
+
module StepTemplate
|
9
|
+
module Exception
|
10
|
+
def self.build(exception)
|
11
|
+
template_step_exception.result(binding)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def self.template_step_exception
|
17
|
+
@template_step_exception ||= ERB.new(<<-EOS)
|
18
|
+
<div class="step_exception">
|
19
|
+
<span>Failure:</span>
|
20
|
+
<pre><%= ERB::Util.h(exception.to_s) %></pre>
|
21
|
+
<span>Backtrace:</span>
|
22
|
+
<ol>
|
23
|
+
<% exception.backtrace.each do |line| %>
|
24
|
+
<li><%= ERB::Util.h(line) %></li>
|
25
|
+
<% end %>
|
26
|
+
</ol>
|
27
|
+
</div>
|
28
|
+
EOS
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Template.add_scss(<<-EOS)
|
34
|
+
div#steps-statistics section.scenario {
|
35
|
+
ul.steps {
|
36
|
+
div.step_exception {
|
37
|
+
margin: 1em 0em;
|
38
|
+
padding: 1em 0em 1em 1em;
|
39
|
+
border: 1px solid #999999;
|
40
|
+
background-color: #eee8d5;
|
41
|
+
color: #586e75;
|
42
|
+
|
43
|
+
> pre {
|
44
|
+
margin-left: 1em;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
EOS
|
50
|
+
|
51
|
+
Step::Failure.add_template StepTemplate::Exception do
|
52
|
+
example.exception
|
53
|
+
end
|
54
|
+
|
55
|
+
Step::Pending.add_template StepTemplate::Exception do
|
56
|
+
message = example.execution_result[:pending_message]
|
57
|
+
exception = RSpec::Core::Pending::PendingDeclaredInExample.new(message)
|
58
|
+
exception.set_backtrace(example.location)
|
59
|
+
exception
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'turnip_formatter/step/failure'
|
4
|
+
require 'rspec/core/formatters/snippet_extractor'
|
5
|
+
|
6
|
+
module TurnipFormatter
|
7
|
+
module StepTemplate
|
8
|
+
module Source
|
9
|
+
def self.build(location)
|
10
|
+
code = extractor.snippet([location])
|
11
|
+
'<pre class="source"><code class="ruby">' + code + '</code></pre>'
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def self.extractor
|
17
|
+
@extractor ||= ::RSpec::Core::Formatters::SnippetExtractor.new
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
Template.add_scss(<<-EOS)
|
23
|
+
pre.source {
|
24
|
+
font-size: 12px;
|
25
|
+
font-family: monospace;
|
26
|
+
background-color: #073642;
|
27
|
+
color: #dddddd;
|
28
|
+
|
29
|
+
code.ruby {
|
30
|
+
padding: 0.1em 0 0.2em 0;
|
31
|
+
|
32
|
+
.linenum {
|
33
|
+
width: 75px;
|
34
|
+
color: #fffbd3;
|
35
|
+
padding-right: 1em;
|
36
|
+
}
|
37
|
+
|
38
|
+
.offending { background-color: gray; }
|
39
|
+
}
|
40
|
+
}
|
41
|
+
EOS
|
42
|
+
|
43
|
+
Step::Failure.add_template(StepTemplate::Source) do
|
44
|
+
example.exception.backtrace.first
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<section class="exception">
|
2
|
+
<h1>TurnipFormatter RuntimeError</h1>
|
3
|
+
<dl>
|
4
|
+
<dt>Runtime Exception</dt>
|
5
|
+
<dd><%= h(exception.to_s) %></dd>
|
6
|
+
|
7
|
+
<dt>Runtime Exception Backtrace</dt>
|
8
|
+
<%= print_exception_backtrace(exception) %>
|
9
|
+
|
10
|
+
<dt>Example Full Description</dt>
|
11
|
+
<dd><%= h(example.metadata[:full_description]) %></dd>
|
12
|
+
|
13
|
+
<% if example.exception %>
|
14
|
+
<dt>Example Exception</dt>
|
15
|
+
<dd><%= h(example.exception.to_s) %></dd>
|
16
|
+
|
17
|
+
<dt>Example Backtrace</dt>
|
18
|
+
<%= print_exception_backtrace(example.exception) %>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<% if example.pending %>
|
22
|
+
<dt>Example Pending description</dt>
|
23
|
+
<dd><%= h(example.metadata[:description]) %></dd>
|
24
|
+
<% end %>
|
25
|
+
</dl>
|
26
|
+
</section>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<section class="scenario <%= h(scenario.status) %>">
|
2
|
+
<header>
|
3
|
+
<span class="permalink">
|
4
|
+
<a href="#<%= scenario.id %>">¶</a>
|
5
|
+
</span>
|
6
|
+
<span class="scenario_name" id="<%= scenario.id %>">
|
7
|
+
Scenario: <%= h(scenario.name) %>
|
8
|
+
</span>
|
9
|
+
<span class="feature_name">
|
10
|
+
(Feature: <%= h(scenario.feature_info) %>)
|
11
|
+
at <%= h(scenario.run_time) %> sec
|
12
|
+
</span>
|
13
|
+
</header>
|
14
|
+
<%= print_scenario_tags(scenario) %>
|
15
|
+
<ul class="steps">
|
16
|
+
<% scenario.steps.each do |step| %>
|
17
|
+
<li <%= step_attr(step) %>><span><%= h(step.name) %></span>
|
18
|
+
<div class="args">
|
19
|
+
<%= step_args(step) %>
|
20
|
+
</div>
|
21
|
+
</li>
|
22
|
+
<% end %>
|
23
|
+
</ul>
|
24
|
+
</section>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<div id="report">
|
2
|
+
<h1>Turnip Report</h1>
|
3
|
+
<section class="checkbox">
|
4
|
+
<label for="passed_check">Passed</label><input type="checkbox" checked id="passed_check">
|
5
|
+
<label for="failed_check">Failed</label><input type="checkbox" checked id="failed_check">
|
6
|
+
<label for="pending_check">Pending</label><input type="checkbox" checked id="pending_check">
|
7
|
+
</section>
|
8
|
+
|
9
|
+
<section class="result">
|
10
|
+
<p>
|
11
|
+
<span id="total_count"></span> Scenario (<span id="failed_count"></span> failed <span id="pending_count"></span> pending).
|
12
|
+
</p>
|
13
|
+
<p>Finished in <span id="total_time"></span></p>
|
14
|
+
</section>
|
15
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
<pre class="multiline"><%= h(lines) %></pre>
|