-
Notifications
You must be signed in to change notification settings - Fork 3
/
string_spec.rb
56 lines (44 loc) · 1.15 KB
/
string_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
# frozen_string_literal: true
RSpec.describe String do
describe '#present?' do
context 'when nil' do
let(:string) { nil }
it 'returns false' do
expect(string.present?).to eq(false)
end
end
context 'when whitespaces only' do
let(:string) { ' ' }
it 'returns false' do
expect(string.present?).to eq(false)
end
end
context 'when whitespaces and other characters' do
let(:string) { ' TAP format is cool! ' }
it 'returns true' do
expect(string.present?).to eq(true)
end
end
end
describe '#blank?', :aggregate_failures do
it 'returns false' do
string = 'TAP '
expect(string.blank?).to eq(true)
expect(string.strip.blank?).to eq(true)
end
it 'returns true', pending: 'need to implement blank? for NilClass' do
string = nil
expect(string.blank?).to eq(true)
end
end
describe '#squish' do
it 'squishes', skip: 'it is Ruby not Rails' do
string = <<-STRING.gsub(/^\s+\|/, '').chomp
|Hello
| Hi
|Hey
STRING
expect(string.squish).to eq('Hello Hi Hey')
end
end
end