Sha256: 26062e9a6ccce575cd8bae418cd3253854db60d0029142e154b92382845cd279

Contents?: true

Size: 1.79 KB

Versions: 4

Compression:

Stored size: 1.79 KB

Contents

require "#{::File.dirname(__FILE__)}/../../test_helper"

class TestCloudDsl < Test::Unit::TestCase
  context "enabling and disabling" do
    setup do
      reset!
      @cloud = cloud :test_cloud_dsl do
      end
    end    
    should "not have an option set for hyper_drive" do
      @cloud.dsl_options[:hyper_drive].should == nil
    end

    should "set the option to :enabled when enabled" do
      @cloud.enable :hyper_drive
      @cloud.dsl_options[:hyper_drive].should == :enabled
    end

    should "set the option to disabled when disabled" do
      @cloud.disable :hyper_drive
      @cloud.dsl_options[:hyper_drive].should == :disabled
    end
    
    should "be able to check if they are enabled" do
      @cloud.enable :hyper_slam
      @cloud.enabled?(:hyper_slam).should == true
    end
    should "be able to check that they are disabled" do
      @cloud.disable :hyper_slam
      @cloud.enabled?(:hyper_slam).should == false
    end
  end
  context "calling add_optional_enabled_services" do
    setup do
      reset!
      @cloud = cloud :test_cloud_dsl_2 do
        enable :haproxy
      end
      @cloud.instance_eval "self.class.send :attr_reader, :brains"
      @cloud.instance_eval "def box;@brains = 'pepper';end"
    end

    should "send @cloud the method box after it's been enabled" do
      @cloud.enable :box
      @cloud.add_optional_enabled_services
      @cloud.brains.should == "pepper"
    end
    should "not call box if the method has not been enabled" do
      @cloud.add_optional_enabled_services
      @cloud.brains.should == nil
    end
    should "call haproxy when adding enabled serivces" do
      @cloud.add_optional_enabled_services
      klasses = @cloud.plugin_store.map {|a| a.class.to_s.split("::")[-1] }
      klasses.include?("HaproxyClass").should == true
    end
  end
  
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
auser-poolparty-1.2.3 test/poolparty/modules/cloud_dsl_test.rb
auser-poolparty-1.2.4 test/poolparty/modules/cloud_dsl_test.rb
auser-poolparty-1.2.7 test/poolparty/modules/cloud_dsl_test.rb
auser-poolparty-1.2.8 test/poolparty/modules/cloud_dsl_test.rb