Sha256: f75be3ab3b8a4ab14151e3823658f06dce70d7f2c6823b26069b25c6a6418337

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

#! /usr/bin/env ruby

require 'spec_helper'

describe "Kernel release fact" do 

  describe "on Windows" do 
    before do 
      Facter.fact(:kernel).stubs(:value).returns("windows")
      require 'facter/util/wmi'
      version = stubs 'version'
      version.stubs(:Version).returns("test_kernel")
      Facter::Util::WMI.stubs(:execquery).with("SELECT Version from Win32_OperatingSystem").returns([version])
    end
    
    it "should return the kernel release" do 
      Facter.fact(:kernelrelease).value.should == "test_kernel"
    end 
  end 

  describe "on AIX" do 
    before do 
      Facter.fact(:kernel).stubs(:value).returns("aix")
      Facter::Core::Execution.stubs(:exec).with('oslevel -s').returns("test_kernel")
    end 
    
    it "should return the kernel release" do 
      Facter.fact(:kernelrelease).value.should == "test_kernel"
    end 
  end 

  describe "on HP-UX" do
    before do
      Facter.fact(:kernel).stubs(:value).returns("hp-ux") 
      Facter::Core::Execution.stubs(:exec).with('uname -r').returns("B.11.31")
    end 
    
    it "should remove preceding letters" do
      Facter.fact(:kernelrelease).value.should == "11.31"
    end 
  end 

  describe "on everything else" do 
    before do
      Facter.fact(:kernel).stubs(:value).returns("linux")
      Facter::Core::Execution.stubs(:exec).with('uname -r').returns("test_kernel")
    end 
    
    it "should return the kernel release" do
      Facter.fact(:kernelrelease).value.should == "test_kernel"
    end   
  end   
end 

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facter-2.0.1.rc1 spec/unit/kernelrelease_spec.rb
facter-2.0.1.rc1-x86-mingw32 spec/unit/kernelrelease_spec.rb
facter-2.0.1.rc1-universal-darwin spec/unit/kernelrelease_spec.rb