Sha256: d5e2e0d147f68caa65b4c9620f11c740d9ff3a26c984707cbc8a1e71c3dfa153

Contents?: true

Size: 1.78 KB

Versions: 4

Compression:

Stored size: 1.78 KB

Contents

#! /usr/bin/env ruby -S rspec
require 'spec_helper'

require 'puppet/provider/confine/feature'

describe Puppet::Provider::Confine::Feature do
  it "should be named :feature" do
    Puppet::Provider::Confine::Feature.name.should == :feature
  end

  it "should require a value" do
    lambda { Puppet::Provider::Confine::Feature.new }.should raise_error(ArgumentError)
  end

  it "should always convert values to an array" do
    Puppet::Provider::Confine::Feature.new("/some/file").values.should be_instance_of(Array)
  end

  describe "when testing values" do
    before do
      @confine = Puppet::Provider::Confine::Feature.new("myfeature")
      @confine.label = "eh"
    end

    it "should use the Puppet features instance to test validity" do
      Puppet.features.expects(:myfeature?)
      @confine.valid?
    end

    it "should return true if the feature is present" do
      Puppet.features.add(:myfeature) do true end
      @confine.pass?("myfeature").should be_true
    end

    it "should return false if the value is false" do
      Puppet.features.add(:myfeature) do false end
      @confine.pass?("myfeature").should be_false
    end

    it "should log that a feature is missing" do
      @confine.message("myfeat").should be_include("missing")
    end
  end

  it "should summarize multiple instances by returning a flattened array of all missing features" do
    confines = []
    confines << Puppet::Provider::Confine::Feature.new(%w{one two})
    confines << Puppet::Provider::Confine::Feature.new(%w{two})
    confines << Puppet::Provider::Confine::Feature.new(%w{three four})

    features = mock 'feature'
    features.stub_everything
    Puppet.stubs(:features).returns features

    Puppet::Provider::Confine::Feature.summarize(confines).sort.should == %w{one two three four}.sort
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppet-3.0.0.rc8 spec/unit/provider/confine/feature_spec.rb
puppet-3.0.0.rc7 spec/unit/provider/confine/feature_spec.rb
puppet-3.0.0.rc5 spec/unit/provider/confine/feature_spec.rb
puppet-3.0.0.rc4 spec/unit/provider/confine/feature_spec.rb