Sha256: 1f1f5b1e7c00bc60b6817b3873b81868d11cdb037743ec1cd753f5a5849011dc

Contents?: true

Size: 1.77 KB

Versions: 29

Compression:

Stored size: 1.77 KB

Contents

#! /usr/bin/env ruby
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

29 entries across 29 versions & 2 rubygems

Version Path
puppet-3.3.2 spec/unit/provider/confine/feature_spec.rb
puppet-3.3.1 spec/unit/provider/confine/feature_spec.rb
puppet-3.3.1.rc3 spec/unit/provider/confine/feature_spec.rb
puppet-3.3.1.rc2 spec/unit/provider/confine/feature_spec.rb
puppet-3.3.1.rc1 spec/unit/provider/confine/feature_spec.rb
puppet-3.3.0 spec/unit/provider/confine/feature_spec.rb
puppet-3.3.0.rc3 spec/unit/provider/confine/feature_spec.rb
puppet-3.3.0.rc2 spec/unit/provider/confine/feature_spec.rb
puppet-3.2.4 spec/unit/provider/confine/feature_spec.rb
puppet-3.2.3 spec/unit/provider/confine/feature_spec.rb
puppet-3.2.3.rc1 spec/unit/provider/confine/feature_spec.rb
puppet-3.2.2 spec/unit/provider/confine/feature_spec.rb
puppet-3.2.1 spec/unit/provider/confine/feature_spec.rb
puppet-3.2.1.rc1 spec/unit/provider/confine/feature_spec.rb
puppet-3.2.0.rc2 spec/unit/provider/confine/feature_spec.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/spec/unit/provider/confine/feature_spec.rb
puppet-3.2.0.rc1 spec/unit/provider/confine/feature_spec.rb
puppet-3.1.1 spec/unit/provider/confine/feature_spec.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/spec/unit/provider/confine/feature_spec.rb
puppet-3.1.0 spec/unit/provider/confine/feature_spec.rb