Add tests for `CaskUnreadableError.

This commit is contained in:
Markus Reiter 2018-07-29 11:40:27 +02:00
parent 5a45315349
commit 785ec4ef57
2 changed files with 36 additions and 1 deletions

View File

@ -0,0 +1,35 @@
describe Hbc::CaskLoader::FromPathLoader do
describe "#load" do
context "when the file does not contain a cask" do
let(:path) {
(mktmpdir/"cask.rb").tap do |path|
path.write <<~RUBY
true
RUBY
end
}
it "raises an error" do
expect {
described_class.new(path).load
}.to raise_error(Hbc::CaskUnreadableError, /does not contain a cask/)
end
end
context "when the file calls a non-existent method" do
let(:path) {
(mktmpdir/"cask.rb").tap do |path|
path.write <<~RUBY
this_method_does_not_exist
RUBY
end
}
it "raises an error" do
expect {
described_class.new(path).load
}.to raise_error(Hbc::CaskUnreadableError, /undefined local variable or method/)
end
end
end
end

View File

@ -46,7 +46,7 @@ describe Hbc::DSL, :cask do
let(:token) { "invalid/invalid-header-format" }
it "raises an error" do
expect { cask }.to raise_error(SyntaxError)
expect { cask }.to raise_error(Hbc::CaskUnreadableError)
end
end