summaryrefslogtreecommitdiffstats
path: root/spec/unit/operatingsystem.rb
blob: de86230a9dba40993fc88c93c35fe9f537e04e85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../spec_helper'

require 'facter'

describe "Operating System fact" do

    before do
        Facter.clear
    end
    
    after do
        Facter.clear
    end
    
    it "should default to the kernel name" do
        Facter.fact(:kernel).stubs(:value).returns("Nutmeg")

        Facter.fact(:operatingsystem).value.should == "Nutmeg"
    end
    
    it "should be Solaris for SunOS" do
         Facter.fact(:kernel).stubs(:value).returns("SunOS")
         
         Facter.fact(:operatingsystem).value.should == "Solaris"
    end
    
    it "should identify Oracle VM as OVS" do

        Facter.fact(:kernel).stubs(:value).returns("Linux")
        FileTest.stubs(:exists?).returns false

        FileTest.expects(:exists?).with("/etc/ovs-release").returns true
        FileTest.expects(:exists?).with("/etc/enterprise-release").returns true
        
        Facter.fact(:operatingsystem).value.should == "OVS"
    end
end