Skip to content

Commit 448f09f

Browse files
committed
Change behavior and add additional test
1 parent 4d9d5a5 commit 448f09f

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

lib/jekyll-pre-commit/runner.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ def run(site, staged_files)
3232
o = Object.const_get("Jekyll::PreCommit::Check::" + c["check"]).new
3333
rescue
3434
result[:ok] = false
35-
# Skip any other messages so the user focuses on this.
36-
result[:message] = ["The check #{c["check"]} does not exist! Please fix your configuration."]
35+
result[:messages].push("The check #{c["check"]} does not exist! Please fix your configuration.")
3736
break
3837
end
3938
r = o.Check(staged_posts, not_staged_posts, site, c)

spec/jekyll-pre-commit_spec.rb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,24 @@
130130
it "fails with non-existent check message" do
131131
result = runner.run(site, ["spec/fixtures/_posts/2017-01-06-no-description.md"])
132132
expect(result[:ok]).to eql(false)
133-
expect(result[:message]).to match_array(["The check Garbage does not exist! Please fix your configuration."])
133+
expect(result[:messages]).to match_array(["The check Garbage does not exist! Please fix your configuration."])
134+
end
135+
end
136+
137+
context "with a check that doesn't exist and a check that does" do
138+
pre_commit_config = [
139+
{"check" => "FrontMatterPropertyExists", "properties" => ["description"]},
140+
{"check" => "Garbage"}
141+
]
142+
let(:site) { build_site({ 'pre-commit' => pre_commit_config }) }
143+
144+
it "fails and shows non-existent check message along with other failure messages" do
145+
result = runner.run(site, ["spec/fixtures/_posts/2017-01-06-no-description.md"])
146+
expect(result[:ok]).to eql(false)
147+
expect(result[:messages]).to match_array([
148+
"No Description was missing a description. ",
149+
"The check Garbage does not exist! Please fix your configuration."
150+
])
134151
end
135152
end
136153
end

0 commit comments

Comments
 (0)