cucumber-html-formatter 21.0.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 +27 -22
- 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/assets/main.js.LICENSE.txt
CHANGED
@@ -5,88 +5,6 @@
|
|
5
5
|
* @license MIT
|
6
6
|
*/
|
7
7
|
|
8
|
-
/*!
|
9
|
-
* Font Awesome Free 6.2.1 by @fontawesome - https://fontawesome.com
|
10
|
-
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
11
|
-
* Copyright 2022 Fonticons, Inc.
|
12
|
-
*/
|
13
|
-
|
14
|
-
/*!
|
15
|
-
* elasticlunr.Configuration
|
16
|
-
* Copyright (C) 2016 Wei Song
|
17
|
-
*/
|
18
|
-
|
19
|
-
/*!
|
20
|
-
* elasticlunr.DocumentStore
|
21
|
-
* Copyright (C) 2016 Wei Song
|
22
|
-
*/
|
23
|
-
|
24
|
-
/*!
|
25
|
-
* elasticlunr.EventEmitter
|
26
|
-
* Copyright (C) 2016 Oliver Nightingale
|
27
|
-
* Copyright (C) 2016 Wei Song
|
28
|
-
*/
|
29
|
-
|
30
|
-
/*!
|
31
|
-
* elasticlunr.Index
|
32
|
-
* Copyright (C) 2016 Oliver Nightingale
|
33
|
-
* Copyright (C) 2016 Wei Song
|
34
|
-
*/
|
35
|
-
|
36
|
-
/*!
|
37
|
-
* elasticlunr.InvertedIndex
|
38
|
-
* Copyright (C) 2016 Wei Song
|
39
|
-
* Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt
|
40
|
-
*/
|
41
|
-
|
42
|
-
/*!
|
43
|
-
* elasticlunr.Pipeline
|
44
|
-
* Copyright (C) 2016 Oliver Nightingale
|
45
|
-
* Copyright (C) 2016 Wei Song
|
46
|
-
*/
|
47
|
-
|
48
|
-
/*!
|
49
|
-
* elasticlunr.js
|
50
|
-
* Copyright (C) 2016 Oliver Nightingale
|
51
|
-
* Copyright (C) 2016 Wei Song
|
52
|
-
*/
|
53
|
-
|
54
|
-
/*!
|
55
|
-
* elasticlunr.stemmer
|
56
|
-
* Copyright (C) 2016 Oliver Nightingale
|
57
|
-
* Copyright (C) 2016 Wei Song
|
58
|
-
* Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt
|
59
|
-
*/
|
60
|
-
|
61
|
-
/*!
|
62
|
-
* elasticlunr.stopWordFilter
|
63
|
-
* Copyright (C) 2016 Oliver Nightingale
|
64
|
-
* Copyright (C) 2016 Wei Song
|
65
|
-
*/
|
66
|
-
|
67
|
-
/*!
|
68
|
-
* elasticlunr.tokenizer
|
69
|
-
* Copyright (C) 2016 Oliver Nightingale
|
70
|
-
* Copyright (C) 2016 Wei Song
|
71
|
-
*/
|
72
|
-
|
73
|
-
/*!
|
74
|
-
* elasticlunr.trimmer
|
75
|
-
* Copyright (C) 2016 Oliver Nightingale
|
76
|
-
* Copyright (C) 2016 Wei Song
|
77
|
-
*/
|
78
|
-
|
79
|
-
/*!
|
80
|
-
* elasticlunr.utils
|
81
|
-
* Copyright (C) 2016 Oliver Nightingale
|
82
|
-
* Copyright (C) 2016 Wei Song
|
83
|
-
*/
|
84
|
-
|
85
|
-
/*!
|
86
|
-
* lunr.SortedSet
|
87
|
-
* Copyright (C) 2016 Oliver Nightingale
|
88
|
-
*/
|
89
|
-
|
90
8
|
/*!
|
91
9
|
* repeat-string <https://github.com/jonschlinkert/repeat-string>
|
92
10
|
*
|
@@ -139,16 +57,6 @@ and limitations under the License.
|
|
139
57
|
* LICENSE file in the root directory of this source tree.
|
140
58
|
*/
|
141
59
|
|
142
|
-
/**
|
143
|
-
* elasticlunr - http://weixsong.github.io
|
144
|
-
* Lightweight full-text search engine in Javascript for browser search and offline search. - 0.9.5
|
145
|
-
*
|
146
|
-
* Copyright (C) 2016 Oliver Nightingale
|
147
|
-
* Copyright (C) 2016 Wei Song
|
148
|
-
* MIT Licensed
|
149
|
-
* @license
|
150
|
-
*/
|
151
|
-
|
152
60
|
/** @license React v17.0.2
|
153
61
|
* react-is.production.min.js
|
154
62
|
*
|
data/bin/cucumber-html-formatter
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'optparse'
|
4
5
|
require 'cucumber/messages'
|
5
6
|
require 'cucumber/html_formatter'
|
6
7
|
|
7
|
-
formatter = Cucumber::HTMLFormatter::Formatter.new(
|
8
|
+
formatter = Cucumber::HTMLFormatter::Formatter.new($stdout)
|
8
9
|
|
9
10
|
option_parser = OptionParser.new do |opts|
|
10
|
-
opts.on_tail(
|
11
|
+
opts.on_tail('-h', '--help', 'Show this message') do
|
11
12
|
puts opts
|
12
13
|
exit
|
13
14
|
end
|
14
15
|
end
|
15
16
|
options = {}
|
16
17
|
option_parser.parse!(into: options)
|
17
|
-
message_enumerator = Cucumber::Messages::NdjsonToMessageEnumerator.new(
|
18
|
+
message_enumerator = Cucumber::Messages::NdjsonToMessageEnumerator.new($stdin)
|
18
19
|
|
19
20
|
formatter.process_messages(message_enumerator)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Cucumber
|
2
4
|
module HTMLFormatter
|
3
5
|
class AssetsLoader
|
@@ -25,10 +27,9 @@ module Cucumber
|
|
25
27
|
|
26
28
|
def html_formatter_path
|
27
29
|
Gem.loaded_specs['cucumber-html-formatter'].full_gem_path
|
28
|
-
rescue
|
30
|
+
rescue StandardError
|
29
31
|
'.'
|
30
32
|
end
|
31
|
-
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cucumber/messages'
|
4
|
+
require 'cucumber/html_formatter/template_writer'
|
5
|
+
require 'cucumber/html_formatter/assets_loader'
|
6
|
+
|
7
|
+
module Cucumber
|
8
|
+
module HTMLFormatter
|
9
|
+
class Formatter
|
10
|
+
attr_reader :out
|
11
|
+
|
12
|
+
def initialize(out)
|
13
|
+
@out = out
|
14
|
+
@pre_message_written = false
|
15
|
+
@first_message = true
|
16
|
+
end
|
17
|
+
|
18
|
+
def process_messages(messages)
|
19
|
+
write_pre_message
|
20
|
+
messages.each { |message| write_message(message) }
|
21
|
+
write_post_message
|
22
|
+
end
|
23
|
+
|
24
|
+
def write_message(message)
|
25
|
+
out.puts(',') unless @first_message
|
26
|
+
out.print(message.to_json)
|
27
|
+
|
28
|
+
@first_message = false
|
29
|
+
end
|
30
|
+
|
31
|
+
def write_pre_message
|
32
|
+
return if @pre_message_written
|
33
|
+
|
34
|
+
out.puts(pre_message)
|
35
|
+
@pre_message_written = true
|
36
|
+
end
|
37
|
+
|
38
|
+
def write_post_message
|
39
|
+
out.print(post_message)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def assets_loader
|
45
|
+
@assets_loader ||= AssetsLoader.new
|
46
|
+
end
|
47
|
+
|
48
|
+
def pre_message
|
49
|
+
[
|
50
|
+
template_writer.write_between(nil, '{{css}}'),
|
51
|
+
assets_loader.css,
|
52
|
+
template_writer.write_between('{{css}}', '{{messages}}')
|
53
|
+
].join("\n")
|
54
|
+
end
|
55
|
+
|
56
|
+
def post_message
|
57
|
+
[
|
58
|
+
template_writer.write_between('{{messages}}', '{{script}}'),
|
59
|
+
assets_loader.script,
|
60
|
+
template_writer.write_between('{{script}}', nil)
|
61
|
+
].join("\n")
|
62
|
+
end
|
63
|
+
|
64
|
+
def template_writer
|
65
|
+
@template_writer ||= TemplateWriter.new(assets_loader.template)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Cucumber
|
2
4
|
module HTMLFormatter
|
3
5
|
class TemplateWriter
|
@@ -11,9 +13,7 @@ module Cucumber
|
|
11
13
|
from_exists = !from.nil? && template.include?(from)
|
12
14
|
|
13
15
|
after_from = from_exists ? template.split(from)[1] : template
|
14
|
-
|
15
|
-
|
16
|
-
return before_to
|
16
|
+
to.nil? ? after_from : after_from.split(to)[0]
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -1,69 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'cucumber/messages'
|
2
|
-
require 'cucumber/html_formatter/template_writer'
|
3
4
|
require 'cucumber/html_formatter/assets_loader'
|
4
|
-
|
5
|
-
|
6
|
-
module HTMLFormatter
|
7
|
-
class Formatter
|
8
|
-
attr_reader :out
|
9
|
-
|
10
|
-
def initialize(out)
|
11
|
-
@out = out
|
12
|
-
@pre_message_written = false
|
13
|
-
@first_message = true
|
14
|
-
end
|
15
|
-
|
16
|
-
def process_messages(messages)
|
17
|
-
write_pre_message
|
18
|
-
messages.each { |message| write_message(message) }
|
19
|
-
write_post_message
|
20
|
-
end
|
21
|
-
|
22
|
-
def write_pre_message
|
23
|
-
return if @pre_message_written
|
24
|
-
|
25
|
-
out.puts(pre_message)
|
26
|
-
@pre_message_written = true
|
27
|
-
end
|
28
|
-
|
29
|
-
def write_message(message)
|
30
|
-
unless @first_message
|
31
|
-
out.puts(',')
|
32
|
-
end
|
33
|
-
out.print(message.to_json)
|
34
|
-
|
35
|
-
@first_message = false
|
36
|
-
end
|
37
|
-
|
38
|
-
def write_post_message
|
39
|
-
out.print(post_message)
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def assets_loader
|
45
|
-
@assets_loader ||= AssetsLoader.new
|
46
|
-
end
|
47
|
-
|
48
|
-
def pre_message
|
49
|
-
[
|
50
|
-
template_writer.write_between(nil, '{{css}}'),
|
51
|
-
assets_loader.css,
|
52
|
-
template_writer.write_between('{{css}}', '{{messages}}')
|
53
|
-
].join("\n")
|
54
|
-
end
|
55
|
-
|
56
|
-
def post_message
|
57
|
-
[
|
58
|
-
template_writer.write_between('{{messages}}', '{{script}}'),
|
59
|
-
assets_loader.script,
|
60
|
-
template_writer.write_between('{{script}}', nil)
|
61
|
-
].join("\n")
|
62
|
-
end
|
63
|
-
|
64
|
-
def template_writer
|
65
|
-
@template_writer ||= TemplateWriter.new(assets_loader.template)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
5
|
+
require 'cucumber/html_formatter/formatter'
|
6
|
+
require 'cucumber/html_formatter/template_writer'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-html-formatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 21.
|
4
|
+
version: 21.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Prêtre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber-messages
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '19'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '25'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,21 @@ dependencies:
|
|
29
29
|
version: '19'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '25'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: cucumber-compatibility-kit
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '14.1'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '14.1'
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
48
|
name: rake
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,33 +73,33 @@ dependencies:
|
|
59
73
|
- !ruby/object:Gem::Version
|
60
74
|
version: '3.12'
|
61
75
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
76
|
+
name: rubocop
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|
64
78
|
requirements:
|
65
79
|
- - "~>"
|
66
80
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
81
|
+
version: 1.41.0
|
68
82
|
type: :development
|
69
83
|
prerelease: false
|
70
84
|
version_requirements: !ruby/object:Gem::Requirement
|
71
85
|
requirements:
|
72
86
|
- - "~>"
|
73
87
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
88
|
+
version: 1.41.0
|
75
89
|
- !ruby/object:Gem::Dependency
|
76
|
-
name: rubocop
|
90
|
+
name: rubocop-rake
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
78
92
|
requirements:
|
79
93
|
- - "~>"
|
80
94
|
- !ruby/object:Gem::Version
|
81
|
-
version:
|
95
|
+
version: 0.6.0
|
82
96
|
type: :development
|
83
97
|
prerelease: false
|
84
98
|
version_requirements: !ruby/object:Gem::Requirement
|
85
99
|
requirements:
|
86
100
|
- - "~>"
|
87
101
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
102
|
+
version: 0.6.0
|
89
103
|
- !ruby/object:Gem::Dependency
|
90
104
|
name: rubocop-rspec
|
91
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,12 +129,8 @@ files:
|
|
115
129
|
- bin/cucumber-html-formatter
|
116
130
|
- lib/cucumber/html_formatter.rb
|
117
131
|
- lib/cucumber/html_formatter/assets_loader.rb
|
132
|
+
- lib/cucumber/html_formatter/formatter.rb
|
118
133
|
- lib/cucumber/html_formatter/template_writer.rb
|
119
|
-
- spec/acceptance_spec.rb
|
120
|
-
- spec/capture_warnings.rb
|
121
|
-
- spec/html-formatter/assets_loader_spec.rb
|
122
|
-
- spec/html-formatter/template_writer_spec.rb
|
123
|
-
- spec/html_formatter_spec.rb
|
124
134
|
homepage: https://github.com/cucumber/html-formatter
|
125
135
|
licenses:
|
126
136
|
- MIT
|
@@ -150,10 +160,5 @@ requirements: []
|
|
150
160
|
rubygems_version: 3.4.10
|
151
161
|
signing_key:
|
152
162
|
specification_version: 4
|
153
|
-
summary: cucumber-html-formatter-21.
|
154
|
-
test_files:
|
155
|
-
- spec/acceptance_spec.rb
|
156
|
-
- spec/capture_warnings.rb
|
157
|
-
- spec/html-formatter/assets_loader_spec.rb
|
158
|
-
- spec/html-formatter/template_writer_spec.rb
|
159
|
-
- spec/html_formatter_spec.rb
|
163
|
+
summary: cucumber-html-formatter-21.2.0
|
164
|
+
test_files: []
|
data/spec/acceptance_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'cucumber-compatibility-kit'
|
2
|
-
require 'cucumber/html_formatter'
|
3
|
-
|
4
|
-
describe Cucumber::HTMLFormatter.name do
|
5
|
-
|
6
|
-
Cucumber::CompatibilityKit.gherkin_examples.each do |example_name|
|
7
|
-
def run_formatter(messages)
|
8
|
-
out = StringIO.new
|
9
|
-
formatter = Cucumber::HTMLFormatter::Formatter.new(out)
|
10
|
-
formatter.process_messages(messages)
|
11
|
-
out.string
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "'#{example_name}' example" do
|
15
|
-
subject(:html_report) { run_formatter(File.readlines(example_ndjson)) }
|
16
|
-
|
17
|
-
let(:example_ndjson) { "#{Cucumber::CompatibilityKit.example_path(example_name)}/#{example_name}.feature.ndjson" }
|
18
|
-
|
19
|
-
it { is_expected.to match(/\A<!DOCTYPE html>\s?<html/) }
|
20
|
-
it { is_expected.to match(/<\/html>\Z/) }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
Cucumber::CompatibilityKit.markdown_examples.each do |example_name|
|
25
|
-
describe "'#{example_name}' example" do
|
26
|
-
let(:example_ndjson) { "#{Cucumber::CompatibilityKit.example_path(example_name)}/#{example_name}.feature.md.ndjson" }
|
27
|
-
subject(:html_report) { run_formatter(File.readlines(example_ndjson)) }
|
28
|
-
|
29
|
-
it { is_expected.to match(/\A<!DOCTYPE html>\s?<html/) }
|
30
|
-
it { is_expected.to match(/<\/html>\Z/) }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/spec/capture_warnings.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# With thanks to @myronmarston
|
3
|
-
# https://github.com/vcr/vcr/blob/master/spec/capture_warnings.rb
|
4
|
-
|
5
|
-
module CaptureWarnings
|
6
|
-
def report_warnings(&block)
|
7
|
-
current_dir = Dir.pwd
|
8
|
-
warnings, errors = capture_error(&block).partition { |line| line.include?('warning') }
|
9
|
-
project_warnings, other_warnings = warnings.uniq.partition { |line| line.include?(current_dir) }
|
10
|
-
|
11
|
-
if errors.any?
|
12
|
-
puts errors.join("\n")
|
13
|
-
end
|
14
|
-
|
15
|
-
if other_warnings.any?
|
16
|
-
puts "#{ other_warnings.count } warnings detected, set VIEW_OTHER_WARNINGS=true to see them."
|
17
|
-
print_warnings('other', other_warnings) if ENV['VIEW_OTHER_WARNINGS']
|
18
|
-
end
|
19
|
-
|
20
|
-
# Until they fix https://bugs.ruby-lang.org/issues/10661
|
21
|
-
if RUBY_VERSION == "2.2.0"
|
22
|
-
project_warnings = project_warnings.reject { |w| w =~ /warning: possible reference to past scope/ }
|
23
|
-
end
|
24
|
-
|
25
|
-
if project_warnings.any?
|
26
|
-
puts "#{ project_warnings.count } warnings detected"
|
27
|
-
print_warnings('cucumber-expressions', project_warnings)
|
28
|
-
fail "Please remove all cucumber-expressions warnings."
|
29
|
-
end
|
30
|
-
|
31
|
-
ensure_system_exit_if_required
|
32
|
-
end
|
33
|
-
|
34
|
-
def capture_error(&block)
|
35
|
-
old_stderr = STDERR.clone
|
36
|
-
pipe_r, pipe_w = IO.pipe
|
37
|
-
pipe_r.sync = true
|
38
|
-
error = String.new
|
39
|
-
reader = Thread.new do
|
40
|
-
begin
|
41
|
-
loop do
|
42
|
-
error << pipe_r.readpartial(1024)
|
43
|
-
end
|
44
|
-
rescue EOFError
|
45
|
-
end
|
46
|
-
end
|
47
|
-
STDERR.reopen(pipe_w)
|
48
|
-
block.call
|
49
|
-
ensure
|
50
|
-
capture_system_exit
|
51
|
-
STDERR.reopen(old_stderr)
|
52
|
-
pipe_w.close
|
53
|
-
reader.join
|
54
|
-
return error.split("\n")
|
55
|
-
end
|
56
|
-
|
57
|
-
def print_warnings(type, warnings)
|
58
|
-
puts
|
59
|
-
puts "-" * 30 + " #{type} warnings: " + "-" * 30
|
60
|
-
puts
|
61
|
-
puts warnings.join("\n")
|
62
|
-
puts
|
63
|
-
puts "-" * 75
|
64
|
-
puts
|
65
|
-
end
|
66
|
-
|
67
|
-
def ensure_system_exit_if_required
|
68
|
-
raise @system_exit if @system_exit
|
69
|
-
end
|
70
|
-
|
71
|
-
def capture_system_exit
|
72
|
-
@system_exit = $!
|
73
|
-
end
|
74
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'cucumber/html_formatter/assets_loader'
|
2
|
-
|
3
|
-
describe Cucumber::HTMLFormatter::AssetsLoader do
|
4
|
-
let(:subject) { Cucumber::HTMLFormatter::AssetsLoader.new }
|
5
|
-
|
6
|
-
before do
|
7
|
-
allow(File).to receive(:read).and_return('whatever content')
|
8
|
-
end
|
9
|
-
|
10
|
-
context '.template' do
|
11
|
-
it 'reads the content of assets/index.mustache.html' do
|
12
|
-
expect(subject.template).to eq('whatever content')
|
13
|
-
expect(File).to have_received(:read).with(/.*\/assets\/index\.mustache\.html$/)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context '.css' do
|
18
|
-
it 'reads the content of assets/main.css' do
|
19
|
-
expect(subject.css).to eq('whatever content')
|
20
|
-
expect(File).to have_received(:read).with(/.*\/assets\/main\.css$/)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context '.script' do
|
25
|
-
it 'reads the content of assets/main.js' do
|
26
|
-
expect(subject.script).to eq('whatever content')
|
27
|
-
expect(File).to have_received(:read).with(/.*\/assets\/main\.js$/)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'cucumber/html_formatter/template_writer'
|
2
|
-
|
3
|
-
describe Cucumber::HTMLFormatter::TemplateWriter do
|
4
|
-
context 'write_between' do
|
5
|
-
let(:subject) { writer = Cucumber::HTMLFormatter::TemplateWriter.new(template) }
|
6
|
-
let(:template) { 'Some template {{here}} with content after' }
|
7
|
-
|
8
|
-
it 'outputs content of the template between the given words' do
|
9
|
-
expect(subject.write_between('Some', 'content')).to eq(' template {{here}} with ')
|
10
|
-
end
|
11
|
-
|
12
|
-
context 'when "from" argument is nil' do
|
13
|
-
it 'outputs template from the beginning' do
|
14
|
-
expect(subject.write_between(nil, '{{here}}')).to eq('Some template ')
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'when "to" argument is nil' do
|
19
|
-
it 'outputs content of template after the "from" argument value' do
|
20
|
-
expect(subject.write_between('{{here}}', nil)).to eq(' with content after')
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'when "from" argument is missing from the template' do
|
25
|
-
it 'renders the template from the beginning' do
|
26
|
-
expect(subject.write_between('Unknown start', '{{here}}')).to eq('Some template ')
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
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
|