File tree Expand file tree Collapse file tree 2 files changed +69
-1
lines changed Expand file tree Collapse file tree 2 files changed +69
-1
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ def set_heredoc_state(line)
35
35
end
36
36
37
37
def extract_heredoc_marker ( line )
38
- line =~ /<<-?\s *(\w +)/ ? $1 : nil
38
+ line =~ /<<-?\s *['"]? (\w +)['"]? / ? $1 : nil
39
39
end
40
40
41
41
def heredoc_closed? ( line )
Original file line number Diff line number Diff line change 45
45
expect ( subject . indent 2 ) . to eq expected
46
46
end
47
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
48
116
end
49
117
50
118
describe '#nonuniq' do
You can’t perform that action at this time.
0 commit comments