require File.dirname(__FILE__) + '/../spec_helper' describe "Pool" do before(:each) do @obj = Object.new end it "should respond to the pool method" do @obj.respond_to?(:pool).should == true end it "should store the pool in the global array" do @p = pool :app do end @obj.pools[:app].should == @p end describe "block" do before(:each) do @pool = Pool.new(:test) do # Inside pool block Proc.new {puts "hello world"} end end it "should be able to define a cloud within the pool block" do @pool.respond_to?(:cloud).should == true end it "should evaluate the block when creating a new pool" do Proc.should_receive(:new).once Pool.new(:test) do Proc.new {puts "hi"} end end describe "plugins" do after(:each) do @pool.instance_eval do plugin_directory "yaway" end end it "should call Dir when the plugin directory is set" do Dir.should_receive(:[]).with("yaway/*/*.rb").once.and_return [] end end describe "configuration" do before(:each) do reset! @pool = Pool.new :test do nick_nack "nails" rocky_shores "ranger" end end it "should set the plugin_directory to nails" do @pool.nick_nack.should == "nails" end it "should set the rocky_shores to ranger" do @pool.rocky_shores.should == "ranger" end describe "range for min/max instances" do it "should be able to respond to instances" do @pool.respond_to?(:instances).should == true end it "should be able to pass instances a range" do lambda { @pool.instance_eval do instances 2..5 end }.should_not raise_error end it "should set the minimum as the minimum_instances from the range" do @pool.instance_eval do instances 2..5 end @pool.minimum_instances.should == 2 end it "should set the maximum as the maximum_instances from the range" do @pool.instance_eval do instances 2..5 end @pool.maximum_instances.should == 5 end end end end end