turnip_formatter 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -0
- data/lib/turnip_formatter/formatter.css +11 -0
- data/lib/turnip_formatter/formatter.scss +13 -0
- data/lib/turnip_formatter/scenario.rb +7 -0
- data/lib/turnip_formatter/template.rb +34 -2
- data/lib/turnip_formatter/version.rb +1 -1
- data/spec/rspec/core/formatters/turnip_formatter_spec.rb +4 -26
- data/spec/support/shared_context_examples.rb +17 -4
- data/spec/turnip_formatter/scenario/failure_spec.rb +9 -14
- data/spec/turnip_formatter/scenario/pass_spec.rb +3 -8
- data/spec/turnip_formatter/scenario/pending_spec.rb +15 -24
- data/spec/turnip_formatter/step/failure_spec.rb +2 -4
- data/spec/turnip_formatter/step/pending_spec.rb +2 -2
- data/spec/turnip_formatter/step_spec.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -48,6 +48,13 @@ Example
|
|
48
48
|
|
49
49
|
see https://github.com/gongo/turnip_formatter/tree/master/spec/examples
|
50
50
|
|
51
|
+
Add-on
|
52
|
+
--------------------
|
53
|
+
|
54
|
+
* Gnawrnip
|
55
|
+
* Gnawrnip is a TurnipFormatter Add-on that provides put a screen shot to report use Capybara
|
56
|
+
* https://github.com/gongo/gnawrnip
|
57
|
+
|
51
58
|
License
|
52
59
|
--------------------
|
53
60
|
|
@@ -8,6 +8,14 @@ div#report {
|
|
8
8
|
background: black;
|
9
9
|
color: #aaffaa; }
|
10
10
|
|
11
|
+
footer {
|
12
|
+
width: 90%;
|
13
|
+
margin: 0 auto;
|
14
|
+
padding: 2em;
|
15
|
+
background: black;
|
16
|
+
color: #aaffaa;
|
17
|
+
text-align: right; }
|
18
|
+
|
11
19
|
div#main {
|
12
20
|
width: 90%;
|
13
21
|
margin: 0 auto;
|
@@ -20,6 +28,9 @@ section.scenario {
|
|
20
28
|
border: 2px solid green; }
|
21
29
|
section.scenario > header {
|
22
30
|
margin: 1em 0em; }
|
31
|
+
section.scenario > header:hover {
|
32
|
+
text-decoration: underline;
|
33
|
+
cursor: pointer; }
|
23
34
|
section.scenario > header span.scenario_name {
|
24
35
|
font-weight: bold;
|
25
36
|
font-size: 14px; }
|
@@ -21,7 +21,15 @@ div#report {
|
|
21
21
|
padding: 2em;
|
22
22
|
background: black;
|
23
23
|
color: #aaffaa;
|
24
|
+
}
|
24
25
|
|
26
|
+
footer {
|
27
|
+
width: 90%;
|
28
|
+
margin: 0 auto;
|
29
|
+
padding: 2em;
|
30
|
+
background: black;
|
31
|
+
color: #aaffaa;
|
32
|
+
text-align: right;
|
25
33
|
}
|
26
34
|
|
27
35
|
div#main {
|
@@ -39,6 +47,11 @@ section.scenario {
|
|
39
47
|
> header {
|
40
48
|
margin: 1em 0em;
|
41
49
|
|
50
|
+
&:hover {
|
51
|
+
text-decoration: underline;
|
52
|
+
cursor: pointer;
|
53
|
+
}
|
54
|
+
|
42
55
|
span.scenario_name {
|
43
56
|
font-weight: bold;
|
44
57
|
font-size: 14px;
|
@@ -42,6 +42,13 @@ module TurnipFormatter
|
|
42
42
|
example.execution_result[:status]
|
43
43
|
end
|
44
44
|
|
45
|
+
#
|
46
|
+
# @return [String] scenario run time
|
47
|
+
#
|
48
|
+
def run_time
|
49
|
+
example.execution_result[:run_time]
|
50
|
+
end
|
51
|
+
|
45
52
|
def feature_name
|
46
53
|
example.example_group.metadata[:example_group][:example_group][:description]
|
47
54
|
end
|
@@ -16,14 +16,38 @@ module TurnipFormatter
|
|
16
16
|
def print_header
|
17
17
|
<<-EOS
|
18
18
|
<!DOCTYPE html>
|
19
|
+
<html>
|
19
20
|
<head>
|
20
21
|
<meta charset="UTF-8">
|
21
22
|
<style>
|
22
23
|
#{File.read(File.dirname(__FILE__) + '/formatter.css')}
|
23
24
|
</style>
|
24
|
-
<script type="text/javascript" src="http://
|
25
|
+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
25
26
|
<script>
|
26
27
|
$(function() {
|
28
|
+
var scenarioHeader = 'section.scenario header';
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Step folding/expanding
|
32
|
+
*/
|
33
|
+
$(scenarioHeader).click(function() {
|
34
|
+
var steps = $(this).siblings();
|
35
|
+
steps.slideToggle();
|
36
|
+
});
|
37
|
+
|
38
|
+
/**
|
39
|
+
* All step folding/expanding action
|
40
|
+
*/
|
41
|
+
$('#scenario_display_check').change(function() {
|
42
|
+
var steps = $(scenarioHeader).siblings();
|
43
|
+
|
44
|
+
if (this.checked) {
|
45
|
+
steps.slideUp();
|
46
|
+
} else {
|
47
|
+
steps.slideDown();
|
48
|
+
}
|
49
|
+
});
|
50
|
+
|
27
51
|
["passed", "failed", "pending"].forEach(function(status) {
|
28
52
|
$('#' + status + '_check').click(function() {
|
29
53
|
if (this.checked) {
|
@@ -39,6 +63,7 @@ module TurnipFormatter
|
|
39
63
|
<body>
|
40
64
|
#{report_area}
|
41
65
|
<div id="main" role="main">
|
66
|
+
<label><input type="checkbox" id="scenario_display_check">step folding</label>
|
42
67
|
EOS
|
43
68
|
end
|
44
69
|
|
@@ -54,6 +79,10 @@ module TurnipFormatter
|
|
54
79
|
<<-EOS
|
55
80
|
</div>
|
56
81
|
#{update_report_js}
|
82
|
+
|
83
|
+
<footer>
|
84
|
+
Generated by <a href="https://rubygems.org/gems/turnip_formatter">turnip_formatter</a> #{TurnipFormatter::VERSION} and <a href="http://jquery.com/">jQuery</a>
|
85
|
+
</footer>
|
57
86
|
</body>
|
58
87
|
</html>
|
59
88
|
EOS
|
@@ -151,7 +180,10 @@ module TurnipFormatter
|
|
151
180
|
<span class="scenario_name" id="<%= scenario.object_id %>">
|
152
181
|
Scenario: <%= h(scenario.name) %>
|
153
182
|
</span>
|
154
|
-
<span class="feature_name">
|
183
|
+
<span class="feature_name">
|
184
|
+
(Feature: <%= h(feature_name(scenario)) %>)
|
185
|
+
at <%= h(scenario.run_time) %> sec
|
186
|
+
</span>
|
155
187
|
</header>
|
156
188
|
<%= scenario_tags(scenario) %>
|
157
189
|
<ul class="steps">
|
@@ -3,7 +3,7 @@ require 'stringio'
|
|
3
3
|
|
4
4
|
module RSpec::Core::Formatters
|
5
5
|
describe TurnipFormatter do
|
6
|
-
include_context 'turnip_formatter
|
6
|
+
include_context 'turnip_formatter standard scenario metadata'
|
7
7
|
|
8
8
|
let(:feature) { RSpec::Core::ExampleGroup.describe('Feature') }
|
9
9
|
let(:scenario) { feature.describe('Scenario') }
|
@@ -29,19 +29,8 @@ module RSpec::Core::Formatters
|
|
29
29
|
end
|
30
30
|
|
31
31
|
describe '#example_failed' do
|
32
|
-
let(:failed_metadata) do
|
33
|
-
metadata[:turnip][:steps].tap do |steps|
|
34
|
-
steps << {
|
35
|
-
name: 'this step is error',
|
36
|
-
extra_args: [],
|
37
|
-
keyword: 'Given'
|
38
|
-
}
|
39
|
-
end
|
40
|
-
metadata
|
41
|
-
end
|
42
|
-
|
43
32
|
it 'should be output failed scenario section' do
|
44
|
-
scenario.example('failed',
|
33
|
+
scenario.example('failed', metadata) do
|
45
34
|
begin
|
46
35
|
expect(true).to be_false
|
47
36
|
rescue => e
|
@@ -56,19 +45,8 @@ module RSpec::Core::Formatters
|
|
56
45
|
end
|
57
46
|
|
58
47
|
describe '#example_pending' do
|
59
|
-
let(:pending_metadata) do
|
60
|
-
metadata[:turnip][:steps].tap do |steps|
|
61
|
-
steps << {
|
62
|
-
name: 'this step is unimplement',
|
63
|
-
extra_args: [],
|
64
|
-
keyword: 'Given'
|
65
|
-
}
|
66
|
-
end
|
67
|
-
metadata
|
68
|
-
end
|
69
|
-
|
70
48
|
it 'should be output pending scenario section' do
|
71
|
-
scenario.example('pending',
|
49
|
+
scenario.example('pending', metadata) do
|
72
50
|
pending("No such step(0): 'this step is unimplement'")
|
73
51
|
end
|
74
52
|
feature.run(formatter)
|
@@ -77,7 +55,7 @@ module RSpec::Core::Formatters
|
|
77
55
|
end
|
78
56
|
|
79
57
|
it 'should be output runtime exception section' do
|
80
|
-
scenario.example('pending',
|
58
|
+
scenario.example('pending', metadata) do
|
81
59
|
pending("Pending")
|
82
60
|
end
|
83
61
|
feature.run(formatter)
|
@@ -1,13 +1,26 @@
|
|
1
|
-
shared_context "turnip_formatter scenario setup" do |
|
1
|
+
shared_context "turnip_formatter scenario setup" do |assertion|
|
2
2
|
let(:example) do
|
3
|
+
assertion ||= proc { expect(true).to be_true }
|
3
4
|
group = ::RSpec::Core::ExampleGroup.describe('Feature').describe('Scenario')
|
4
|
-
|
5
|
+
example = group.example('example', metadata, &assertion)
|
5
6
|
group.run(NoopObject.new)
|
6
|
-
|
7
|
+
example
|
7
8
|
end
|
8
9
|
end
|
9
10
|
|
10
|
-
shared_context
|
11
|
+
shared_context "turnip_formatter failure scenario setup" do |assertion|
|
12
|
+
include_context 'turnip_formatter scenario setup', proc {
|
13
|
+
expect(true).to be_false
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
shared_context "turnip_formatter pending scenario setup" do |assertion|
|
18
|
+
include_context 'turnip_formatter scenario setup', proc {
|
19
|
+
pending('Pending')
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
shared_context 'turnip_formatter standard scenario metadata' do
|
11
24
|
let(:metadata) do
|
12
25
|
{
|
13
26
|
turnip: {
|
@@ -3,13 +3,10 @@ require 'spec_helper'
|
|
3
3
|
module TurnipFormatter::Scenario
|
4
4
|
describe Failure do
|
5
5
|
let(:scenario) { ::TurnipFormatter::Scenario::Failure.new(failure_example) }
|
6
|
-
include_context 'turnip_formatter
|
6
|
+
include_context 'turnip_formatter standard scenario metadata'
|
7
|
+
include_context 'turnip_formatter failure scenario setup'
|
7
8
|
|
8
9
|
context 'Turnip example' do
|
9
|
-
include_context 'turnip_formatter scenario setup', proc {
|
10
|
-
expect(true).to be_false
|
11
|
-
}
|
12
|
-
|
13
10
|
let(:failure_example) do
|
14
11
|
example.exception.backtrace.push ":in step:0 `"
|
15
12
|
example
|
@@ -28,25 +25,23 @@ module TurnipFormatter::Scenario
|
|
28
25
|
end
|
29
26
|
|
30
27
|
context 'Not failed example' do
|
31
|
-
include_context 'turnip_formatter scenario setup'
|
32
|
-
expect(true).to be_true
|
33
|
-
}
|
28
|
+
include_context 'turnip_formatter scenario setup'
|
34
29
|
|
35
30
|
describe '#validation' do
|
36
31
|
it 'should raise exception' do
|
37
|
-
expect {
|
32
|
+
expect {
|
33
|
+
scenario.validation
|
34
|
+
}.to raise_error NotFailedScenarioError
|
38
35
|
end
|
39
36
|
end
|
40
37
|
end
|
41
38
|
|
42
39
|
context 'Not exist failed step information' do
|
43
|
-
include_context 'turnip_formatter scenario setup', proc {
|
44
|
-
expect(true).to be_false
|
45
|
-
}
|
46
|
-
|
47
40
|
describe '#validation' do
|
48
41
|
it 'should raise exception' do
|
49
|
-
expect {
|
42
|
+
expect {
|
43
|
+
scenario.validation
|
44
|
+
}.to raise_error NoExistFailedStepInformationError
|
50
45
|
end
|
51
46
|
end
|
52
47
|
end
|
@@ -4,11 +4,8 @@ module TurnipFormatter::Scenario
|
|
4
4
|
describe Pass do
|
5
5
|
let(:scenario) { ::TurnipFormatter::Scenario::Pass.new(example) }
|
6
6
|
|
7
|
-
include_context 'turnip_formatter scenario setup'
|
8
|
-
|
9
|
-
}
|
10
|
-
|
11
|
-
include_context 'turnip_formatter passed scenario metadata'
|
7
|
+
include_context 'turnip_formatter scenario setup'
|
8
|
+
include_context 'turnip_formatter standard scenario metadata'
|
12
9
|
|
13
10
|
context 'Turnip example' do
|
14
11
|
describe '#validation' do
|
@@ -20,9 +17,7 @@ module TurnipFormatter::Scenario
|
|
20
17
|
|
21
18
|
context 'Not Turnip example' do
|
22
19
|
context 'Not passed example' do
|
23
|
-
include_context 'turnip_formatter scenario setup'
|
24
|
-
expect(true).to be_false
|
25
|
-
}
|
20
|
+
include_context 'turnip_formatter failure scenario setup'
|
26
21
|
|
27
22
|
describe '#validation' do
|
28
23
|
it 'should raise exception' do
|
@@ -2,19 +2,16 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module TurnipFormatter::Scenario
|
4
4
|
describe Failure do
|
5
|
-
|
6
|
-
|
7
|
-
let(:pending_example) do
|
8
|
-
example.execution_result[:pending_message] = 'No such step(0): '
|
9
|
-
example
|
10
|
-
end
|
5
|
+
include_context 'turnip_formatter standard scenario metadata'
|
6
|
+
include_context 'turnip_formatter pending scenario setup'
|
11
7
|
|
12
|
-
|
8
|
+
let(:scenario) { ::TurnipFormatter::Scenario::Pending.new(pending_example) }
|
13
9
|
|
14
10
|
context 'Turnip example' do
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
let(:pending_example) do
|
12
|
+
example.execution_result[:pending_message] = 'No such step(0): '
|
13
|
+
example
|
14
|
+
end
|
18
15
|
|
19
16
|
describe '#validation' do
|
20
17
|
it 'should not raise exception' do
|
@@ -24,34 +21,28 @@ module TurnipFormatter::Scenario
|
|
24
21
|
end
|
25
22
|
|
26
23
|
context 'Not Turnip example' do
|
27
|
-
let(:
|
24
|
+
let(:pending_example) do
|
28
25
|
example
|
29
26
|
end
|
30
27
|
|
31
28
|
context 'Not pending example' do
|
32
|
-
include_context 'turnip_formatter scenario setup'
|
33
|
-
expect(true).to be_true
|
34
|
-
}
|
29
|
+
include_context 'turnip_formatter scenario setup'
|
35
30
|
|
36
31
|
describe '#validation' do
|
37
32
|
it 'should raise exception' do
|
38
|
-
expect {
|
33
|
+
expect {
|
34
|
+
scenario.validation
|
35
|
+
}.to raise_error NotPendingScenarioError
|
39
36
|
end
|
40
37
|
end
|
41
38
|
end
|
42
39
|
|
43
40
|
context 'Not exist pending step information' do
|
44
|
-
include_context 'turnip_formatter scenario setup', proc {
|
45
|
-
pending('Pending')
|
46
|
-
}
|
47
|
-
|
48
|
-
let(:pending_example) do
|
49
|
-
example
|
50
|
-
end
|
51
|
-
|
52
41
|
describe '#validation' do
|
53
42
|
it 'should raise exception' do
|
54
|
-
expect {
|
43
|
+
expect {
|
44
|
+
scenario.validation
|
45
|
+
}.to raise_error NoExistPendingStepInformationError
|
55
46
|
end
|
56
47
|
end
|
57
48
|
end
|
@@ -4,10 +4,8 @@ module TurnipFormatter
|
|
4
4
|
class Step
|
5
5
|
describe Failure do
|
6
6
|
include_context 'turnip_formatter standard step parameters'
|
7
|
-
include_context 'turnip_formatter scenario setup'
|
8
|
-
|
9
|
-
}
|
10
|
-
include_context 'turnip_formatter passed scenario metadata'
|
7
|
+
include_context 'turnip_formatter failure scenario setup'
|
8
|
+
include_context 'turnip_formatter standard scenario metadata'
|
11
9
|
|
12
10
|
let(:step) do
|
13
11
|
step = ::TurnipFormatter::Step.new(example, description)
|
@@ -4,8 +4,8 @@ module TurnipFormatter
|
|
4
4
|
class Step
|
5
5
|
describe Failure do
|
6
6
|
include_context 'turnip_formatter standard step parameters'
|
7
|
-
include_context 'turnip_formatter scenario setup'
|
8
|
-
include_context 'turnip_formatter
|
7
|
+
include_context 'turnip_formatter pending scenario setup'
|
8
|
+
include_context 'turnip_formatter standard scenario metadata'
|
9
9
|
|
10
10
|
let(:step) do
|
11
11
|
step = ::TurnipFormatter::Step.new(example, description)
|
@@ -4,7 +4,7 @@ module TurnipFormatter
|
|
4
4
|
describe Step do
|
5
5
|
include_context 'turnip_formatter standard step parameters'
|
6
6
|
include_context 'turnip_formatter scenario setup'
|
7
|
-
include_context 'turnip_formatter
|
7
|
+
include_context 'turnip_formatter standard scenario metadata'
|
8
8
|
let(:step) { ::TurnipFormatter::Step.new(example, description) }
|
9
9
|
|
10
10
|
describe '#attention?' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turnip_formatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: turnip
|
@@ -172,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
172
172
|
version: '0'
|
173
173
|
segments:
|
174
174
|
- 0
|
175
|
-
hash: -
|
175
|
+
hash: -759848237600448328
|
176
176
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
177
|
none: false
|
178
178
|
requirements:
|
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
181
|
version: '0'
|
182
182
|
segments:
|
183
183
|
- 0
|
184
|
-
hash: -
|
184
|
+
hash: -759848237600448328
|
185
185
|
requirements: []
|
186
186
|
rubyforge_project:
|
187
187
|
rubygems_version: 1.8.23
|