summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xspec/integration/provider/mailalias/aliases_spec.rb18
-rw-r--r--spec/shared_behaviours/all_parsedfile_providers.rb21
-rwxr-xr-xspec/unit/provider/host/parsed_spec.rb9
-rwxr-xr-xspec/unit/provider/mount/parsed_spec.rb25
-rwxr-xr-xspec/unit/provider/ssh_authorized_key/parsed_spec.rb8
5 files changed, 34 insertions, 47 deletions
diff --git a/spec/integration/provider/mailalias/aliases_spec.rb b/spec/integration/provider/mailalias/aliases_spec.rb
index c9c252600..19e430ba1 100755
--- a/spec/integration/provider/mailalias/aliases_spec.rb
+++ b/spec/integration/provider/mailalias/aliases_spec.rb
@@ -1,22 +1,10 @@
#!/usr/bin/env ruby
-
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
-
-require 'puppettest/fileparsing'
+require 'shared_behaviours/all_parsedfile_providers'
provider_class = Puppet::Type.type(:mailalias).provider(:aliases)
describe provider_class do
- include PuppetTest::FileParsing
-
- before :each do
- @provider = provider_class
- end
-
- # #1560
- it "should be able to parse the mailalias examples" do
- my_fixtures do |file|
- fakedataparse(file)
- end
- end
+ # #1560, in which we corrupt the format of complex mail aliases.
+ it_should_behave_like "all parsedfile providers", provider_class
end
diff --git a/spec/shared_behaviours/all_parsedfile_providers.rb b/spec/shared_behaviours/all_parsedfile_providers.rb
new file mode 100644
index 000000000..9cb199b5f
--- /dev/null
+++ b/spec/shared_behaviours/all_parsedfile_providers.rb
@@ -0,0 +1,21 @@
+shared_examples_for "all parsedfile providers" do |provider, *files|
+ if files.empty? then
+ files = my_fixtures
+ end
+
+ files.flatten.each do |file|
+ it "should rewrite #{file} reasonably unchanged" do
+ provider.stubs(:default_target).returns(file)
+ provider.prefetch
+
+ text = provider.to_file(provider.target_records(file))
+ text.gsub!(/^# HEADER.+\n/, '')
+
+ oldlines = File.readlines(file)
+ newlines = text.chomp.split "\n"
+ oldlines.zip(newlines).each do |old, new|
+ new.gsub(/\s+/, '').should == old.chomp.gsub(/\s+/, '')
+ end
+ end
+ end
+end
diff --git a/spec/unit/provider/host/parsed_spec.rb b/spec/unit/provider/host/parsed_spec.rb
index 4a616f34b..3ed479974 100755
--- a/spec/unit/provider/host/parsed_spec.rb
+++ b/spec/unit/provider/host/parsed_spec.rb
@@ -3,13 +3,11 @@
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
require 'puppet_spec/files'
-require 'puppettest/fileparsing'
provider_class = Puppet::Type.type(:host).provider(:parsed)
describe provider_class do
include PuppetSpec::Files
- include PuppetTest::FileParsing
before do
@host_class = Puppet::Type.type(:host)
@@ -130,11 +128,8 @@ describe provider_class do
end
describe "when operating on /etc/hosts like files" do
- my_fixtures('valid*') do |file|
- it "should be able to parse #{file}" do
- fakedataparse(file)
- end
- end
+ it_should_behave_like "all parsedfile providers",
+ provider_class, my_fixtures('valid*')
it "should be able to generate a simple hostfile entry" do
host = mkhost(
diff --git a/spec/unit/provider/mount/parsed_spec.rb b/spec/unit/provider/mount/parsed_spec.rb
index 0eb473978..01262f94c 100755
--- a/spec/unit/provider/mount/parsed_spec.rb
+++ b/spec/unit/provider/mount/parsed_spec.rb
@@ -4,26 +4,9 @@
# Copyright (c) 2006. All rights reserved.
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
-
-require 'puppettest/fileparsing'
+require 'shared_behaviours/all_parsedfile_providers'
module ParsedMountTesting
- include PuppetTest::FileParsing
-
- def fake_fstab
- os = Facter['operatingsystem']
- if os == "Solaris"
- name = "solaris.fstab"
- elsif os == "FreeBSD"
- name = "freebsd.fstab"
- else
- # Catchall for other fstabs
- name = "linux.fstab"
- end
- oldpath = @provider_class.default_target
- my_fixture(name)
- end
-
def mkmountargs
mount = nil
@@ -79,7 +62,13 @@ describe provider_class do
describe provider_class do
include ParsedMountTesting
+ it_should_behave_like "all parsedfile providers",
+ provider_class, my_fixtures('*.fstab')
+
it "should be able to parse all of the example mount tabs" do
+ pending "REVISIT: these may want to be dropped, or maybe rewritten."
+ # fake_fstab was just one of the *.fstab files, based on running OS,
+ # despite the claim in the title of this test. --daniel 2011-03-03
tab = fake_fstab
@provider = @provider_class
diff --git a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb
index b951b0a38..6d67ee3bb 100755
--- a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb
+++ b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb
@@ -3,7 +3,6 @@
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
require 'puppet_spec/files'
-require 'puppettest/fileparsing'
require 'puppettest/fakes'
provider_class = Puppet::Type.type(:ssh_authorized_key).provider(:parsed)
@@ -11,7 +10,6 @@ provider_class = Puppet::Type.type(:ssh_authorized_key).provider(:parsed)
describe provider_class do
include PuppetSpec::Files
include PuppetTest
- include PuppetTest::FileParsing
before :each do
@sshauthkey_class = Puppet::Type.type(:ssh_authorized_key)
@@ -48,11 +46,7 @@ describe provider_class do
@provider.target_object(@keyfile).read
end
- my_fixtures do |file|
- it "should be able to parse example data in #{file}" do
- fakedataparse(file)
- end
- end
+ it_should_behave_like "all parsedfile providers", provider_class
it "should be able to generate a basic authorized_keys file" do