Skip to content

Commit

Permalink
preserve empty line on bump
Browse files Browse the repository at this point in the history
  • Loading branch information
bravehager committed Mar 31, 2022
1 parent e1d339f commit 5fb3aff
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/spoom/sorbet/sigils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module Sigils
STRICTNESS_INTERNAL,
].freeze, T::Array[String])

SIGIL_REGEXP = T.let(/^#\s*typed\s*:\s*(\w*)\s*$/.freeze, Regexp)
SIGIL_REGEXP = T.let(/^#\s*typed\s*:\s*(\w*)$/.freeze, Regexp)

# returns the full sigil comment string for the passed strictness
sig { params(strictness: String).returns(String) }
Expand Down
5 changes: 5 additions & 0 deletions lib/spoom/test_helpers/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ def files
Dir.glob("#{@path}/**/*").sort
end

sig { params(rel_path: String).returns(String) }
def read(rel_path)
File.read(absolute_path(rel_path))
end

# Actions

# Run `git init` in this project
Expand Down
24 changes: 24 additions & 0 deletions test/spoom/cli/bump_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,30 @@ def test_bump_with_sorbet_segfault
assert_equal("false", Sorbet::Sigils.file_strictness("#{@project.path}/will_segfault.rb"))
end
end

def test_bump_preserve_empty_line
@project.write("file1.rb", <<~RB)
# typed: false
class A; end
RB

result = @project.bundle_exec("spoom bump --no-color")
assert_empty(result.err)
assert_equal(<<~OUT, result.out)
Checking files...
Bumped `1` file from `false` to `true`:
+ file1.rb
OUT
refute(result.status)

assert_equal(<<~RB, @project.read("file1.rb"))
# typed: true
class A; end
RB
end
end
end
end

0 comments on commit 5fb3aff

Please sign in to comment.