Sha256: c86865fae9e92589cb7378187f3805e535e734d18f6e8a1cc9619dfcd77aa7f0

Contents?: true

Size: 1.4 KB

Versions: 52

Compression:

Stored size: 1.4 KB

Contents

#!/usr/bin/env ruby

require 'spec_helper'
require 'facter'

describe "rackspace facts" do
  describe "on Rackspace Cloud" do
    before :each do
      Facter.collection.internal_loader.load(:rackspace)
    end

    it "should set is_rsc to true" do
      Facter::Util::Resolution.stubs(:exec).with("/usr/bin/xenstore-read vm-data/provider_data/provider 2> /dev/null").returns("Rackspace")
      Facter.fact(:is_rsc).value.should == "true"
    end

    it "should set the region to dfw" do
      Facter.fact(:is_rsc).stubs(:value).returns("true")
      Facter::Util::Resolution.stubs(:exec).with("/usr/bin/xenstore-read vm-data/provider_data/region 2> /dev/null").returns("dfw")
      Facter.fact(:rsc_region).value.should == "dfw"
    end

    it "should get the instance id" do
      Facter.fact(:is_rsc).stubs(:value).returns("true")
      Facter::Util::Resolution.stubs(:exec).with("/usr/bin/xenstore-read name").returns("instance-75a96685-85d6-44c6-aed8-41ef0fb2cfcc")
      Facter.fact(:rsc_instance_id).value.should == "75a96685-85d6-44c6-aed8-41ef0fb2cfcc"
    end
  end

  describe "not on Rackspace Cloud" do
    before do
      Facter.collection.internal_loader.load(:rackspace)
    end

    it "shouldn't set is_rsc" do
      Facter::Util::Resolution.stubs(:exec).with("/usr/bin/xenstore-read vm-data/provider_data/provider 2> /dev/null").returns("other")
      Facter.fact(:is_rsc).value.should == nil
    end
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
facter-2.5.7 spec/unit/rackspace_spec.rb
facter-2.5.7-x86-mingw32 spec/unit/rackspace_spec.rb
facter-2.5.7-x64-mingw32 spec/unit/rackspace_spec.rb
facter-2.5.7-universal-darwin spec/unit/rackspace_spec.rb
facter-2.5.6-x86-mingw32 spec/unit/rackspace_spec.rb
facter-2.5.6-x64-mingw32 spec/unit/rackspace_spec.rb
facter-2.5.6-universal-darwin spec/unit/rackspace_spec.rb
facter-2.5.6 spec/unit/rackspace_spec.rb
facter-2.5.5-x86-mingw32 spec/unit/rackspace_spec.rb
facter-2.5.5-x64-mingw32 spec/unit/rackspace_spec.rb
facter-2.5.5-universal-darwin spec/unit/rackspace_spec.rb
facter-2.5.5 spec/unit/rackspace_spec.rb
facter-2.5.4-x86-mingw32 spec/unit/rackspace_spec.rb
facter-2.5.4-x64-mingw32 spec/unit/rackspace_spec.rb
facter-2.5.4-universal-darwin spec/unit/rackspace_spec.rb
facter-2.5.4 spec/unit/rackspace_spec.rb
facter-2.5.1 spec/unit/rackspace_spec.rb
facter-2.5.1-x86-mingw32 spec/unit/rackspace_spec.rb
facter-2.5.1-x64-mingw32 spec/unit/rackspace_spec.rb
facter-2.5.1-universal-darwin spec/unit/rackspace_spec.rb