[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5
Daniel Pittman
daniel at rimspace.net
Tue May 10 08:05:44 UTC 2011
The following commit has been merged in the experimental branch:
commit 53b6df3781fe67a3e7fd686cb93cad50c40c6ce3
Author: Daniel Pittman <daniel at rimspace.net>
Date: Thu Mar 3 00:05:38 2011 -0800
(#6582) eliminate fakeparsefile helper method.
This was a helper that implemented rspec style "shared behaviour" for
Test::Unit; now that we have moved on we can use the upstream implementation
instead. This eliminates a whole bit of code we have to maintain.
Reviewed-By: Nick Lewis <nick at puppetlabs.com>
diff --git a/spec/integration/provider/mailalias/aliases_spec.rb b/spec/integration/provider/mailalias/aliases_spec.rb
index c9c2526..19e430b 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 0000000..9cb199b
--- /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 4a616f3..3ed4799 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 0eb4739..01262f9 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 b951b0a..6d67ee3 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
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list