Sha256: 8ebe6302503ba6560b790be98f86bb365aef763f11e34cfc3a8f7d248ef3d092

Contents?: true

Size: 1.66 KB

Versions: 35

Compression:

Stored size: 1.66 KB

Contents

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

require 'puppet/provider/naginator'

describe Puppet::Provider::Naginator do
  before do
    @resource_type = stub 'resource_type', :name => :nagios_test
    @class = Class.new(Puppet::Provider::Naginator)

    @class.stubs(:resource_type).returns @resource_type
  end

  it "should be able to look up the associated Nagios type" do
    nagios_type = mock "nagios_type"
    nagios_type.stubs :attr_accessor
    Nagios::Base.expects(:type).with(:test).returns nagios_type

    @class.nagios_type.should equal(nagios_type)
  end

  it "should use the Nagios type to determine whether an attribute is valid" do
    nagios_type = mock "nagios_type"
    nagios_type.stubs :attr_accessor
    Nagios::Base.expects(:type).with(:test).returns nagios_type

    nagios_type.expects(:parameters).returns [:foo, :bar]

    @class.valid_attr?(:test, :foo).should be_true
  end

  it "should use Naginator to parse configuration snippets" do
    parser = mock 'parser'
    parser.expects(:parse).with("my text").returns "my instances"
    Nagios::Parser.expects(:new).returns(parser)

    @class.parse("my text").should == "my instances"
  end

  it "should join Nagios::Base records with '\\n' when asked to convert them to text" do
    @class.expects(:header).returns "myheader\n"

    @class.to_file([:one, :two]).should == "myheader\none\ntwo"
  end

  it "should be able to prefetch instance from configuration files" do
    @class.should respond_to(:prefetch)
  end

  it "should be able to generate a list of instances" do
    @class.should respond_to(:instances)
  end

  it "should never skip records" do
    @class.should_not be_skip_record("foo")
  end
end

Version data entries

35 entries across 35 versions & 3 rubygems

Version Path
puppet-2.7.26 spec/unit/provider/naginator_spec.rb
puppet-2.7.25 spec/unit/provider/naginator_spec.rb
puppet-2.7.24 spec/unit/provider/naginator_spec.rb
puppet-2.7.23 spec/unit/provider/naginator_spec.rb
puppet-2.7.22 spec/unit/provider/naginator_spec.rb
puppet-2.7.21 spec/unit/provider/naginator_spec.rb
puppet-2.7.20 spec/unit/provider/naginator_spec.rb
puppet-2.7.20.rc1 spec/unit/provider/naginator_spec.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/provider/naginator_spec.rb
puppet-2.7.19 spec/unit/provider/naginator_spec.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/provider/naginator_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/provider/naginator_spec.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/provider/naginator_spec.rb
puppet-2.7.18 spec/unit/provider/naginator_spec.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/provider/naginator_spec.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/provider/naginator_spec.rb
puppet-2.7.17 spec/unit/provider/naginator_spec.rb
puppet-2.7.16 spec/unit/provider/naginator_spec.rb
puppet-2.7.14 spec/unit/provider/naginator_spec.rb
puppet-2.7.13 spec/unit/provider/naginator_spec.rb