Convert Edit test to spec.
This commit is contained in:
parent
dcb206dd1e
commit
3ef51dba05
@ -1,4 +1,4 @@
|
|||||||
require "test_helper"
|
require "spec_helper"
|
||||||
|
|
||||||
# monkeypatch for testing
|
# monkeypatch for testing
|
||||||
module Hbc
|
module Hbc
|
||||||
@ -20,43 +20,43 @@ module Hbc
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe Hbc::CLI::Edit do
|
describe Hbc::CLI::Edit do
|
||||||
before do
|
before(:each) do
|
||||||
Hbc::CLI::Edit.reset!
|
Hbc::CLI::Edit.reset!
|
||||||
end
|
end
|
||||||
|
|
||||||
it "opens the editor for the specified Cask" do
|
it "opens the editor for the specified Cask" do
|
||||||
Hbc::CLI::Edit.run("alfred")
|
Hbc::CLI::Edit.run("local-caffeine")
|
||||||
Hbc::CLI::Edit.editor_commands.must_equal [
|
expect(Hbc::CLI::Edit.editor_commands).to eq [
|
||||||
[Hbc.path("alfred")],
|
[Hbc.path("local-caffeine")],
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "throws away additional arguments and uses the first" do
|
it "throws away additional arguments and uses the first" do
|
||||||
Hbc::CLI::Edit.run("adium", "alfred")
|
Hbc::CLI::Edit.run("local-caffeine", "local-transmission")
|
||||||
Hbc::CLI::Edit.editor_commands.must_equal [
|
expect(Hbc::CLI::Edit.editor_commands).to eq [
|
||||||
[Hbc.path("adium")],
|
[Hbc.path("local-caffeine")],
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an exception when the Cask doesnt exist" do
|
it "raises an exception when the Cask doesnt exist" do
|
||||||
lambda {
|
expect {
|
||||||
Hbc::CLI::Edit.run("notacask")
|
Hbc::CLI::Edit.run("notacask")
|
||||||
}.must_raise Hbc::CaskUnavailableError
|
}.to raise_error(Hbc::CaskUnavailableError)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "when no Cask is specified" do
|
describe "when no Cask is specified" do
|
||||||
it "raises an exception" do
|
it "raises an exception" do
|
||||||
lambda {
|
expect {
|
||||||
Hbc::CLI::Edit.run
|
Hbc::CLI::Edit.run
|
||||||
}.must_raise Hbc::CaskUnspecifiedError
|
}.to raise_error(Hbc::CaskUnspecifiedError)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "when no Cask is specified, but an invalid option" do
|
describe "when no Cask is specified, but an invalid option" do
|
||||||
it "raises an exception" do
|
it "raises an exception" do
|
||||||
lambda {
|
expect {
|
||||||
Hbc::CLI::Edit.run("--notavalidoption")
|
Hbc::CLI::Edit.run("--notavalidoption")
|
||||||
}.must_raise Hbc::CaskUnspecifiedError
|
}.to raise_error(Hbc::CaskUnspecifiedError)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user