Parcourir la source

add a type to test inheriting from ini_setting

In order to test with rspec-puppet we need to set up the fixtures, and test via
rake spec, so we change that too
Richard Clamp il y a 11 ans
Parent
commit
bd6d244610

+ 3 - 0
.fixtures.yml

@@ -0,0 +1,3 @@
+fixtures:
+  symlinks:
+    inifile: '#{source_dir}'

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+spec/fixtures/modules/inifile
+Gemfile.lock

+ 10 - 0
spec/classes/inherit_test1_spec.rb

@@ -0,0 +1,10 @@
+require 'spec_helper'
+# We can't really test much here, apart from the type roundtrips though the
+# parser OK.
+describe 'inherit_test1' do
+  it do
+    should contain_inherit_ini_setting('valid_type').with({
+      'value' => 'true'
+    })
+  end
+end

+ 11 - 0
spec/fixtures/modules/inherit_ini_setting/lib/puppet/provider/inherit_ini_setting/ini_setting.rb

@@ -0,0 +1,11 @@
+Puppet::Type.type(:inherit_ini_setting).provide(
+  :ini_setting,
+  :parent => Puppet::Type.type(:ini_setting).provider(:ruby)
+) do
+  def section
+    '' # all global
+  end
+  def self.file_path
+    '/tmp/demo_inherit_inifile.cfg'
+  end
+end

+ 5 - 0
spec/fixtures/modules/inherit_ini_setting/lib/puppet/type/inherit_ini_setting.rb

@@ -0,0 +1,5 @@
+Puppet::Type.newtype(:inherit_ini_setting) do
+  ensurable
+  newparam(:setting, :namevar => true)
+  newproperty(:value)
+end

+ 5 - 0
spec/fixtures/modules/inherit_test1/manifests/init.pp

@@ -0,0 +1,5 @@
+class inherit_test1 {
+  inherit_ini_setting { 'valid_type':
+    value => true,
+  }
+}

+ 2 - 0
spec/spec_helper.rb

@@ -6,6 +6,8 @@ require 'puppetlabs_spec_helper/puppetlabs_spec_helper'
 
 require 'puppetlabs_spec_helper/puppetlabs_spec/files'
 
+require 'puppetlabs_spec_helper/module_spec_helper'
+
 RSpec.configure do |config|
   config.mock_with :rspec
 end