Sha256: e06890dd1438080aa8755b5d90df9f84a3938e1e36f4570be88ccaab5a03af19

Contents?: true

Size: 1.67 KB

Versions: 63

Compression:

Stored size: 1.67 KB

Contents

#! /usr/bin/env ruby
require 'spec_helper'

require 'puppet/confine/feature'

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

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

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

  describe "when testing values" do
    before do
      @confine = Puppet::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::Confine::Feature.new(%w{one two})
    confines << Puppet::Confine::Feature.new(%w{two})
    confines << Puppet::Confine::Feature.new(%w{three four})

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

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

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
puppet-3.8.7 spec/unit/confine/feature_spec.rb
puppet-3.8.7-x86-mingw32 spec/unit/confine/feature_spec.rb
puppet-3.8.7-x64-mingw32 spec/unit/confine/feature_spec.rb
puppet-3.8.6 spec/unit/confine/feature_spec.rb
puppet-3.8.6-x86-mingw32 spec/unit/confine/feature_spec.rb
puppet-3.8.6-x64-mingw32 spec/unit/confine/feature_spec.rb
puppet-3.8.5 spec/unit/confine/feature_spec.rb
puppet-3.8.5-x86-mingw32 spec/unit/confine/feature_spec.rb
puppet-3.8.5-x64-mingw32 spec/unit/confine/feature_spec.rb
puppet-3.8.4 spec/unit/confine/feature_spec.rb
puppet-3.8.4-x86-mingw32 spec/unit/confine/feature_spec.rb
puppet-3.8.4-x64-mingw32 spec/unit/confine/feature_spec.rb
puppet-3.8.3 spec/unit/confine/feature_spec.rb
puppet-3.8.3-x86-mingw32 spec/unit/confine/feature_spec.rb
puppet-3.8.3-x64-mingw32 spec/unit/confine/feature_spec.rb
puppet-3.8.2 spec/unit/confine/feature_spec.rb
puppet-3.8.2-x86-mingw32 spec/unit/confine/feature_spec.rb
puppet-3.8.2-x64-mingw32 spec/unit/confine/feature_spec.rb
puppet-3.8.1 spec/unit/confine/feature_spec.rb
puppet-3.8.1-x86-mingw32 spec/unit/confine/feature_spec.rb