summaryrefslogtreecommitdiffstats
path: root/spec/unit/provider/naginator_spec.rb
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-06-28 17:10:20 -0700
committerMarkus Roberts <Markus@reality.com>2010-06-28 17:10:20 -0700
commitfdc8c3509b5ac5bc170c54d72b2c2bafb58409f2 (patch)
tree6ed2204d72c6924e867a1320d3b7e6728035f1a1 /spec/unit/provider/naginator_spec.rb
parent9a94ee274c39c261cd49e688a7bd7ea0eb73af50 (diff)
downloadpuppet-fdc8c3509b5ac5bc170c54d72b2c2bafb58409f2.tar.gz
puppet-fdc8c3509b5ac5bc170c54d72b2c2bafb58409f2.tar.xz
puppet-fdc8c3509b5ac5bc170c54d72b2c2bafb58409f2.zip
[#3994-part 3] rename spec tests from *_spec_spec to *_spec.rb
Part 2 re-did the change on the spec files, which it shouldn't have.
Diffstat (limited to 'spec/unit/provider/naginator_spec.rb')
-rwxr-xr-xspec/unit/provider/naginator_spec.rb58
1 files changed, 58 insertions, 0 deletions
diff --git a/spec/unit/provider/naginator_spec.rb b/spec/unit/provider/naginator_spec.rb
new file mode 100755
index 000000000..d0d43aa4b
--- /dev/null
+++ b/spec/unit/provider/naginator_spec.rb
@@ -0,0 +1,58 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../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