Skip to content

Commit b4b5c1a

Browse files
authored
Merge pull request #627 from DannyBen/update/indentation-specs
Relocate `IndentationHelper` specs
2 parents 4b26464 + 186a4bc commit b4b5c1a

File tree

6 files changed

+124
-106
lines changed

6 files changed

+124
-106
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require:
1+
plugins:
22
- rubocop-performance
33
- rubocop-rspec
44

examples/render-mandoc/docs/download.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" Automatically generated by Pandoc 3.2
22
.\"
3-
.TH "download" "1" "February 2025" "Version 0.1.0" "Sample application"
3+
.TH "download" "1" "March 2025" "Version 0.1.0" "Sample application"
44
.SH NAME
55
\f[B]download\f[R] \- Sample application
66
.SH SYNOPSIS

examples/render-mandoc/docs/download.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% download(1) Version 0.1.0 | Sample application
22
% Lana Lang
3-
% February 2025
3+
% March 2025
44

55
NAME
66
==================================================

spec/approvals/examples/render-mandoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ ISSUE TRACKER
4444
AUTHORS
4545
Lana Lang.
4646

47-
Version 0.1.0 February 2025 download(1)
47+
Version 0.1.0 March 2025 download(1)
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
describe IndentationHelper do
2+
# Since `IndentationHelper` is a stateful class that operates on a
3+
# line-by-line basis, the `IndentationHelper#indent` method is tested via
4+
# the `Array#indent` extension for convenience and clarity.
5+
describe '#indent' do
6+
subject { ['root:', ' indented:'] }
7+
8+
it 'prepends each element with spaces' do
9+
expect(subject.indent(2)).to eq [' root:', ' indented:']
10+
end
11+
12+
context 'when offset is 0' do
13+
it 'returns the array as is' do
14+
expect(subject.indent(0)).to eq subject
15+
end
16+
end
17+
18+
context 'when the string contains heredoc block' do
19+
subject do
20+
result = <<~SUBJECT
21+
function() {
22+
cat <<-SOME_EOF_MARKER
23+
not-indented
24+
indented-once
25+
indented-twice
26+
SOME_EOF_MARKER
27+
} # indented with function() start
28+
SUBJECT
29+
30+
result.lines
31+
end
32+
33+
let(:expected) do
34+
result = <<~SUBJECT
35+
function() {
36+
cat <<-SOME_EOF_MARKER
37+
not-indented
38+
indented-once
39+
indented-twice
40+
SOME_EOF_MARKER
41+
} # indented with function() start
42+
SUBJECT
43+
44+
result.lines
45+
end
46+
47+
it 'does not indent it but indents everything else' do
48+
expect(subject.indent 2).to eq expected
49+
end
50+
end
51+
52+
context 'when the string contains a single quoted heredoc block' do
53+
subject do
54+
result = <<~SUBJECT
55+
function() {
56+
cat <<-'SOME_EOF_MARKER'
57+
not-indented
58+
indented-once
59+
indented-twice
60+
SOME_EOF_MARKER
61+
} # indented with function() start
62+
SUBJECT
63+
64+
result.lines
65+
end
66+
67+
let(:expected) do
68+
result = <<~SUBJECT
69+
function() {
70+
cat <<-'SOME_EOF_MARKER'
71+
not-indented
72+
indented-once
73+
indented-twice
74+
SOME_EOF_MARKER
75+
} # indented with function() start
76+
SUBJECT
77+
78+
result.lines
79+
end
80+
81+
it 'does not indent it but indents everything else' do
82+
expect(subject.indent 2).to eq expected
83+
end
84+
end
85+
86+
context 'when the string contains a double quoted heredoc block' do
87+
subject do
88+
result = <<~SUBJECT
89+
function() {
90+
cat <<-"SOME_EOF_MARKER"
91+
not-indented
92+
indented-once
93+
indented-twice
94+
SOME_EOF_MARKER
95+
} # indented with function() start
96+
SUBJECT
97+
98+
result.lines
99+
end
100+
101+
let(:expected) do
102+
result = <<~SUBJECT
103+
function() {
104+
cat <<-"SOME_EOF_MARKER"
105+
not-indented
106+
indented-once
107+
indented-twice
108+
SOME_EOF_MARKER
109+
} # indented with function() start
110+
SUBJECT
111+
112+
result.lines
113+
end
114+
115+
it 'does not indent it but indents everything else' do
116+
expect(subject.indent 2).to eq expected
117+
end
118+
end
119+
end
120+
end

spec/bashly/extensions/array_spec.rb

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -11,108 +11,6 @@
1111
expect(subject.indent(0)).to eq subject
1212
end
1313
end
14-
15-
context 'when the string contains heredoc block' do
16-
subject do
17-
result = <<~SUBJECT
18-
function() {
19-
cat <<-SOME_EOF_MARKER
20-
not-indented
21-
indented-once
22-
indented-twice
23-
SOME_EOF_MARKER
24-
} # indented with function() start
25-
SUBJECT
26-
27-
result.lines
28-
end
29-
30-
let(:expected) do
31-
result = <<~SUBJECT
32-
function() {
33-
cat <<-SOME_EOF_MARKER
34-
not-indented
35-
indented-once
36-
indented-twice
37-
SOME_EOF_MARKER
38-
} # indented with function() start
39-
SUBJECT
40-
41-
result.lines
42-
end
43-
44-
it 'does not indent it but indents everything else' do
45-
expect(subject.indent 2).to eq expected
46-
end
47-
end
48-
49-
context 'when the string contains a single quoted heredoc block' do
50-
subject do
51-
result = <<~SUBJECT
52-
function() {
53-
cat <<-'SOME_EOF_MARKER'
54-
not-indented
55-
indented-once
56-
indented-twice
57-
SOME_EOF_MARKER
58-
} # indented with function() start
59-
SUBJECT
60-
61-
result.lines
62-
end
63-
64-
let(:expected) do
65-
result = <<~SUBJECT
66-
function() {
67-
cat <<-'SOME_EOF_MARKER'
68-
not-indented
69-
indented-once
70-
indented-twice
71-
SOME_EOF_MARKER
72-
} # indented with function() start
73-
SUBJECT
74-
75-
result.lines
76-
end
77-
78-
it 'does not indent it but indents everything else' do
79-
expect(subject.indent 2).to eq expected
80-
end
81-
end
82-
83-
context 'when the string contains a double quoted heredoc block' do
84-
subject do
85-
result = <<~SUBJECT
86-
function() {
87-
cat <<-"SOME_EOF_MARKER"
88-
not-indented
89-
indented-once
90-
indented-twice
91-
SOME_EOF_MARKER
92-
} # indented with function() start
93-
SUBJECT
94-
95-
result.lines
96-
end
97-
98-
let(:expected) do
99-
result = <<~SUBJECT
100-
function() {
101-
cat <<-"SOME_EOF_MARKER"
102-
not-indented
103-
indented-once
104-
indented-twice
105-
SOME_EOF_MARKER
106-
} # indented with function() start
107-
SUBJECT
108-
109-
result.lines
110-
end
111-
112-
it 'does not indent it but indents everything else' do
113-
expect(subject.indent 2).to eq expected
114-
end
115-
end
11614
end
11715

11816
describe '#nonuniq' do

0 commit comments

Comments
 (0)