more cli tests
This commit is contained in:
@@ -61,15 +61,26 @@ describe "Foreman::CLI" do
|
||||
|
||||
describe "scale" do
|
||||
describe "without an existing configuration" do
|
||||
# TODO
|
||||
it "displays an error" do
|
||||
mock_error(subject, "No such app: testapp.") do
|
||||
subject.scale("testapp", "alpha", "2")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "with an existing configuration" do
|
||||
before(:each) { write_foreman_config("testapp") }
|
||||
|
||||
it "scales the specified process" do
|
||||
mock.instance_of(Foreman::Configuration).scale("testprocess", "2")
|
||||
subject.scale("testapp", "testprocess", "2")
|
||||
it "scales a process that exists" do
|
||||
mock.instance_of(Foreman::Configuration).scale("alpha", "2")
|
||||
subject.scale("testapp", "alpha", "2")
|
||||
end
|
||||
|
||||
it "errors if a process that does not exist is specified" do
|
||||
mock_error(subject, "No such process: invalidprocess.") do
|
||||
dont_allow.instance_of(Foreman::Configuration).scale
|
||||
subject.scale("testapp", "invalidprocess", "2")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+1
-20
@@ -3,19 +3,6 @@ require "rspec"
|
||||
|
||||
$:.unshift "lib"
|
||||
|
||||
# def stub_configuration
|
||||
# config = mock(Foreman::Configuration)
|
||||
# Foreman::Configuration.stub(:new).and_return(config)
|
||||
# config
|
||||
# end
|
||||
#
|
||||
#
|
||||
# def stub_export_upstart
|
||||
# upstart = mock(Foreman::Export::Upstart)
|
||||
# Foreman::Export::Upstart.stub(:new).and_return(upstart)
|
||||
# upstart
|
||||
# end
|
||||
|
||||
def mock_error(subject, message)
|
||||
mock_exit do
|
||||
mock(subject).puts("ERROR: #{message}")
|
||||
@@ -27,17 +14,11 @@ def mock_exit(&block)
|
||||
block.should raise_error(SystemExit)
|
||||
end
|
||||
|
||||
# def stub_engine
|
||||
# engine = mock(Foreman::Engine)
|
||||
# stub(Foreman::Engine).new { engine }
|
||||
# engine
|
||||
# end
|
||||
#
|
||||
def write_foreman_config(app)
|
||||
File.open("/etc/foreman/#{app}.conf", "w") do |file|
|
||||
file.puts %{#{app}_processes="alpha bravo"}
|
||||
file.puts %{#{app}_alpha="1"}
|
||||
file.puts %{#{app}_bravo="2"}
|
||||
file.puts %{#{app}_bravo="2"}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user