spec/node_spec.rb in testlab-0.3.1 vs spec/node_spec.rb in testlab-0.4.0
- old
+ new
@@ -19,11 +19,15 @@
################################################################################
require "spec_helper"
describe TestLab::Node do
- subject { @testlab = TestLab.new(:labfile => LABFILE); @testlab.nodes.first }
+ subject {
+ @ui = ZTK::UI.new(:stdout => StringIO.new, :stderr => StringIO.new)
+ @testlab = TestLab.new(:labfile => LABFILE, :ui => @ui)
+ @testlab.nodes.first
+ }
describe "class" do
it "should be an instance of TestLab::Node" do
subject.should be_an_instance_of TestLab::Node
@@ -37,10 +41,26 @@
it "should return the path to the node template directory" do
subject.class.template_dir.should == "#{TestLab.gem_dir}/lib/testlab/node/templates"
end
end
+ describe "#bind_setup" do
+ it "should setup bind" do
+ subject.ssh.stub(:exec) { true }
+ subject.ssh.stub(:file).and_yield(StringIO.new)
+ subject.bind_setup
+ end
+ end
+
+ describe "#build_resolv_conf" do
+ it "should build resolv.conf" do
+ subject.ssh.stub(:exec) { true }
+ subject.ssh.stub(:file).and_yield(StringIO.new)
+ subject.build_resolv_conf
+ end
+ end
+
describe "#status" do
it "should return a hash of status information about the node" do
subject.instance_variable_get(:@provider).stub(:state) { :not_created }
subject.status.should be_kind_of(Hash)
subject.status.should_not be_empty
@@ -85,9 +105,39 @@
describe "#down" do
it "should offline the node" do
subject.instance_variable_get(:@provider).stub(:down) { true }
subject.down
+ end
+ end
+
+ describe "setup" do
+ it "should setup the node" do
+ subject.ssh.stub(:bootstrap) { true }
+ subject.stub(:route_setup) { true }
+ subject.stub(:build_resolv_conf) { true }
+ subject.stub(:bind_setup) { true }
+ subject.stub(:bind_reload) { true }
+ subject.containers.each do |container|
+ container.stub(:setup) { true }
+ end
+ subject.networks.each do |network|
+ network.stub(:setup) { true }
+ end
+ subject.setup
+ end
+ end
+
+ describe "teardown" do
+ it "should teardown the node" do
+ subject.stub(:route_setup) { true }
+ subject.containers.each do |container|
+ container.stub(:teardown) { true }
+ end
+ subject.networks.each do |network|
+ network.stub(:teardown) { true }
+ end
+ subject.teardown
end
end
end