Add normalize parameter to expect_correction

This commit is contained in:
fn ⌃ ⌥ 2021-11-01 17:57:56 -07:00
parent 7cb0c15747
commit 4b67e4b900
2 changed files with 4 additions and 3 deletions

View file

@ -24,7 +24,7 @@ module Ameba::Rule::Layout
it "fails if last line is not blank" do
source = expect_issue subject, "\n\n\n puts 22 # error: Trailing newline missing", normalize: false
expect_correction source, "\n\n\n puts 22\n"
expect_correction source, "\n\n\n puts 22\n", normalize: false
end
context "when unnecessary blank line has been detected" do

View file

@ -50,8 +50,8 @@ module Ameba::Spec::ExpectIssue
def expect_issue(rules : Rule::Base | Enumerable(Rule::Base),
annotated_code : String,
path = "",
normalize = true,
*,
normalize = true,
file = __FILE__,
line = __LINE__,
**replacements)
@ -81,7 +81,8 @@ module Ameba::Spec::ExpectIssue
source
end
def expect_correction(source, correction, *, file = __FILE__, line = __LINE__)
def expect_correction(source, correction, *, normalize = true, file = __FILE__, line = __LINE__)
correction = normalize_code(correction) if normalize
raise "Use `expect_no_corrections` if the code will not change" unless source.correct
return if correction == source.code