Skip to content

Commit 929bc85

Browse files
author
Ashley Baldwin-Hunter
committed
Merge pull request #8 from codeclimate/abh-gemfile-lock
Raise error when Gemfile.lock not present
2 parents f83dd23 + 972b6f0 commit 929bc85

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

lib/cc/engine/bundler_audit.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
module CC
55
module Engine
66
class BundlerAudit
7+
GemfileLockNotFound = Class.new(StandardError)
8+
79
def initialize(directory: , io: , engine_config: )
810
@directory = directory
911
@engine_config = engine_config
@@ -25,11 +27,7 @@ def run
2527
@io.print("#{issue.to_json}\0")
2628
end
2729
else
28-
warning = {
29-
type: "warning",
30-
description: "No Gemfile.lock file found"
31-
}
32-
@io.print("#{warning.to_json}\0")
30+
raise GemfileLockNotFound, "No Gemfile.lock found."
3331
end
3432
end
3533

spec/cc/engine/bundler_audit_spec.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
module CC::Engine
44
describe BundlerAudit do
55
describe "#run" do
6-
it "emits a warning when no Gemfile exists" do
6+
it "raises an error when no Gemfile.lock exists" do
77
FakeFS do
88
directory = "/c"
99
FileUtils.mkdir_p(directory)
1010
io = StringIO.new
1111
config = {}
1212

13-
BundlerAudit.new(directory: directory, io: io, engine_config: config).run
14-
15-
expect(io.string).to match(%{{"type":"warning","description":"No Gemfile.lock file found"}})
13+
expect { BundlerAudit.new(directory: directory, io: io, engine_config: config).run }
14+
.to raise_error(CC::Engine::BundlerAudit::GemfileLockNotFound)
1615
end
1716
end
1817

0 commit comments

Comments
 (0)