diff --git a/Gemfile b/Gemfile index 2df03ec..58723d2 100644 --- a/Gemfile +++ b/Gemfile @@ -4,4 +4,5 @@ gem 'rake' gem 'puppet-lint' +gem 'rspec-puppet' gem 'puppet', puppetversion diff --git a/Rakefile b/Rakefile index bdb32be..733330f 100644 --- a/Rakefile +++ b/Rakefile @@ -1,12 +1,17 @@ require 'rake' begin + require 'rspec/core/rake_task' require 'puppet-lint/tasks/puppet-lint' rescue LoadError require 'rubygems' retry end -task :test => [:lint] +RSpec::Core::RakeTask.new(:spec) do |t| + t.pattern = 'spec/*/*_spec.rb' +end + +task :test => [:spec, :lint] task :default => :test diff --git a/spec/defines/iface_spec.rb b/spec/defines/iface_spec.rb new file mode 100644 index 0000000..a443385 --- /dev/null +++ b/spec/defines/iface_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe 'interfaces::iface' do + let(:title) { 'lo' } + let(:params) { { :family => 'inet', :method => 'loopback', :auto => 1 } } + + it { + should contain_interfaces__auto('lo') + should contain_concat__fragment('interfaces::iface_lo').with_target('/etc/network/interfaces') + should contain_concat__fragment('interfaces::iface_lo').with_content('iface lo inet loopback\n\t\n\n') + } +end diff --git a/spec/fixtures/manifests/site.pp b/spec/fixtures/manifests/site.pp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/spec/fixtures/manifests/site.pp diff --git a/spec/fixtures/modules/interfaces/manifests b/spec/fixtures/modules/interfaces/manifests new file mode 120000 index 0000000..373b992 --- /dev/null +++ b/spec/fixtures/modules/interfaces/manifests @@ -0,0 +1 @@ +../../../../manifests \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..8c3a6cb --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,6 @@ +require 'rspec-puppet' + +RSpec.configure do |c| + c.module_path = File.expand_path(File.join(__FILE__, '..', 'fixtures', 'modules')) + c.manifest_dir = File.expand_path(File.join(__FILE__, '..', 'fixtures', 'manifests')) +end