Sha256: 1c23b21c27caf5e302bd32f63020eefd9ae87da35666f6d74289a936a986eb53

Contents?: true

Size: 1.74 KB

Versions: 3

Compression:

Stored size: 1.74 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'

include PoolParty::Resources

describe "Conditional" do
  before(:each) do
    reset_resources!
  end
  describe "wrapped" do
    before(:each) do
      @cloud = cloud :conditional_cloud_spec do
          execute_if("$hostname", "==", "'master'", {}, self) do
            has_file({:name => "/etc/apache2/puppetmaster2.conf"})
          end
      end
      @cond = @cloud.get_resource(:conditional, "$hostname == 'master'")
    end
    it "should add the block of resources on the parent" do
      @cloud.resources.size.should == 1
    end
    it "should have a conditional in the resources" do
      @cond.name.should == "$hostname == 'master'"
    end
    it "should push the resources onto the conditional resource" do
      @cond.resources.size.should == 1
    end
    it "should have a file resource on the conditional" do
      @cond.get_file("/etc/apache2/puppetmaster2.conf").name.should == "/etc/apache2/puppetmaster2.conf"
    end
    it "should have the parent as the cloud" do
      @cond.parent.should == @cloud
    end
    describe "helpers" do
      it "should have execute_on_master with the string $hostname == 'master'" do
        str = execute_on_master do
          has_file(:name => "/etc/vars")
        end.to_string.should =~ /\$hostname==master/
      end
      it "should have execute_on_node with the string $hostname != 'master'" do
        str = execute_on_node do
          has_file(:name => "/etc/vars")
        end.to_string.should =~ /\$hostname!=master/
      end
    end
    describe "to_string" do
      before(:each) do
        @string = @cond.to_string
      end
      it "should have a case statement for the hostname" do
        @string.should =~ /case \$hostname/
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
auser-poolparty-0.2.59 spec/poolparty/pool/resources/conditional_spec.rb
auser-poolparty-0.2.60 spec/poolparty/pool/resources/conditional_spec.rb
auser-poolparty-0.2.61 spec/poolparty/pool/resources/conditional_spec.rb