Sha256: 3b23e6bcd928bd4f9a355771ae9832e89ca761482f264b295317436988918094

Contents?: true

Size: 1.62 KB

Versions: 16

Compression:

Stored size: 1.62 KB

Contents

require 'mixlib/config'

$:.unshift(File.dirname(__FILE__) + '/../lib')
require 'ohai'
Ohai::Config[:log_level] = :error

def it_should_check_from(plugin, attribute, from, value)
  it "should set the #{attribute} to the value from '#{from}'" do
    @ohai._require_plugin(plugin)
    @ohai[attribute].should == value
  end
end

def it_should_check_from_mash(plugin, attribute, from, value)
  it "should get the #{plugin}[:#{attribute}] value from '#{from}'" do
    @ohai.should_receive(:from).with(from).and_return(value)
    @ohai._require_plugin(plugin)
  end

  it "should set the #{plugin}[:#{attribute}] to the value from '#{from}'" do
    @ohai._require_plugin(plugin)
    @ohai[plugin][attribute].should == value
  end
end

# the mash variable may be an array listing multiple levels of Mash hierarchy
def it_should_check_from_deep_mash(plugin, mash, attribute, from, value)
  it "should get the #{mash.inspect}[:#{attribute}] value from '#{from}'" do
    @ohai.should_receive(:from).with(from).and_return(value)
    @ohai._require_plugin(plugin)
  end

  it "should set the #{mash.inspect}[:#{attribute}] to the value from '#{from}'" do
    @ohai._require_plugin(plugin)
    if mash.is_a?(String)
      @ohai[mash][attribute].should == value
    elsif mash.is_a?(Array)
      if mash.length == 2
        @ohai[mash[0]][mash[1]][attribute].should == value
      elsif mash.length == 3
        @ohai[mash[0]][mash[1]][mash[2]][attribute].should == value
      else
        return nil
      end
    else
      return nil
    end
  end
end

module SimpleFromFile
  def from_file(filename)
    self.instance_eval(IO.read(filename), filename, 1)
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ohai-0.6.12.rc.3 spec/spec_helper.rb
ohai-0.6.12.rc.2 spec/spec_helper.rb
ohai-0.6.12.rc.1 spec/spec_helper.rb
ohai-0.6.10 spec/spec_helper.rb
ohai-0.6.10.rc.1 spec/spec_helper.rb
ohai-0.6.8 spec/spec_helper.rb
ohai-0.6.8.rc.1 spec/spec_helper.rb
ohai-0.6.8.rc.0 spec/spec_helper.rb
ohai-0.6.6 spec/spec_helper.rb
ohai-0.6.6.rc.1 spec/spec_helper.rb
ohai-0.6.6.rc.0 spec/spec_helper.rb
ohai-0.6.4 spec/spec_helper.rb
ohai-0.6.2 spec/spec_helper.rb
ohai-0.6.2.rc.0 spec/spec_helper.rb
ohai-0.6.0 spec/spec_helper.rb
ohai-0.6.0.beta.0 spec/spec_helper.rb