turnip_formatter 0.2.11 → 0.3.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.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +18 -22
- data/example/README.md +6 -8
- data/example/images/background.png +0 -0
- data/example/images/basic_step.png +0 -0
- data/example/images/failed_step.png +0 -0
- data/example/images/multiline.png +0 -0
- data/example/images/outline.png +0 -0
- data/example/images/pending_step.png +0 -0
- data/example/spec/bar.js +1 -0
- data/example/spec/foo.css +3 -0
- data/example/spec/spec_helper.rb +7 -2
- data/lib/rspec/core/formatters/turnip_formatter.rb +32 -19
- data/lib/turnip_formatter/printer/index.rb +6 -9
- data/lib/turnip_formatter/printer/scenario.rb +4 -2
- data/lib/turnip_formatter/printer/step.rb +16 -14
- data/lib/turnip_formatter/printer/step_extra_args.rb +2 -0
- data/lib/turnip_formatter/printer/tab_speed_statistics.rb +2 -1
- data/lib/turnip_formatter/printer/tab_tag_statistics.rb +5 -6
- data/lib/turnip_formatter/printer.rb +6 -11
- data/lib/turnip_formatter/scenario/base.rb +98 -0
- data/lib/turnip_formatter/scenario/failure.rb +19 -21
- data/lib/turnip_formatter/scenario/pass.rb +2 -13
- data/lib/turnip_formatter/scenario/pending.rb +19 -25
- data/lib/turnip_formatter/step.rb +8 -38
- data/lib/turnip_formatter/step_template/base.rb +34 -0
- data/lib/turnip_formatter/step_template/exception.rb +59 -50
- data/lib/turnip_formatter/step_template/source.rb +36 -34
- data/lib/turnip_formatter/template/exception.haml +8 -0
- data/lib/turnip_formatter/template/index.haml +88 -0
- data/lib/turnip_formatter/template/runtime_exception.haml +13 -0
- data/lib/turnip_formatter/template/scenario.haml +14 -0
- data/lib/turnip_formatter/template/step.haml +6 -0
- data/lib/turnip_formatter/template/step_multiline.haml +1 -0
- data/lib/turnip_formatter/template/step_outline.haml +6 -0
- data/lib/turnip_formatter/template/tab_feature_statistics.haml +18 -0
- data/lib/turnip_formatter/template/tab_speed_statistics.haml +16 -0
- data/lib/turnip_formatter/template/tab_tag_statistics.haml +18 -0
- data/lib/turnip_formatter/template/turnip_formatter.js +8 -25
- data/lib/turnip_formatter/template/turnip_formatter.scss +102 -174
- data/lib/turnip_formatter/template.rb +65 -39
- data/lib/turnip_formatter/version.rb +1 -1
- data/lib/turnip_formatter.rb +45 -7
- data/spec/spec_helper.rb +6 -1
- data/spec/support/example_helper.rb +36 -0
- data/spec/support/step_helper.rb +27 -0
- data/spec/turnip_formatter/printer/index_spec.rb +10 -10
- data/spec/turnip_formatter/printer/scenario_spec.rb +29 -23
- data/spec/turnip_formatter/printer/step_extra_args_spec.rb +6 -6
- data/spec/turnip_formatter/printer/step_spec.rb +36 -69
- data/spec/turnip_formatter/printer/tab_feature_statistics_spec.rb +1 -4
- data/spec/turnip_formatter/printer/tab_speed_statistics_spec.rb +1 -4
- data/spec/turnip_formatter/printer/tab_tag_statistics_spec.rb +1 -4
- data/spec/turnip_formatter/scenario/base_spec.rb +67 -0
- data/spec/turnip_formatter/scenario/failure_spec.rb +16 -38
- data/spec/turnip_formatter/scenario/pending_spec.rb +16 -39
- data/spec/turnip_formatter/step_template/base_spec.rb +82 -0
- data/spec/turnip_formatter/step_template/exception_spec.rb +25 -17
- data/spec/turnip_formatter/step_template/source_spec.rb +10 -13
- data/turnip_formatter.gemspec +15 -11
- metadata +83 -41
- data/example/images/tag_step.png +0 -0
- data/images/tab_feature_statistics.png +0 -0
- data/images/tab_speed_statistics.png +0 -0
- data/images/tab_steps.png +0 -0
- data/images/tab_steps_expanding.png +0 -0
- data/images/tab_tag_statistics.png +0 -0
- data/lib/turnip_formatter/ext/turnip/builder.rb +0 -47
- data/lib/turnip_formatter/scenario.rb +0 -89
- data/lib/turnip_formatter/step/dsl.rb +0 -33
- data/lib/turnip_formatter/step/failure.rb +0 -19
- data/lib/turnip_formatter/step/pending.rb +0 -19
- data/lib/turnip_formatter/step_template.rb +0 -8
- data/lib/turnip_formatter/template/exception.erb +0 -10
- data/lib/turnip_formatter/template/exception_backtrace.erb +0 -7
- data/lib/turnip_formatter/template/index.erb +0 -70
- data/lib/turnip_formatter/template/runtime_exception.erb +0 -16
- data/lib/turnip_formatter/template/scenario.erb +0 -25
- data/lib/turnip_formatter/template/section_report.erb +0 -15
- data/lib/turnip_formatter/template/step.erb +0 -4
- data/lib/turnip_formatter/template/step_multiline.erb +0 -1
- data/lib/turnip_formatter/template/step_outline.erb +0 -9
- data/lib/turnip_formatter/template/tab_feature_statistics.erb +0 -24
- data/lib/turnip_formatter/template/tab_speed_statistics.erb +0 -18
- data/lib/turnip_formatter/template/tab_tag_statistics.erb +0 -24
- data/spec/rspec/core/formatters/turnip_formatter_spec.rb +0 -78
- data/spec/support/shared_context_examples.rb +0 -39
- data/spec/turnip_formatter/scenario/pass_spec.rb +0 -54
- data/spec/turnip_formatter/step/failure_spec.rb +0 -64
- data/spec/turnip_formatter/step/pending_spec.rb +0 -63
- data/spec/turnip_formatter/step_spec.rb +0 -86
@@ -1,24 +0,0 @@
|
|
1
|
-
<table>
|
2
|
-
<thead>
|
3
|
-
<tr>
|
4
|
-
<th>Tag</th>
|
5
|
-
<th>Scearios</th>
|
6
|
-
<th>passed</th>
|
7
|
-
<th>failed</th>
|
8
|
-
<th>pending</th>
|
9
|
-
<th>status</th>
|
10
|
-
</tr>
|
11
|
-
</thead>
|
12
|
-
<tbody>
|
13
|
-
<% analysis_results.each do |info| %>
|
14
|
-
<tr>
|
15
|
-
<td><%= info.name %></td>
|
16
|
-
<td><%= info.scenario_count %></td>
|
17
|
-
<td><%= info.passed_count %></td>
|
18
|
-
<td><%= info.failed_count %></td>
|
19
|
-
<td><%= info.pending_count %></td>
|
20
|
-
<td class="<%= info.status %>"><%= info.status %></td>
|
21
|
-
</tr>
|
22
|
-
<% end %>
|
23
|
-
</tbody>
|
24
|
-
</table>
|
@@ -1,78 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'stringio'
|
3
|
-
|
4
|
-
module RSpec::Core::Formatters
|
5
|
-
describe TurnipFormatter do
|
6
|
-
include_context 'turnip_formatter standard scenario metadata'
|
7
|
-
|
8
|
-
let(:feature) { RSpec::Core::ExampleGroup.describe('Feature') }
|
9
|
-
let(:scenario) { feature.describe('Scenario') }
|
10
|
-
let(:output) { StringIO.new }
|
11
|
-
let(:formatter) { TurnipFormatter.new(output) }
|
12
|
-
|
13
|
-
describe '#example_passed' do
|
14
|
-
before do
|
15
|
-
scenario.example('passed', metadata) { expect(true).to be true }
|
16
|
-
feature.run(formatter)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should get passed scenario count' do
|
20
|
-
expect(formatter.passed_scenarios.size).to eq 1
|
21
|
-
expect(formatter.failed_scenarios.size).to eq 0
|
22
|
-
expect(formatter.pending_scenarios.size).to eq 0
|
23
|
-
expect(formatter.scenarios.size).to eq 1
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#example_failed' do
|
28
|
-
before do
|
29
|
-
scenario.example('failed', metadata) do
|
30
|
-
begin
|
31
|
-
expect(true).to be false
|
32
|
-
rescue => e
|
33
|
-
e.backtrace.push ":in step:0 `"
|
34
|
-
raise e
|
35
|
-
end
|
36
|
-
end
|
37
|
-
feature.run(formatter)
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'should get failed scenario count' do
|
41
|
-
expect(formatter.passed_scenarios.size).to eq 0
|
42
|
-
expect(formatter.failed_scenarios.size).to eq 1
|
43
|
-
expect(formatter.pending_scenarios.size).to eq 0
|
44
|
-
expect(formatter.scenarios.size).to eq 1
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '#example_pending' do
|
49
|
-
before do
|
50
|
-
scenario.example('pending', metadata) do
|
51
|
-
pending("No such step(0): 'this step is unimplement'")
|
52
|
-
end
|
53
|
-
feature.run(formatter)
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'should get pending scenario count' do
|
57
|
-
expect(formatter.passed_scenarios.size).to eq 0
|
58
|
-
expect(formatter.failed_scenarios.size).to eq 0
|
59
|
-
expect(formatter.pending_scenarios.size).to eq 1
|
60
|
-
expect(formatter.scenarios.size).to eq 1
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe '#dump_summary' do
|
65
|
-
before do
|
66
|
-
formatter.dump_summary(0.0, 3, 2, 1)
|
67
|
-
end
|
68
|
-
|
69
|
-
subject { output.string }
|
70
|
-
|
71
|
-
it 'should be output summary section' do
|
72
|
-
should include '(<span id="failed_count">2</span> failed'
|
73
|
-
should include '<span id="pending_count">1</span> pending)'
|
74
|
-
should include '<span id="total_time">0.0</span>'
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
shared_context "turnip_formatter scenario setup" do |assertion|
|
2
|
-
let(:example) do
|
3
|
-
assertion ||= proc { expect(true).to be true }
|
4
|
-
group = ::RSpec::Core::ExampleGroup.describe('Feature').describe('Scenario')
|
5
|
-
example = group.example('example', metadata, &assertion)
|
6
|
-
group.run(NoopObject.new)
|
7
|
-
example
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
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
|
24
|
-
let(:metadata) do
|
25
|
-
{
|
26
|
-
turnip_formatter: {
|
27
|
-
steps: [ { name: 'Step 1', extra_args: [], keyword: 'When' } ],
|
28
|
-
tags: []
|
29
|
-
},
|
30
|
-
file_path: '/path/to/hoge.feature'
|
31
|
-
}
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
shared_context 'turnip_formatter standard step parameters' do
|
36
|
-
let(:description) do
|
37
|
-
{ name: 'StepName', keyword: 'Keyword', extra_args: ['Docstring'] }
|
38
|
-
end
|
39
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module TurnipFormatter::Scenario
|
4
|
-
describe Pass do
|
5
|
-
let(:scenario) { ::TurnipFormatter::Scenario::Pass.new(example) }
|
6
|
-
|
7
|
-
include_context 'turnip_formatter scenario setup'
|
8
|
-
include_context 'turnip_formatter standard scenario metadata'
|
9
|
-
|
10
|
-
context 'Turnip example' do
|
11
|
-
describe '#validation' do
|
12
|
-
it 'should not raise exception' do
|
13
|
-
expect { scenario.validation }.not_to raise_error
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'Not Turnip example' do
|
19
|
-
context 'Not passed example' do
|
20
|
-
include_context 'turnip_formatter failure scenario setup'
|
21
|
-
|
22
|
-
describe '#validation' do
|
23
|
-
it 'should raise exception' do
|
24
|
-
expect { scenario.validation }.to raise_error NotPassedScenarioError
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'not exist feature file' do
|
30
|
-
let(:metadata) do
|
31
|
-
metadata = super()
|
32
|
-
metadata[:file_path] = '/path/to/hoge.rb'
|
33
|
-
metadata
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '#validation' do
|
37
|
-
it 'should raise exception' do
|
38
|
-
expect { scenario.validation }.to raise_error NoFeatureFileError
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'not exist step information' do
|
44
|
-
let(:metadata) { { file_path: '/path/to/hoge.rb' } }
|
45
|
-
|
46
|
-
describe '#validation' do
|
47
|
-
it 'should raise exception' do
|
48
|
-
expect { scenario.validation }.to raise_error NotExistStepsInformationError
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module TurnipFormatter
|
4
|
-
class Step
|
5
|
-
describe Failure do
|
6
|
-
include_context 'turnip_formatter standard step parameters'
|
7
|
-
include_context 'turnip_formatter failure scenario setup'
|
8
|
-
include_context 'turnip_formatter standard scenario metadata'
|
9
|
-
|
10
|
-
let(:step) do
|
11
|
-
step = ::TurnipFormatter::Step.new(example, description)
|
12
|
-
step.extend TurnipFormatter::Step::Failure
|
13
|
-
step
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:klasses) do
|
17
|
-
builtin_klass1 = ::TurnipFormatter::StepTemplate::Source
|
18
|
-
builtin_klass2 = ::TurnipFormatter::StepTemplate::Exception
|
19
|
-
[builtin_klass1, builtin_klass2]
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'exists built-in step template' do
|
23
|
-
templates = TurnipFormatter::Step::Failure.templates
|
24
|
-
expect(templates.keys).to include(*klasses)
|
25
|
-
end
|
26
|
-
|
27
|
-
context 'add custom step template' do
|
28
|
-
let :custom_template do
|
29
|
-
Module.new do
|
30
|
-
def self.build(message)
|
31
|
-
'[error] ' + message
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
before do
|
37
|
-
TurnipFormatter::Step::Failure.add_template(custom_template) do
|
38
|
-
example.example_group.description
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
after do
|
43
|
-
TurnipFormatter::Step::Failure.remove_template(custom_template)
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should get custom step template' do
|
47
|
-
templates = TurnipFormatter::Step::Failure.templates
|
48
|
-
klasses << custom_template
|
49
|
-
expect(templates.keys).to include(*klasses)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '#attention?' do
|
54
|
-
subject { step.attention? }
|
55
|
-
it { should be true }
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '#status' do
|
59
|
-
subject { step.status }
|
60
|
-
it { should eq :failure }
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module TurnipFormatter
|
4
|
-
class Step
|
5
|
-
describe Failure do
|
6
|
-
include_context 'turnip_formatter standard step parameters'
|
7
|
-
include_context 'turnip_formatter pending scenario setup'
|
8
|
-
include_context 'turnip_formatter standard scenario metadata'
|
9
|
-
|
10
|
-
let(:step) do
|
11
|
-
step = ::TurnipFormatter::Step.new(example, description)
|
12
|
-
step.extend TurnipFormatter::Step::Pending
|
13
|
-
step
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:klasses) do
|
17
|
-
builtin_klass = ::TurnipFormatter::StepTemplate::Exception
|
18
|
-
[builtin_klass]
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'exists built-in step template' do
|
22
|
-
templates = TurnipFormatter::Step::Pending.templates
|
23
|
-
expect(templates.keys).to include(*klasses)
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'add custom step template' do
|
27
|
-
let :custom_template do
|
28
|
-
Module.new do
|
29
|
-
def self.build(message)
|
30
|
-
'[pending] ' + message
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
before do
|
36
|
-
TurnipFormatter::Step::Pending.add_template custom_template do
|
37
|
-
example.example_group.description
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
after do
|
42
|
-
TurnipFormatter::Step::Failure.remove_template custom_template
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should get custom step template' do
|
46
|
-
templates = TurnipFormatter::Step::Pending.templates
|
47
|
-
klasses << custom_template
|
48
|
-
expect(templates.keys).to include(*klasses)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe '#attention?' do
|
53
|
-
subject { step.attention? }
|
54
|
-
it { should be true }
|
55
|
-
end
|
56
|
-
|
57
|
-
describe '#status' do
|
58
|
-
subject { step.status }
|
59
|
-
it { should eq :pending }
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module TurnipFormatter
|
4
|
-
describe Step do
|
5
|
-
include_context 'turnip_formatter standard step parameters'
|
6
|
-
include_context 'turnip_formatter scenario setup'
|
7
|
-
include_context 'turnip_formatter standard scenario metadata'
|
8
|
-
let(:step) { ::TurnipFormatter::Step.new(example, description) }
|
9
|
-
|
10
|
-
describe '#attention?' do
|
11
|
-
subject { step.attention? }
|
12
|
-
it { should be false }
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '#name' do
|
16
|
-
subject { step.name }
|
17
|
-
it { should eq('KeywordStepName') }
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#docs' do
|
21
|
-
subject { step.docs }
|
22
|
-
it { should include :extra_args }
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'using template' do
|
26
|
-
let :custom_template1 do
|
27
|
-
Module.new do
|
28
|
-
def self.build(hoge)
|
29
|
-
hoge * 3
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
let :custom_template2 do
|
35
|
-
Module.new do
|
36
|
-
def self.build(hoge)
|
37
|
-
'aiueo' + hoge
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
before do
|
43
|
-
TurnipFormatter::Step.add_template :hoge, custom_template1 do
|
44
|
-
'12345'
|
45
|
-
end
|
46
|
-
|
47
|
-
TurnipFormatter::Step.add_template :hoge, custom_template2 do
|
48
|
-
'abcde'
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
after do
|
53
|
-
TurnipFormatter::Step.remove_template(:hoge, custom_template1)
|
54
|
-
TurnipFormatter::Step.remove_template(:hoge, custom_template2)
|
55
|
-
end
|
56
|
-
|
57
|
-
describe '#add_template' do
|
58
|
-
it 'can add step template' do
|
59
|
-
style1 = TurnipFormatter::Step.templates[:hoge][custom_template1]
|
60
|
-
klass1 = style1[:klass]
|
61
|
-
block1 = style1[:block]
|
62
|
-
expect(klass1.build(block1.call)).to eq('123451234512345')
|
63
|
-
|
64
|
-
style2 = TurnipFormatter::Step.templates[:hoge][custom_template2]
|
65
|
-
klass2 = style2[:klass]
|
66
|
-
block2 = style2[:block]
|
67
|
-
expect(klass2.build(block2.call)).to eq('aiueoabcde')
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe '#remove_template' do
|
72
|
-
it 'can remove step template' do
|
73
|
-
expect(TurnipFormatter::Step.templates[:hoge]).to have_key custom_template1
|
74
|
-
expect(TurnipFormatter::Step.templates[:hoge]).to have_key custom_template2
|
75
|
-
|
76
|
-
TurnipFormatter::Step.remove_template(:hoge, custom_template1)
|
77
|
-
expect(TurnipFormatter::Step.templates[:hoge]).not_to have_key custom_template1
|
78
|
-
expect(TurnipFormatter::Step.templates[:hoge]).to have_key custom_template2
|
79
|
-
|
80
|
-
TurnipFormatter::Step.remove_template(:hoge, custom_template2)
|
81
|
-
expect(TurnipFormatter::Step.templates).not_to have_key custom_template2
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|