Sha256: 1bd1814364e2ac71a5558a3c6dc5607512fc9738e75f496b338110c08df82994

Contents?: true

Size: 1.64 KB

Versions: 6

Compression:

Stored size: 1.64 KB

Contents

require "spec_helper"
require "baton/configuration"

describe Baton::Configuration do
  describe "#config_path=" do
    context "given config file available" do
      before(:each) do
        subject.config_path = "#{File.dirname(__FILE__)}/../fixtures/config.cfg"
      end
      
      it "will set the host" do
        subject.host.should eq("fromconfig.com")
      end
      
      it "will set the vhost" do
        subject.vhost.should eq("fromconfig")
      end
      
      it "will set the user" do
        subject.user.should eq("fromconfiguser")
      end
      
      it "will set the password" do
        subject.password.should eq("fromconfigpass")
      end
    end
    
    context "given a non existing file" do
      it "will log an erorr" do
        subject.logger.should_receive(:error).with("Could not find a baton configuration file at bad_path")
        subject.config_path = "bad_path"
      end
    end
  end
  
  describe "#connection_opts" do
    before(:each) do
      subject.config_path = "#{File.dirname(__FILE__)}/../fixtures/config.cfg"
    end
    
    context "give a config file" do
      it "will return a config hash" do
        subject.connection_opts.should eq({:host=>"fromconfig.com", :vhost=>"fromconfig", :user=>"fromconfiguser", :password=>"fromconfigpass", :pass=>"fromconfigpass"})
      end
    end
    
    context "given one of the configuration options is nil" do
      it "will not be returned in the config hash" do
        subject.vhost = nil
        subject.connection_opts.should eq({:host=>"fromconfig.com", :user=>"fromconfiguser", :password=>"fromconfigpass", :pass=>"fromconfigpass"})        
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
baton-0.4.4 spec/baton/configuration_spec.rb
baton-0.4.3 spec/baton/configuration_spec.rb
baton-0.4.2 spec/baton/configuration_spec.rb
baton-0.4.1 spec/baton/configuration_spec.rb
baton-0.3.7 spec/baton/configuration_spec.rb
baton-0.3.6 spec/baton/configuration_spec.rb