-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathhtml2text_spec.rb
More file actions
71 lines (57 loc) · 1.61 KB
/
Copy pathhtml2text_spec.rb
File metadata and controls
71 lines (57 loc) · 1.61 KB
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
# frozen_string_literal: true
require 'spec_helper'
describe Html2Text do
describe '#convert' do
let(:text) { Html2Text.convert(html) }
context 'an empty line' do
let(:html) { '' }
it 'is an empty line' do
expect(text).to eq('')
end
end
context 'a simple string' do
let(:html) { 'hello world' }
it 'is an empty line' do
expect(text).to eq('hello world')
end
end
context 'input value is non-string' do
let(:html) { nil }
it '(nil)' do
expect(text).to eq('')
end
end
context 'input value is non-string' do
let(:html) { 1234 }
it '(number)' do
expect(text).to eq('1234')
end
end
context 'input value is non-string' do
let(:html) { 1234.5600 }
it '(float number)' do
expect(text).to eq('1234.56')
end
end
end
describe '#remove_leading_and_trailing_whitespace' do
let(:subject) { Html2Text.new(nil).remove_leading_and_trailing_whitespace(input) }
context 'an empty string' do
let(:input) { '' }
it { is_expected.to eq('') }
end
context 'many new lines' do
let(:input) { "hello\n world \n yes" }
it { is_expected.to eq("hello\nworld\nyes") }
end
end
end
describe 'Wrapped links' do
describe 'when using the wrap_links: false option' do
let(:link_text) { '<a href="https://example.com">Click Here!</a>' }
let(:expected_text) { 'Click Here!: https://example.com' }
it 'returns an unwrapped link' do
expect(Html2Text.convert(link_text, wrap_links: false)).to eq(expected_text)
end
end
end