forked from fastlane/fastlane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtml_generator_spec.rb
87 lines (73 loc) · 2.13 KB
/
html_generator_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
require 'deliver/html_generator'
require 'tmpdir'
describe Deliver::HtmlGenerator do
let(:generator) { Deliver::HtmlGenerator.new }
describe :render do
let(:screenshots) { [] }
context 'minimal configuration' do
let(:options) do
{
name: { 'en-US' => 'Fastlane Demo' },
description: { 'en-US' => 'Demo description' }
}
end
it 'renders HTML' do
expect(render(options, screenshots)).to match(/<html>/)
end
end
context 'with keywords' do
let(:options) do
{
name: { 'en-US' => 'Fastlane Demo' },
description: { 'en-US' => 'Demo description' },
keywords: { 'en-US' => 'Some, key, words' }
}
end
it 'renders HTML' do
capture = render(options, screenshots)
expect(capture).to match(/<html>/)
expect(capture).to include('<li>Some</li>')
expect(capture).to include('<li>key</li>')
expect(capture).to include('<li>words</li>')
end
end
private
def render(options, screenshots)
Dir.mktmpdir do |dir|
path = generator.render(options, screenshots, dir)
return File.read(path)
end
end
end
describe :split_keywords do
context 'only commas' do
let(:keywords) { 'One,Two, Three, Four Token,' }
it 'splits correctly' do
expected = ['One', 'Two', 'Three', 'Four Token']
expect(generator.split_keywords(keywords)).to eq(expected)
end
end
context 'only newlines' do
let(:keywords) { "One\nTwo\r\nThree\nFour Token\n" }
it 'splits correctly' do
expected = ['One', 'Two', 'Three', 'Four Token']
expect(generator.split_keywords(keywords)).to eq(expected)
end
end
context 'mixed' do
let(:keywords) { "One,Two, Three, Four Token,Or\nNewlines\r\nEverywhere" }
it 'splits correctly' do
expected = [
'One',
'Two',
'Three',
'Four Token',
'Or',
'Newlines',
'Everywhere'
]
expect(generator.split_keywords(keywords)).to eq(expected)
end
end
end
end