cucumber-html-formatter 20.4.0 → 21.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.
- checksums.yaml +4 -4
- data/assets/main.js +1 -1
- data/assets/main.js.LICENSE.txt +0 -92
- data/bin/cucumber-html-formatter +4 -3
- data/lib/cucumber/html_formatter/assets_loader.rb +3 -2
- data/lib/cucumber/html_formatter/formatter.rb +69 -0
- data/lib/cucumber/html_formatter/template_writer.rb +3 -3
- data/lib/cucumber/html_formatter.rb +4 -67
- metadata +61 -46
- data/spec/acceptance_spec.rb +0 -33
- data/spec/capture_warnings.rb +0 -74
- data/spec/html-formatter/assets_loader_spec.rb +0 -30
- data/spec/html-formatter/template_writer_spec.rb +0 -30
- data/spec/html_formatter_spec.rb +0 -87
data/spec/html_formatter_spec.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'cucumber/messages'
|
2
|
-
require 'cucumber/html_formatter'
|
3
|
-
|
4
|
-
class FakeAssets
|
5
|
-
def template
|
6
|
-
"<html>{{css}}<body>{{messages}}</body>{{script}}</html>"
|
7
|
-
end
|
8
|
-
|
9
|
-
def css
|
10
|
-
"<style>div { color: red }</style>"
|
11
|
-
end
|
12
|
-
|
13
|
-
def script
|
14
|
-
"<script>alert('Hi')</script>"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe Cucumber::HTMLFormatter::Formatter do
|
19
|
-
let(:subject) {
|
20
|
-
formatter = Cucumber::HTMLFormatter::Formatter.new(out)
|
21
|
-
allow(formatter).to receive(:assets_loader).and_return(assets)
|
22
|
-
formatter
|
23
|
-
}
|
24
|
-
let(:out) { StringIO.new }
|
25
|
-
let(:assets) { FakeAssets.new }
|
26
|
-
|
27
|
-
context '.write_pre_message' do
|
28
|
-
it 'outputs the content of the template up to {{messages}}' do
|
29
|
-
subject.write_pre_message()
|
30
|
-
expect(out.string).to eq("<html>\n<style>div { color: red }</style>\n<body>\n")
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'does not write the content twice' do
|
34
|
-
subject.write_pre_message()
|
35
|
-
subject.write_pre_message()
|
36
|
-
|
37
|
-
expect(out.string).to eq("<html>\n<style>div { color: red }</style>\n<body>\n")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context '.write_message' do
|
42
|
-
let(:message) do
|
43
|
-
::Cucumber::Messages::Envelope.new(
|
44
|
-
pickle: ::Cucumber::Messages::Pickle.new(id: 'some-random-uid')
|
45
|
-
)
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'appends the message to out' do
|
49
|
-
subject.write_message(message)
|
50
|
-
expect(out.string).to eq(message.to_json)
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'adds commas between the messages' do
|
54
|
-
subject.write_message(message)
|
55
|
-
subject.write_message(message)
|
56
|
-
|
57
|
-
expect(out.string).to eq("#{message.to_json},\n#{message.to_json}")
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context '.write_post_message' do
|
62
|
-
it 'outputs the template end' do
|
63
|
-
subject.write_post_message()
|
64
|
-
expect(out.string).to eq("</body>\n<script>alert('Hi')</script>\n</html>")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context '.process_messages' do
|
69
|
-
let(:message) do
|
70
|
-
::Cucumber::Messages::Envelope.new(
|
71
|
-
pickle: ::Cucumber::Messages::Pickle.new(id: 'some-random-uid')
|
72
|
-
)
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'produces the full html report' do
|
76
|
-
subject.process_messages([message])
|
77
|
-
expect(out.string).to eq([
|
78
|
-
'<html>',
|
79
|
-
'<style>div { color: red }</style>',
|
80
|
-
'<body>',
|
81
|
-
"#{message.to_json}</body>",
|
82
|
-
"<script>alert('Hi')</script>",
|
83
|
-
'</html>'
|
84
|
-
].join("\n"))
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|