spec/container_spec.rb in testlab-0.3.1 vs spec/container_spec.rb in testlab-0.4.0
- old
+ new
@@ -19,30 +19,38 @@
################################################################################
require "spec_helper"
describe TestLab::Container do
- subject { @testlab = TestLab.new(:labfile => LABFILE); @testlab.containers.first }
+ subject {
+ @ui = ZTK::UI.new(:stdout => StringIO.new, :stderr => StringIO.new)
+ @testlab = TestLab.new(:labfile => LABFILE, :ui => @ui)
+ @testlab.containers.first
+ }
describe "class" do
it "should be an instance of TestLab::Container" do
subject.should be_an_instance_of TestLab::Container
end
- end
+ describe "methods" do
- describe "methods" do
-
- describe "domains" do
- it "should return the domains for all defined containers" do
- subject.class.domains.should be_kind_of(Array)
- subject.class.domains.should_not be_empty
- subject.class.domains.should == ["default.zone"]
+ describe "domains" do
+ it "should return the domains for all defined containers" do
+ subject.class.domains.should be_kind_of(Array)
+ subject.class.domains.should_not be_empty
+ subject.class.domains.should == ["default.zone"]
+ end
end
+
end
+ end
+
+ describe "methods" do
+
describe "#status" do
it "should return a hash of status information about the container" do
subject.lxc.stub(:state) { :not_created }
subject.status.should be_kind_of(Hash)
subject.status.should_not be_empty
@@ -56,11 +64,11 @@
end
end
describe "#fqdn" do
it "should return the FQDN for the container" do
- subject.fqdn.should == "server-1.default.zone"
+ subject.fqdn.should == "server-dual-nic.default.zone"
end
end
describe "#ip" do
it "should return the IP address of the containers primary interface" do
@@ -167,26 +175,53 @@
subject.down
end
end
describe "#setup" do
- it "should create and online the container" do
- subject.stub(:create) { true }
- subject.stub(:up) { true }
- subject.instance_variable_get(:@provisioner) and subject.instance_variable_get(:@provisioner).stub(:setup) { true }
+ context "with no provisioner" do
+ it "should create and online the container" do
+ subject.stub(:create) { true }
+ subject.stub(:up) { true }
+ subject.instance_variable_get(:@provisioner) and subject.instance_variable_get(:@provisioner).stub(:setup) { true }
- subject.setup
+ subject.setup
+ end
end
+
+ context "with the shell provisioner" do
+ it "should create and online the container" do
+ subject = TestLab::Container.first('server-shell')
+ subject.stub(:create) { true }
+ subject.stub(:up) { true }
+ subject.instance_variable_get(:@provisioner) and subject.instance_variable_get(:@provisioner).stub(:setup) { true }
+
+ subject.setup
+ end
+ end
end
describe "#teardown" do
- it "should create and online the container" do
- subject.stub(:down) { true }
- subject.stub(:destroy) { true }
- subject.instance_variable_get(:@provisioner) and subject.instance_variable_get(:@provisioner).stub(:teardown) { true }
+ context "with no provisioner" do
+ it "should create and online the container" do
+ subject.stub(:down) { true }
+ subject.stub(:destroy) { true }
+ subject.instance_variable_get(:@provisioner) and subject.instance_variable_get(:@provisioner).stub(:teardown) { true }
- subject.teardown
+ subject.teardown
+ end
end
+
+ context "with the shell provisioner" do
+ it "should create and online the container" do
+ subject = TestLab::Container.first('server-shell')
+ subject.stub(:down) { true }
+ subject.stub(:destroy) { true }
+ subject.instance_variable_get(:@provisioner) and subject.instance_variable_get(:@provisioner).stub(:teardown) { true }
+
+ subject.teardown
+ end
+ end
+
end
end
end