Sha256: ea883b07f8a5ebd1182a9a344e9370675111450e682195560000538239f3e36a

Contents?: true

Size: 1.77 KB

Versions: 17

Compression:

Stored size: 1.77 KB

Contents

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

17 entries across 17 versions & 2 rubygems

Version Path
puppet-2.7.26 spec/unit/provider/confine/feature_spec.rb
puppet-2.7.25 spec/unit/provider/confine/feature_spec.rb
puppet-2.7.24 spec/unit/provider/confine/feature_spec.rb
puppet-2.7.23 spec/unit/provider/confine/feature_spec.rb
puppet-2.7.22 spec/unit/provider/confine/feature_spec.rb
puppet-2.7.21 spec/unit/provider/confine/feature_spec.rb
puppet-2.7.20 spec/unit/provider/confine/feature_spec.rb
puppet-2.7.20.rc1 spec/unit/provider/confine/feature_spec.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/provider/confine/feature_spec.rb
puppet-2.7.19 spec/unit/provider/confine/feature_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/provider/confine/feature_spec.rb
puppet-2.7.18 spec/unit/provider/confine/feature_spec.rb
puppet-2.7.17 spec/unit/provider/confine/feature_spec.rb
puppet-2.7.16 spec/unit/provider/confine/feature_spec.rb
puppet-2.7.14 spec/unit/provider/confine/feature_spec.rb
puppet-2.7.13 spec/unit/provider/confine/feature_spec.rb
puppet-2.7.12 spec/unit/provider/confine/feature_spec.rb