Sha256: 5cd13ea48004ea965c9ffbf28ff587625772fb9d24eb856826e012ac9b6e0571

Contents?: true

Size: 1.73 KB

Versions: 18

Compression:

Stored size: 1.73 KB

Contents

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

describe Puppet::Provider do
  it "should have a specifity class method" do
    Puppet::Provider.should respond_to(:specificity)
  end

  it "should consider two defaults to be higher specificity than one default" do
    one = Class.new(Puppet::Provider)
    one.initvars
    one.defaultfor :operatingsystem => "solaris"

    two = Class.new(Puppet::Provider)
    two.initvars
    two.defaultfor :operatingsystem => "solaris", :operatingsystemrelease => "5.10"

    two.specificity.should > one.specificity
  end

  it "should consider a subclass more specific than its parent class" do
    one = Class.new(Puppet::Provider)
    one.initvars

    two = Class.new(one)
    two.initvars

    two.specificity.should > one.specificity
  end

  it "should be Comparable" do
    res = Puppet::Type.type(:notify).new(:name => "res")

    # Normally I wouldn't like the stubs, but the only way to name a class
    # otherwise is to assign it to a constant, and that hurts more here in
    # testing world. --daniel 2012-01-29
    a = Class.new(Puppet::Provider).new(res)
    a.class.stubs(:name).returns "Puppet::Provider::Notify::A"

    b = Class.new(Puppet::Provider).new(res)
    b.class.stubs(:name).returns "Puppet::Provider::Notify::B"

    c = Class.new(Puppet::Provider).new(res)
    c.class.stubs(:name).returns "Puppet::Provider::Notify::C"

    [[a, b, c], [a, c, b], [b, a, c], [b, c, a], [c, a, b], [c, b, a]].each do |this|
      this.sort.should == [a, b, c]
    end

    a.should be < b
    a.should be < c
    b.should be > a
    b.should be < c
    c.should be > a
    c.should be > b

    [a, b, c].each {|x| a.should be <= x }
    [a, b, c].each {|x| c.should be >= x }

    b.should be_between(a, c)
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

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