Suggest different variables to use if we want to tunnel both v4 and v6
[mirror/dsa-puppet.git] / 3rdparty / modules / concat / spec / unit / defines / concat_fragment_spec.rb
index 317b02c..4815b93 100644 (file)
@@ -11,9 +11,6 @@ describe 'concat::fragment', :type => :define do
       :order   => 10,
     }.merge(params)
 
-    id               = 'root'
-    gid              = 'root'
-
     let(:title) { title }
     let(:params) { params }
     let(:pre_condition) do
@@ -51,7 +48,7 @@ describe 'concat::fragment', :type => :define do
       let(:params) {{ :target => false }}
 
       it 'should fail' do
-        expect { catalogue }.to raise_error(Puppet::Error, /is not a string/)
+        expect { catalogue }.to raise_error(Puppet::Error, /parameter 'target' expects a .*String.*/)
       end
     end
   end # target =>
@@ -71,7 +68,7 @@ describe 'concat::fragment', :type => :define do
       let(:params) {{ :content => false, :target => '/etc/motd' }}
 
       it 'should fail' do
-        expect { catalogue }.to raise_error(Puppet::Error, /is not a string/)
+        expect { catalogue }.to raise_error(Puppet::Error, /parameter 'content' expects a .*String.*/ )
       end
     end
   end # content =>
@@ -86,29 +83,74 @@ describe 'concat::fragment', :type => :define do
       end
     end
 
+    context 'false' do
+       let(:title) { 'motd_header' }
+       let(:params) {{ :source => false, :target => '/etc/motd' }}
+
+       it 'should fail' do
+         expect { catalogue }.to raise_error(Puppet::Error, /parameter 'source' expects a .*String.*Array.*/)
+       end
+     end
+  end # source =>
+
+  context 'order =>' do
+    ['', '42', 'a', 'z'].each do |order|
+      context '\'\'' do
+        it_behaves_like 'fragment', 'motd_header', {
+          :order  => order,
+          :target => '/etc/motd',
+        }
+      end
+    end
+
     context 'false' do
       let(:title) { 'motd_header' }
-      let(:params) {{ :source => false, :target => '/etc/motd' }}
+      let(:params) {{ :order => false, :target => '/etc/motd' }}
 
       it 'should fail' do
-        expect { catalogue }.to raise_error(Puppet::Error, /is not a string or an Array/)
+        expect { catalogue }.to raise_error(Puppet::Error, /Evaluation Error.*expects.*Boolean.*/)
       end
     end
-  end # source =>
+
+    context '123:456' do
+      let(:title) { 'motd_header' }
+      let(:params) {{ :order => '123:456', :target => '/etc/motd' }}
+
+      it 'should fail' do
+        expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/)
+      end
+    end
+    context '123/456' do
+      let(:title) { 'motd_header' }
+      let(:params) {{ :order => '123/456', :target => '/etc/motd' }}
+
+      it 'should fail' do
+        expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/)
+      end
+    end
+    context '123\n456' do
+      let(:title) { 'motd_header' }
+      let(:params) {{ :order => "123\n456", :target => '/etc/motd' }}
+
+      it 'should fail' do
+        expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/)
+      end
+    end
+  end # order =>
 
   context 'more than one content source' do
     context 'source and content' do
       let(:title) { 'motd_header' }
       let(:params) do
         {
-          :target => '/etc/motd', 
+          :target => '/etc/motd',
           :source => '/foo',
           :content => 'bar',
         }
       end
 
       it 'should fail' do
-        expect { catalogue }.to raise_error(Puppet::Error, /Can't use 'source' and 'content' at the same time/)
+        expect { catalogue }.to raise_error(Puppet::Error, /Can\'t use \'source\' and \'content\' at the same time/m)
       end
     end
   end # more than one content source