summaryrefslogtreecommitdiff
path: root/spec/unit/puppet/util/ini_file_spec.rb
diff options
context:
space:
mode:
authorChris Price <chris@puppetlabs.com>2012-07-28 21:59:54 -0700
committerChris Price <chris@puppetlabs.com>2012-07-28 21:59:54 -0700
commit9c76b6af1200c71e7ae72e0e2f349919a3081738 (patch)
treee3dc5ca1824f1fcf74c08e78d649eed394408a78 /spec/unit/puppet/util/ini_file_spec.rb
parent91273a5a2b0c88e7129908406fd0933a0d88ef11 (diff)
downloadpuppet-inifile-9c76b6af1200c71e7ae72e0e2f349919a3081738.tar.gz
puppet-inifile-9c76b6af1200c71e7ae72e0e2f349919a3081738.tar.bz2
First (basic) working version of ini_setting provider
Diffstat (limited to 'spec/unit/puppet/util/ini_file_spec.rb')
-rw-r--r--spec/unit/puppet/util/ini_file_spec.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/unit/puppet/util/ini_file_spec.rb b/spec/unit/puppet/util/ini_file_spec.rb
new file mode 100644
index 0000000..7e7458a
--- /dev/null
+++ b/spec/unit/puppet/util/ini_file_spec.rb
@@ -0,0 +1,47 @@
+require 'spec_helper'
+require 'puppet/util/ini_file'
+
+describe Puppet::Util::IniFile do
+ context "when parsing a file" do
+ let(:subject) { Puppet::Util::IniFile.new("/my/ini/file/path") }
+ let(:sample_content) {
+ template = <<-EOS
+# This is a comment
+[section1]
+; This is also a comment
+foo=foovalue
+
+bar = barvalue
+[section2]
+
+foo= foovalue2
+baz=bazvalue
+ #another comment
+ ; yet another comment
+ EOS
+ template.split("\n")
+ }
+
+ before :each do
+ described_class.should_receive(:readlines).once.with("/my/ini/file/path") do
+ sample_content
+ end
+ end
+
+ it "should parse the correct number of sections" do
+ subject.section_names.length.should == 2
+ end
+
+ it "should parse the correct section_names" do
+ subject.section_names.should == ["section1", "section2"]
+ end
+
+ it "should expose settings for sections" do
+ subject.get_value("section1", "foo").should == "foovalue"
+ subject.get_value("section1", "bar").should == "barvalue"
+ subject.get_value("section2", "foo").should == "foovalue2"
+ subject.get_value("section2", "baz").should == "bazvalue"
+ end
+
+ end
+end \ No newline at end of file