summaryrefslogtreecommitdiffstats
path: root/spec/unit/file_serving/configuration/parser.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-03-31 23:56:09 -0500
committerLuke Kanies <luke@madstop.com>2008-03-31 23:56:09 -0500
commit88dc49cb7b0efe757c92ce28c807b91335acb07a (patch)
tree13fe4561f1f524f97a8bb2c1ff84c1ef981d0241 /spec/unit/file_serving/configuration/parser.rb
parent4165edaeb71ee2883b1bb85ff39a52d5628b259f (diff)
parenta8592f1009040ebf30a98268610915cc33bb3f63 (diff)
downloadpuppet-88dc49cb7b0efe757c92ce28c807b91335acb07a.tar.gz
puppet-88dc49cb7b0efe757c92ce28c807b91335acb07a.tar.xz
puppet-88dc49cb7b0efe757c92ce28c807b91335acb07a.zip
Merge branch 'master' into master_no_global_resources
Conflicts: lib/puppet/node/catalog.rb lib/puppet/type/pfile.rb lib/puppet/type/pfilebucket.rb lib/puppet/util/filetype.rb spec/unit/node/catalog.rb spec/unit/other/transbucket.rb spec/unit/ral/provider/mount/parsed.rb spec/unit/ral/types/file.rb spec/unit/ral/types/interface.rb spec/unit/ral/types/mount.rb spec/unit/ral/types/package.rb spec/unit/ral/types/schedule.rb spec/unit/ral/types/service.rb test/language/compile.rb test/language/lexer.rb test/language/snippets.rb test/lib/puppettest.rb test/ral/types/basic.rb test/ral/types/cron.rb test/ral/types/exec.rb test/ral/types/file.rb test/ral/types/file/target.rb test/ral/types/filebucket.rb test/ral/types/fileignoresource.rb test/ral/types/filesources.rb test/ral/types/group.rb test/ral/types/host.rb test/ral/types/parameter.rb test/ral/types/sshkey.rb test/ral/types/tidy.rb test/ral/types/user.rb test/ral/types/yumrepo.rb
Diffstat (limited to 'spec/unit/file_serving/configuration/parser.rb')
-rwxr-xr-xspec/unit/file_serving/configuration/parser.rb175
1 files changed, 89 insertions, 86 deletions
diff --git a/spec/unit/file_serving/configuration/parser.rb b/spec/unit/file_serving/configuration/parser.rb
index aa296cf43..df2f629d5 100755
--- a/spec/unit/file_serving/configuration/parser.rb
+++ b/spec/unit/file_serving/configuration/parser.rb
@@ -10,8 +10,17 @@ describe Puppet::FileServing::Configuration::Parser do
end
end
+
module FSConfigurationParserTesting
- def setup
+ def mock_file_content(content)
+ # We want an array, but we actually want our carriage returns on all of it.
+ lines = content.split("\n").collect { |l| l + "\n" }
+ @filehandle.stubs(:each).multiple_yields(*lines)
+ end
+end
+
+describe Puppet::FileServing::Configuration::Parser do
+ before :each do
@path = "/my/config.conf"
FileTest.stubs(:exists?).with(@path).returns(true)
FileTest.stubs(:readable?).with(@path).returns(true)
@@ -20,113 +29,107 @@ module FSConfigurationParserTesting
@parser = Puppet::FileServing::Configuration::Parser.new(@path)
end
- def mock_file_content(content)
- # We want an array, but we actually want our carriage returns on all of it.
- lines = content.split("\n").collect { |l| l + "\n" }
- @filehandle.stubs(:each).multiple_yields(*lines)
- end
-end
-
-describe Puppet::FileServing::Configuration::Parser, " when parsing" do
- include FSConfigurationParserTesting
+ describe Puppet::FileServing::Configuration::Parser, " when parsing" do
+ include FSConfigurationParserTesting
- before do
- @parser.stubs(:add_modules_mount)
- end
+ before do
+ @parser.stubs(:add_modules_mount)
+ end
- it "should allow comments" do
- @filehandle.expects(:each).yields("# this is a comment\n")
- proc { @parser.parse }.should_not raise_error
- end
+ it "should allow comments" do
+ @filehandle.expects(:each).yields("# this is a comment\n")
+ proc { @parser.parse }.should_not raise_error
+ end
- it "should allow blank lines" do
- @filehandle.expects(:each).yields("\n")
- proc { @parser.parse }.should_not raise_error
- end
+ it "should allow blank lines" do
+ @filehandle.expects(:each).yields("\n")
+ proc { @parser.parse }.should_not raise_error
+ end
- it "should create a new mount for each section in the configuration" do
- mount1 = mock 'one'
- mount2 = mock 'two'
- Puppet::FileServing::Mount.expects(:new).with("one").returns(mount1)
- Puppet::FileServing::Mount.expects(:new).with("two").returns(mount2)
- mock_file_content "[one]\n[two]\n"
- @parser.parse
- end
+ it "should create a new mount for each section in the configuration" do
+ mount1 = mock 'one'
+ mount2 = mock 'two'
+ Puppet::FileServing::Mount.expects(:new).with("one").returns(mount1)
+ Puppet::FileServing::Mount.expects(:new).with("two").returns(mount2)
+ mock_file_content "[one]\n[two]\n"
+ @parser.parse
+ end
- # This test is almost the exact same as the previous one.
- it "should return a hash of the created mounts" do
- mount1 = mock 'one'
- mount2 = mock 'two'
- Puppet::FileServing::Mount.expects(:new).with("one").returns(mount1)
- Puppet::FileServing::Mount.expects(:new).with("two").returns(mount2)
- mock_file_content "[one]\n[two]\n"
+ # This test is almost the exact same as the previous one.
+ it "should return a hash of the created mounts" do
+ mount1 = mock 'one'
+ mount2 = mock 'two'
+ Puppet::FileServing::Mount.expects(:new).with("one").returns(mount1)
+ Puppet::FileServing::Mount.expects(:new).with("two").returns(mount2)
+ mock_file_content "[one]\n[two]\n"
- @parser.parse.should == {"one" => mount1, "two" => mount2}
- end
+ @parser.parse.should == {"one" => mount1, "two" => mount2}
+ end
- it "should only allow mount names that are alphanumeric plus dashes" do
- mock_file_content "[a*b]\n"
- proc { @parser.parse }.should raise_error(ArgumentError)
- end
+ it "should only allow mount names that are alphanumeric plus dashes" do
+ mock_file_content "[a*b]\n"
+ proc { @parser.parse }.should raise_error(ArgumentError)
+ end
- it "should fail if the value for path/allow/deny starts with an equals sign" do
- mock_file_content "[one]\npath = /testing"
- proc { @parser.parse }.should raise_error(ArgumentError)
+ it "should fail if the value for path/allow/deny starts with an equals sign" do
+ mock_file_content "[one]\npath = /testing"
+ proc { @parser.parse }.should raise_error(ArgumentError)
+ end
end
-end
-describe Puppet::FileServing::Configuration::Parser, " when parsing mount attributes" do
- include FSConfigurationParserTesting
+ describe Puppet::FileServing::Configuration::Parser, " when parsing mount attributes" do
+ include FSConfigurationParserTesting
- before do
- @mount = stub 'mount', :name => "one"
- Puppet::FileServing::Mount.expects(:new).with("one").returns(@mount)
- @parser.stubs(:add_modules_mount)
- end
+ before do
+ @mount = stub 'mount', :name => "one"
+ Puppet::FileServing::Mount.expects(:new).with("one").returns(@mount)
+ @parser.stubs(:add_modules_mount)
+ end
- it "should set the mount path to the path attribute from that section" do
- mock_file_content "[one]\npath /some/path\n"
+ it "should set the mount path to the path attribute from that section" do
+ mock_file_content "[one]\npath /some/path\n"
- @mount.expects(:path=).with("/some/path")
- @parser.parse
- end
+ @mount.expects(:path=).with("/some/path")
+ @parser.parse
+ end
- it "should tell the mount to allow any allow values from the section" do
- mock_file_content "[one]\nallow something\n"
+ it "should tell the mount to allow any allow values from the section" do
+ mock_file_content "[one]\nallow something\n"
- @mount.expects(:info)
- @mount.expects(:allow).with("something")
- @parser.parse
- end
+ @mount.expects(:info)
+ @mount.expects(:allow).with("something")
+ @parser.parse
+ end
- it "should tell the mount to deny any deny values from the section" do
- mock_file_content "[one]\ndeny something\n"
+ it "should tell the mount to deny any deny values from the section" do
+ mock_file_content "[one]\ndeny something\n"
- @mount.expects(:info)
- @mount.expects(:deny).with("something")
- @parser.parse
- end
+ @mount.expects(:info)
+ @mount.expects(:deny).with("something")
+ @parser.parse
+ end
- it "should fail on any attributes other than path, allow, and deny" do
- mock_file_content "[one]\ndo something\n"
+ it "should fail on any attributes other than path, allow, and deny" do
+ mock_file_content "[one]\ndo something\n"
- proc { @parser.parse }.should raise_error(ArgumentError)
+ proc { @parser.parse }.should raise_error(ArgumentError)
+ end
end
-end
-describe Puppet::FileServing::Configuration::Parser, " when parsing the modules mount" do
- include FSConfigurationParserTesting
+ describe Puppet::FileServing::Configuration::Parser, " when parsing the modules mount" do
+ include FSConfigurationParserTesting
- before do
- @mount = stub 'mount', :name => "modules"
- Puppet::FileServing::Mount.expects(:new).with("modules").returns(@mount)
- end
+ before do
+ @mount = stub 'mount', :name => "modules"
+ Puppet::FileServing::Mount.expects(:new).with("modules").returns(@mount)
+ end
- it "should warn if a path is set" do
- mock_file_content "[modules]\npath /some/path\n"
+ it "should warn if a path is set" do
+ mock_file_content "[modules]\npath /some/path\n"
- @modules.expects(:path=).never
- Puppet.expects(:warning)
- @parser.parse
+ @modules.expects(:path=).never
+ Puppet.expects(:warning)
+ @parser.parse
+ end
end
-end
+end \ No newline at end of file