Skip to content
This repository was archived by the owner on Jul 15, 2025. It is now read-only.

Commit b4e8f20

Browse files
committed
gemfile_spec properly undents content.
Content produced by heredoc was not being properly undented. No tests were broken (the regular expressions are tolerant of leading space), but it still seems like a good idea to undent the content.
1 parent 807d7cc commit b4e8f20

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

spec/gemnasium/parser/gemfile_spec.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
require "spec_helper"
22

33
describe Gemnasium::Parser::Gemfile do
4+
5+
def undent(string)
6+
first_line_indent = string[/\A\s*/]
7+
string.gsub(first_line_indent, "")
8+
end
9+
410
def content(string)
5-
@content ||= begin
6-
indent = string.scan(/^[ \t]*(?=\S)/)
7-
n = indent ? indent.size : 0
8-
string.gsub(/^[ \t]{#{n}}/, "")
9-
end
11+
@content ||= undent(string)
1012
end
1113

1214
def gemfile

0 commit comments

Comments
 (0)