Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / concat / spec / unit / type / concat_file_spec.rb
index ee6992b..892ff4f 100644 (file)
@@ -1,25 +1,5 @@
 require 'spec_helper'
 
-shared_examples 'Puppet::Parameter::Boolean' do |parameter|
-  [true, :true, 'true', :yes, 'yes'].each do |value|
-    it "accepts #{value} (#{value.class}) as a value" do
-      resource[parameter] = value
-      expect(resource[parameter]).to eq(true)
-    end
-  end
-
-  [false, :false, 'false', :no, 'no'].each do |value|
-    it "accepts #{value} (#{value.class}) as a value" do
-      resource[parameter] = value
-      expect(resource[parameter]).to eq(false)
-    end
-  end
-
-  it 'does not accept "foo" as a value' do
-    expect { resource[parameter] = 'foo' }.to raise_error(%r{Invalid value "foo"})
-  end
-end
-
 describe Puppet::Type.type(:concat_file) do
   let(:resource) { described_class.new(name: '/foo/bar') }
 
@@ -34,11 +14,35 @@ describe Puppet::Type.type(:concat_file) do
   describe 'parameter :path' do
     it 'does not accept unqualified paths' do
       expect { resource[:path] = 'foo' }.to raise_error(
-        %r{File paths must be fully qualified}
+        %r{File paths must be fully qualified},
       )
     end
   end
 
+  describe 'parameter :owner' do
+    subject { described_class.attrclass(:owner) }
+
+    it 'inherits Puppet::Type::File::Owner' do
+      is_expected.to be < Puppet::Type::File::Owner
+    end
+  end
+
+  describe 'parameter :group' do
+    subject { described_class.attrclass(:group) }
+
+    it 'inherits Puppet::Type::File::Group' do
+      is_expected.to be < Puppet::Type::File::Group
+    end
+  end
+
+  describe 'parameter :mode' do
+    subject { described_class.attrclass(:mode) }
+
+    it 'inherits Puppet::Type::File::Mode' do
+      is_expected.to be < Puppet::Type::File::Mode
+    end
+  end
+
   describe 'parameter :order' do
     it 'accepts "alpha" as a value' do
       resource[:order] = 'alpha'
@@ -55,6 +59,39 @@ describe Puppet::Type.type(:concat_file) do
     end
   end
 
+  describe 'parameter :backup' do
+    it 'accepts true (TrueClass) as a value' do
+      resource[:backup] = true
+      expect(resource[:backup]).to eq(true)
+    end
+
+    it 'accepts false (FalseClass) as a value' do
+      resource[:backup] = false
+      expect(resource[:backup]).to eq(false)
+    end
+
+    it 'accepts "foo" as a value' do
+      resource[:backup] = 'foo'
+      expect(resource[:backup]).to eq('foo')
+    end
+  end
+
+  describe 'parameter :selrange' do
+    it_behaves_like 'a parameter that accepts only string values', :selrange
+  end
+
+  describe 'parameter :selrole' do
+    it_behaves_like 'a parameter that accepts only string values', :selrole
+  end
+
+  describe 'parameter :seltype' do
+    it_behaves_like 'a parameter that accepts only string values', :seltype
+  end
+
+  describe 'parameter :seluser' do
+    it_behaves_like 'a parameter that accepts only string values', :seluser
+  end
+
   describe 'parameter :replace' do
     it_behaves_like 'Puppet::Parameter::Boolean', :replace
   end
@@ -62,4 +99,52 @@ describe Puppet::Type.type(:concat_file) do
   describe 'parameter :ensure_newline' do
     it_behaves_like 'Puppet::Parameter::Boolean', :ensure_newline
   end
+
+  describe 'parameter :show_diff' do
+    it_behaves_like 'Puppet::Parameter::Boolean', :show_diff
+  end
+
+  describe 'parameter :selinux_ignore_defaults' do
+    it_behaves_like 'Puppet::Parameter::Boolean', :selinux_ignore_defaults
+  end
+
+  describe 'parameter :force' do
+    it_behaves_like 'Puppet::Parameter::Boolean', :force
+  end
+
+  describe 'parameter :format' do
+    it 'accepts "plain" as a value' do
+      resource[:format] = 'plain'
+      expect(resource[:format]).to eq(:plain)
+    end
+
+    it 'accepts "yaml" as a value' do
+      resource[:format] = 'yaml'
+      expect(resource[:format]).to eq(:yaml)
+    end
+
+    it 'accepts "json" as a value' do
+      resource[:format] = 'json'
+      expect(resource[:format]).to eq(:json)
+    end
+
+    it 'accepts "json-array" as a value' do
+      resource[:format] = 'json-array'
+      expect(resource[:format]).to eq(:'json-array')
+    end
+
+    it 'accepts "json-pretty" as a value' do
+      resource[:format] = 'json-pretty'
+      expect(resource[:format]).to eq(:'json-pretty')
+    end
+
+    it 'accepts "json-array-pretty" as a value' do
+      resource[:format] = 'json-array-pretty'
+      expect(resource[:format]).to eq(:'json-array-pretty')
+    end
+
+    it 'does not accept "bar" as a value' do
+      expect { resource[:format] = 'bar' }.to raise_error(%r{Invalid value "bar"})
+    end
+  end
 end