turnip_formatter 0.6.0.pre.beta.2 → 0.6.0.pre.beta.3
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 +0 -1
- data/Rakefile +3 -2
- data/lib/rspec/core/formatters/turnip_formatter.rb +8 -9
- data/lib/turnip_formatter/ext/turnip/rspec.rb +6 -5
- data/lib/turnip_formatter/{template → renderer/html/assets}/turnip_formatter.css +1 -1
- data/lib/turnip_formatter/{template → renderer/html/assets}/turnip_formatter.js +0 -0
- data/lib/turnip_formatter/{template → renderer/html/assets}/turnip_formatter.scss +1 -1
- data/lib/turnip_formatter/renderer/html/base.rb +4 -4
- data/lib/turnip_formatter/renderer/html/index.rb +83 -0
- data/lib/turnip_formatter/renderer/html/runtime_error.rb +20 -0
- data/lib/turnip_formatter/renderer/html/scenario.rb +20 -0
- data/lib/turnip_formatter/renderer/html/statistics_feature.rb +45 -0
- data/lib/turnip_formatter/renderer/html/statistics_speed.rb +39 -0
- data/lib/turnip_formatter/renderer/html/statistics_tag.rb +53 -0
- data/lib/turnip_formatter/renderer/html/views/index.html.erb +94 -0
- data/lib/turnip_formatter/renderer/html/views/runtime_error.html.erb +20 -0
- data/lib/turnip_formatter/renderer/html/views/scenario.html.erb +23 -0
- data/lib/turnip_formatter/renderer/html/views/statistics_feature.html.erb +24 -0
- data/lib/turnip_formatter/renderer/html/views/statistics_speed.html.erb +24 -0
- data/lib/turnip_formatter/renderer/html/views/statistics_tag.html.erb +24 -0
- data/lib/turnip_formatter/renderer/html.rb +84 -0
- data/lib/turnip_formatter/resource/scenario/base.rb +80 -0
- data/lib/turnip_formatter/resource/scenario/failure.rb +50 -0
- data/lib/turnip_formatter/resource/scenario/pass.rb +10 -0
- data/lib/turnip_formatter/resource/scenario/pending.rb +42 -0
- data/lib/turnip_formatter/version.rb +1 -1
- data/lib/turnip_formatter.rb +8 -4
- data/test/helper.rb +64 -12
- data/test/turnip_formatter/renderer/html/test_index.rb +102 -0
- data/test/turnip_formatter/renderer/html/test_runtime_error.rb +40 -0
- data/test/turnip_formatter/renderer/html/test_statistics_feature.rb +102 -0
- data/test/turnip_formatter/renderer/html/test_statistics_speed.rb +77 -0
- data/test/turnip_formatter/renderer/html/test_statistics_tag.rb +112 -0
- data/test/turnip_formatter/renderer/html/test_step.rb +27 -0
- data/test/turnip_formatter/renderer/test_html.rb +75 -0
- data/test/turnip_formatter/resource/scenario/test_failure.rb +39 -0
- data/test/turnip_formatter/resource/scenario/test_pass.rb +65 -0
- data/test/turnip_formatter/resource/scenario/test_pending.rb +39 -0
- data/turnip_formatter.gemspec +1 -1
- metadata +45 -57
- data/lib/turnip_formatter/printer/index.rb +0 -26
- data/lib/turnip_formatter/printer/runtime_error.rb +0 -36
- data/lib/turnip_formatter/printer/scenario.rb +0 -22
- data/lib/turnip_formatter/printer/tab_feature_statistics.rb +0 -46
- data/lib/turnip_formatter/printer/tab_speed_statistics.rb +0 -35
- data/lib/turnip_formatter/printer/tab_tag_statistics.rb +0 -76
- data/lib/turnip_formatter/printer.rb +0 -29
- data/lib/turnip_formatter/scenario/base.rb +0 -99
- data/lib/turnip_formatter/scenario/failure.rb +0 -44
- data/lib/turnip_formatter/scenario/pass.rb +0 -8
- data/lib/turnip_formatter/scenario/pending.rb +0 -40
- data/lib/turnip_formatter/step.rb +0 -23
- data/lib/turnip_formatter/template/exception.slim +0 -8
- data/lib/turnip_formatter/template/index.slim +0 -86
- data/lib/turnip_formatter/template/runtime_exception.slim +0 -13
- data/lib/turnip_formatter/template/scenario.slim +0 -15
- data/lib/turnip_formatter/template/tab_feature_statistics.slim +0 -18
- data/lib/turnip_formatter/template/tab_speed_statistics.slim +0 -16
- data/lib/turnip_formatter/template/tab_tag_statistics.slim +0 -18
- data/spec/turnip_formatter/printer/index_spec.rb +0 -38
- data/spec/turnip_formatter/printer/scenario_spec.rb +0 -42
- data/spec/turnip_formatter/printer/tab_feature_statistics_spec.rb +0 -80
- data/spec/turnip_formatter/printer/tab_speed_statistics_spec.rb +0 -48
- data/spec/turnip_formatter/printer/tab_tag_statistics_spec.rb +0 -103
- data/spec/turnip_formatter/scenario/base_spec.rb +0 -67
- data/spec/turnip_formatter/scenario/failure_spec.rb +0 -55
- data/spec/turnip_formatter/scenario/pending_spec.rb +0 -51
- data/spec/turnip_formatter/template_spec.rb +0 -119
- data/test/sample.feature +0 -16
@@ -1,103 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'turnip_formatter/printer/tab_tag_statistics'
|
3
|
-
|
4
|
-
module TurnipFormatter::Printer
|
5
|
-
describe TabTagStatistics do
|
6
|
-
let :base_scenario do
|
7
|
-
TurnipFormatter::Scenario::Pass.new(passed_example)
|
8
|
-
end
|
9
|
-
|
10
|
-
let :scenarios do
|
11
|
-
scenarios = []
|
12
|
-
|
13
|
-
# | tag | scenarios | passed | failed | pending | status |
|
14
|
-
# |-------+-----------+--------+--------+---------+---------|
|
15
|
-
# | none | 1 | 1 | 0 | 0 | status |
|
16
|
-
# | @bar | 2 | 0 | 1 | 1 | failed |
|
17
|
-
# | @foo | 1 | 0 | 1 | 0 | failed |
|
18
|
-
# | @hoge | 1 | 1 | 0 | 1 | pending |
|
19
|
-
|
20
|
-
# Failed scenario have tags @hoge and @fuga
|
21
|
-
scenario = base_scenario.dup
|
22
|
-
allow(scenario).to receive(:tags).and_return(['foo', 'bar'])
|
23
|
-
allow(scenario).to receive(:validation).and_return(true)
|
24
|
-
allow(scenario).to receive(:status).and_return('failed')
|
25
|
-
scenarios << scenario
|
26
|
-
|
27
|
-
# Passed scenario no have tags
|
28
|
-
scenario = base_scenario.dup
|
29
|
-
allow(scenario).to receive(:tags).and_return([])
|
30
|
-
allow(scenario).to receive(:validation).and_return(true)
|
31
|
-
allow(scenario).to receive(:status).and_return('passed')
|
32
|
-
scenarios << scenario
|
33
|
-
|
34
|
-
# Passed scenario have tags @hoge
|
35
|
-
scenario = base_scenario.dup
|
36
|
-
allow(scenario).to receive(:tags).and_return(['hoge'])
|
37
|
-
allow(scenario).to receive(:validation).and_return(true)
|
38
|
-
allow(scenario).to receive(:status).and_return('passed')
|
39
|
-
scenarios << scenario
|
40
|
-
|
41
|
-
# Pending scenario have tags @fuga and @hago
|
42
|
-
scenario = base_scenario.dup
|
43
|
-
allow(scenario).to receive(:tags).and_return(['bar', 'hoge'])
|
44
|
-
allow(scenario).to receive(:validation).and_return(true)
|
45
|
-
allow(scenario).to receive(:status).and_return('pending')
|
46
|
-
scenarios << scenario
|
47
|
-
end
|
48
|
-
|
49
|
-
let :statistics do
|
50
|
-
TurnipFormatter::Printer::TabTagStatistics
|
51
|
-
end
|
52
|
-
|
53
|
-
let :groups do
|
54
|
-
statistics.send(:group_by_tag, scenarios)
|
55
|
-
end
|
56
|
-
|
57
|
-
describe '.group_by_tag' do
|
58
|
-
it 'should get results sort by tag name' do
|
59
|
-
expect(groups.map(&:first)).to eq ['@bar', '@foo', '@hoge', 'turnip']
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe '.tag_analysis' do
|
64
|
-
it 'should get count of each status' do
|
65
|
-
# @bar
|
66
|
-
group = groups[0]
|
67
|
-
statistics.send(:tag_analysis, group[0], group[1]).tap do |result|
|
68
|
-
expect(result.passed_count).to eq 0
|
69
|
-
expect(result.failed_count).to eq 1
|
70
|
-
expect(result.pending_count).to eq 1
|
71
|
-
expect(result.status).to eq 'failed'
|
72
|
-
end
|
73
|
-
|
74
|
-
# @foo
|
75
|
-
group = groups[1]
|
76
|
-
statistics.send(:tag_analysis, group[0], group[1]).tap do |result|
|
77
|
-
expect(result.passed_count).to eq 0
|
78
|
-
expect(result.failed_count).to eq 1
|
79
|
-
expect(result.pending_count).to eq 0
|
80
|
-
expect(result.status).to eq 'failed'
|
81
|
-
end
|
82
|
-
|
83
|
-
# @hoge
|
84
|
-
group = groups[2]
|
85
|
-
statistics.send(:tag_analysis, group[0], group[1]).tap do |result|
|
86
|
-
expect(result.passed_count).to eq 1
|
87
|
-
expect(result.failed_count).to eq 0
|
88
|
-
expect(result.pending_count).to eq 1
|
89
|
-
expect(result.status).to eq 'pending'
|
90
|
-
end
|
91
|
-
|
92
|
-
# no tags (turnip)
|
93
|
-
group = groups[3]
|
94
|
-
statistics.send(:tag_analysis, group[0], group[1]).tap do |result|
|
95
|
-
expect(result.passed_count).to eq 1
|
96
|
-
expect(result.failed_count).to eq 0
|
97
|
-
expect(result.pending_count).to eq 0
|
98
|
-
expect(result.status).to eq 'passed'
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe TurnipFormatter::Scenario::Base do
|
4
|
-
let(:example) { passed_example }
|
5
|
-
let(:scenario) { described_class.new(example) }
|
6
|
-
|
7
|
-
describe '#valid?' do
|
8
|
-
subject { scenario.valid? }
|
9
|
-
|
10
|
-
context 'called by turnip example' do
|
11
|
-
it { should be true }
|
12
|
-
end
|
13
|
-
|
14
|
-
context 'called by not turnip example' do
|
15
|
-
let(:example) do
|
16
|
-
passed_example.tap { |e| e.metadata.delete(:turnip_formatter) }
|
17
|
-
end
|
18
|
-
|
19
|
-
it { should be false }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#id' do
|
24
|
-
it 'returns unique string' do
|
25
|
-
expect(scenario.id).to start_with 'scenario_'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe '#steps' do
|
30
|
-
subject { scenario.steps }
|
31
|
-
|
32
|
-
it 'returns step array' do
|
33
|
-
expect(subject).to be_a Array
|
34
|
-
expect(subject[0]).to be_a TurnipFormatter::Resource::Step
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe '#name' do
|
39
|
-
it 'returns scenario name' do
|
40
|
-
expect(scenario.name).to eq 'Scenario'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '#status' do
|
45
|
-
it 'returns scenario status' do
|
46
|
-
expect(scenario.status).to eq 'passed'
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe '#run_time' do
|
51
|
-
it 'returns run time(second) of scenario' do
|
52
|
-
expect(scenario.run_time).to be_a Float
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe '#feature_info' do
|
57
|
-
it 'returns feature name and filepath' do
|
58
|
-
expect(scenario.feature_info).to eq '"Feature" in /path/to/hoge.feature'
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe '#tags' do
|
63
|
-
it 'returns tags' do
|
64
|
-
expect(scenario.tags).to be_a Array
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe TurnipFormatter::Scenario::Failure do
|
4
|
-
let(:example) { failed_example }
|
5
|
-
let(:scenario) { described_class.new(example) }
|
6
|
-
|
7
|
-
describe '#steps' do
|
8
|
-
let(:example) do
|
9
|
-
example = failed_example
|
10
|
-
example.metadata[:turnip_formatter] = {
|
11
|
-
steps: [
|
12
|
-
create_step_node('When', 'Step 1', 1),
|
13
|
-
create_step_node('When', 'Step 2', 3),
|
14
|
-
create_step_node('When', 'Step 3', 10), # failed line
|
15
|
-
create_step_node('When', 'Step 4', 11),
|
16
|
-
create_step_node('When', 'Step 5', 12)
|
17
|
-
],
|
18
|
-
tags: []
|
19
|
-
}
|
20
|
-
example
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should return steps that has status' do
|
24
|
-
expect = [:passed, :passed, :failed, :unexecuted, :unexecuted]
|
25
|
-
actual = scenario.steps.map(&:status)
|
26
|
-
expect(actual).to eq expect
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '#valid?' do
|
31
|
-
subject { scenario.valid? }
|
32
|
-
|
33
|
-
context 'called by turnip example' do
|
34
|
-
it { should be true }
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'called by not turnip example' do
|
38
|
-
let(:example) do
|
39
|
-
backtrace = failed_example.exception.backtrace.reject do |b|
|
40
|
-
b.include? failed_example.metadata[:file_path]
|
41
|
-
end
|
42
|
-
|
43
|
-
failed_example.tap { |e| e.exception.set_backtrace(backtrace) }
|
44
|
-
end
|
45
|
-
|
46
|
-
it { should be false }
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe '#status' do
|
51
|
-
it 'return scenario status' do
|
52
|
-
expect(scenario.status).to eq 'failed'
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe TurnipFormatter::Scenario::Pending do
|
4
|
-
let(:example) { pending_example }
|
5
|
-
let(:scenario) { described_class.new(example) }
|
6
|
-
|
7
|
-
describe '#steps' do
|
8
|
-
let(:example) do
|
9
|
-
example = pending_example
|
10
|
-
example.metadata[:turnip_formatter] = {
|
11
|
-
steps: [
|
12
|
-
create_step_node('When', 'Step 1', 1),
|
13
|
-
create_step_node('When', 'Step 2', 3),
|
14
|
-
create_step_node('When', 'Step 3', 10), # pending line
|
15
|
-
create_step_node('When', 'Step 4', 11),
|
16
|
-
create_step_node('When', 'Step 5', 12)
|
17
|
-
],
|
18
|
-
tags: []
|
19
|
-
}
|
20
|
-
example
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should return steps that has status' do
|
24
|
-
expect = [:passed, :passed, :pending, :unexecuted, :unexecuted]
|
25
|
-
actual = scenario.steps.map(&:status)
|
26
|
-
expect(actual).to eq expect
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '#valid?' do
|
31
|
-
subject { scenario.valid? }
|
32
|
-
|
33
|
-
context 'called by turnip example' do
|
34
|
-
it { should be true }
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'called by not turnip example' do
|
38
|
-
let(:example) do
|
39
|
-
pending_example.tap { |e| e.metadata[:line_number] = nil }
|
40
|
-
end
|
41
|
-
|
42
|
-
it { should be false }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '#status' do
|
47
|
-
it 'return scenario status' do
|
48
|
-
expect(scenario.status).to eq 'pending'
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,119 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'tempfile'
|
3
|
-
|
4
|
-
describe TurnipFormatter::Template do
|
5
|
-
let(:template) { described_class }
|
6
|
-
|
7
|
-
let(:local_js_path) do
|
8
|
-
Tempfile.open('local.js') do |f|
|
9
|
-
f.write('alert("local!");')
|
10
|
-
f.path
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
let(:local_css_path) do
|
15
|
-
Tempfile.open('local.css') do |f|
|
16
|
-
f.write('body { color: green; }')
|
17
|
-
f.path
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
let(:remote_js_path) { 'http://example.com/foo.js' }
|
22
|
-
let(:remote_css_path) { 'http://example.com/foo.css' }
|
23
|
-
|
24
|
-
before do
|
25
|
-
template.reset!
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '.render_javascript_codes' do
|
29
|
-
subject { template.render_javascript_codes }
|
30
|
-
|
31
|
-
before do
|
32
|
-
template.add_javascript(path)
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'added local javascript file' do
|
36
|
-
let(:path) { local_js_path }
|
37
|
-
it { should include 'alert("local!");' }
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'add remote javascript file' do
|
41
|
-
let(:path) { remote_js_path }
|
42
|
-
it { should be_empty }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '.render_javascript_links' do
|
47
|
-
subject { template.render_javascript_links }
|
48
|
-
|
49
|
-
before do
|
50
|
-
template.add_javascript(path)
|
51
|
-
end
|
52
|
-
|
53
|
-
context 'added local javascript file' do
|
54
|
-
let(:path) { local_js_path }
|
55
|
-
it { should be_empty }
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'add remote javascript file' do
|
59
|
-
let(:path) { remote_js_path }
|
60
|
-
it { should include %Q(<script src="#{path}"></script>) }
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'add remote javascript file (no schema)' do
|
64
|
-
let(:path) { '//example.com/foo.js' }
|
65
|
-
it { should include %Q(<script src="#{path}"></script>) }
|
66
|
-
end
|
67
|
-
|
68
|
-
context 'add incorrect uri' do
|
69
|
-
let(:path) { 'http://e xample.com/foo.js' }
|
70
|
-
it { should be_empty }
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '.render_stylesheet_codes' do
|
75
|
-
subject { template.render_stylesheet_codes }
|
76
|
-
|
77
|
-
before do
|
78
|
-
template.add_stylesheet(path)
|
79
|
-
end
|
80
|
-
|
81
|
-
context 'added local stylesheet file' do
|
82
|
-
let(:path) { local_css_path }
|
83
|
-
it { should include 'body { color: green; }' }
|
84
|
-
end
|
85
|
-
|
86
|
-
context 'add remote stylesheet file' do
|
87
|
-
let(:path) { remote_css_path }
|
88
|
-
it { should be_empty }
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe '.render_stylesheet_links' do
|
93
|
-
subject { template.render_stylesheet_links }
|
94
|
-
|
95
|
-
before do
|
96
|
-
template.add_stylesheet(path)
|
97
|
-
end
|
98
|
-
|
99
|
-
context 'added local stylesheet file' do
|
100
|
-
let(:path) { local_js_path }
|
101
|
-
it { should be_empty }
|
102
|
-
end
|
103
|
-
|
104
|
-
context 'add remote stylesheet file' do
|
105
|
-
let(:path) { remote_css_path }
|
106
|
-
it { should include %Q(<link rel="stylesheet" href="#{path}">) }
|
107
|
-
end
|
108
|
-
|
109
|
-
context 'add remote stylesheet file (no schema)' do
|
110
|
-
let(:path) { '//example.com/foo.css' }
|
111
|
-
it { should include %Q(<link rel="stylesheet" href="#{path}">) }
|
112
|
-
end
|
113
|
-
|
114
|
-
context 'add incorrect uri' do
|
115
|
-
let(:path) { 'http://e xample.com/foo.css' }
|
116
|
-
it { should be_empty }
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
data/test/sample.feature
DELETED