Sha256: 1762523ef69573b11ffa0cb79c3d9f0655b08c84edacb80b8a3c6b5fa3dcf52b

Contents?: true

Size: 1.88 KB

Versions: 19

Compression:

Stored size: 1.88 KB

Contents

#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../../../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
      @features = mock 'features'
      Puppet.stubs(:features).returns @features
      @confine = Puppet::Provider::Confine::Feature.new("myfeature")
      @confine.label = "eh"
    end

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

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

    it "should return false if the value is false" do
      @features.expects(:myfeature?).returns false
      @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

19 entries across 19 versions & 1 rubygems

Version Path
puppet-2.6.18 spec/unit/provider/confine/feature_spec.rb
puppet-2.6.17 spec/unit/provider/confine/feature_spec.rb
puppet-2.6.16 spec/unit/provider/confine/feature_spec.rb
puppet-2.6.15 spec/unit/provider/confine/feature_spec.rb
puppet-2.6.14 spec/unit/provider/confine/feature_spec.rb
puppet-2.6.13 spec/unit/provider/confine/feature_spec.rb
puppet-2.6.12 spec/unit/provider/confine/feature_spec.rb
puppet-2.6.11 spec/unit/provider/confine/feature_spec.rb
puppet-2.6.10 spec/unit/provider/confine/feature_spec.rb
puppet-2.6.9 spec/unit/provider/confine/feature_spec.rb
puppet-2.6.8 spec/unit/provider/confine/feature_spec.rb
puppet-2.6.7 spec/unit/provider/confine/feature_spec.rb
puppet-2.6.6 spec/unit/provider/confine/feature_spec.rb
puppet-2.6.5 spec/unit/provider/confine/feature_spec.rb
puppet-2.6.4 spec/unit/provider/confine/feature_spec.rb
puppet-2.6.3 spec/unit/provider/confine/feature_spec.rb
puppet-2.6.2 spec/unit/provider/confine/feature_spec.rb
puppet-2.6.1 spec/unit/provider/confine/feature_spec.rb
puppet-2.6.0 spec/unit/provider/confine/feature_spec.rb