Convert Create test to spec.
This commit is contained in:
parent
2ade29a5cf
commit
dcb206dd1e
@ -1,4 +1,4 @@
|
||||
require "test_helper"
|
||||
require "spec_helper"
|
||||
|
||||
# monkeypatch for testing
|
||||
module Hbc
|
||||
@ -20,11 +20,11 @@ module Hbc
|
||||
end
|
||||
|
||||
describe Hbc::CLI::Create do
|
||||
before do
|
||||
before(:each) do
|
||||
Hbc::CLI::Create.reset!
|
||||
end
|
||||
|
||||
after do
|
||||
after(:each) do
|
||||
%w[new-cask additional-cask another-cask yet-another-cask local-caff].each do |cask|
|
||||
path = Hbc.path(cask)
|
||||
path.delete if path.exist?
|
||||
@ -33,7 +33,7 @@ describe Hbc::CLI::Create do
|
||||
|
||||
it "opens the editor for the specified Cask" do
|
||||
Hbc::CLI::Create.run("new-cask")
|
||||
Hbc::CLI::Create.editor_commands.must_equal [
|
||||
expect(Hbc::CLI::Create.editor_commands).to eq [
|
||||
[Hbc.path("new-cask")],
|
||||
]
|
||||
end
|
||||
@ -41,7 +41,7 @@ describe Hbc::CLI::Create do
|
||||
it "drops a template down for the specified Cask" do
|
||||
Hbc::CLI::Create.run("new-cask")
|
||||
template = File.read(Hbc.path("new-cask"))
|
||||
template.must_equal <<-EOS.undent
|
||||
expect(template).to eq <<-EOS.undent
|
||||
cask 'new-cask' do
|
||||
version ''
|
||||
sha256 ''
|
||||
@ -57,44 +57,44 @@ describe Hbc::CLI::Create do
|
||||
|
||||
it "throws away additional Cask arguments and uses the first" do
|
||||
Hbc::CLI::Create.run("additional-cask", "another-cask")
|
||||
Hbc::CLI::Create.editor_commands.must_equal [
|
||||
expect(Hbc::CLI::Create.editor_commands).to eq [
|
||||
[Hbc.path("additional-cask")],
|
||||
]
|
||||
end
|
||||
|
||||
it "throws away stray options" do
|
||||
Hbc::CLI::Create.run("--notavalidoption", "yet-another-cask")
|
||||
Hbc::CLI::Create.editor_commands.must_equal [
|
||||
expect(Hbc::CLI::Create.editor_commands).to eq [
|
||||
[Hbc.path("yet-another-cask")],
|
||||
]
|
||||
end
|
||||
|
||||
it "raises an exception when the Cask already exists" do
|
||||
lambda {
|
||||
expect {
|
||||
Hbc::CLI::Create.run("basic-cask")
|
||||
}.must_raise Hbc::CaskAlreadyCreatedError
|
||||
}.to raise_error(Hbc::CaskAlreadyCreatedError)
|
||||
end
|
||||
|
||||
it "allows creating Casks that are substrings of existing Casks" do
|
||||
Hbc::CLI::Create.run("local-caff")
|
||||
Hbc::CLI::Create.editor_commands.must_equal [
|
||||
expect(Hbc::CLI::Create.editor_commands).to eq [
|
||||
[Hbc.path("local-caff")],
|
||||
]
|
||||
end
|
||||
|
||||
describe "when no Cask is specified" do
|
||||
it "raises an exception" do
|
||||
lambda {
|
||||
expect {
|
||||
Hbc::CLI::Create.run
|
||||
}.must_raise Hbc::CaskUnspecifiedError
|
||||
}.to raise_error(Hbc::CaskUnspecifiedError)
|
||||
end
|
||||
end
|
||||
|
||||
describe "when no Cask is specified, but an invalid option" do
|
||||
it "raises an exception" do
|
||||
lambda {
|
||||
expect {
|
||||
Hbc::CLI::Create.run("--notavalidoption")
|
||||
}.must_raise Hbc::CaskUnspecifiedError
|
||||
}.to raise_error(Hbc::CaskUnspecifiedError)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user