Sha256: 26a2a84b975c24e6f688a44de6105ad998bfd9f1c2e48ac78a67f330c28cd411

Contents?: true

Size: 1.52 KB

Versions: 4

Compression:

Stored size: 1.52 KB

Contents

require "spec_helper"
require "baton/server"

describe Baton::Server do
  before(:each) do
    Ohai::System.any_instance.stub(:all_plugins).and_return(true)
    Ohai::System.any_instance.stub(:data).and_return({
      "chef_environment" => "production",
      "fqdn" => "build-prod-i-722b0004.dsci.it",
      "trebuchet" => ["octobutler"]
    })
  end

  describe "#configure" do
    context "given data from Ohai" do

      it "will set the fqdn" do
        subject.fqdn.should eq("build-prod-i-722b0004.dsci.it")
      end

      it "will set the environment" do
        subject.environment.should eq("production")
      end

      it "will set the apps" do
        subject.app_names.first.should eq("octobutler")
      end
    end

    context "given the required facts are not available" do
      before(:each) do
        Baton::Server.any_instance.stub(:facts).and_return({})
        subject.configure
      end

      it "will default the fqdn to an empty string" do
        subject.fqdn.should be_empty
      end

      it "will default environment to development" do
        subject.environment.should eq("development")
      end

      it "will default apps to an empty array" do
        subject.app_names.should be_empty
      end
    end
  end

  describe "#attributes" do
    context "given an instance of a server" do
      it "should have the attributes set" do
        subject.attributes.should eq({:environment=>"production",
          :fqdn=>"build-prod-i-722b0004.dsci.it",
          :app_names=>["octobutler"]})
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
baton-0.5.2 spec/baton/server_spec.rb
baton-0.4.10 spec/baton/server_spec.rb
baton-0.4.9 spec/baton/server_spec.rb
baton-0.4.8 spec/baton/server_spec.rb