aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNan Liu <nan.liu@gmail.com>2012-06-08 13:41:42 -0700
committerNan Liu <nan.liu@gmail.com>2012-06-08 13:41:42 -0700
commit5b360e17be617ef8e5b3722de7578642bd881b76 (patch)
tree9909c26948e85ea61f0a7321e82fc16739ccdfef
parent097a1ae83a3f43b639eb3608d3ae83aa33f7b43e (diff)
parent43b1fb32ca45eca3494fa802300153ff1c1c63e8 (diff)
downloadpuppet-tftp-5b360e17be617ef8e5b3722de7578642bd881b76.tar.gz
puppet-tftp-5b360e17be617ef8e5b3722de7578642bd881b76.tar.bz2
Merge pull request #6 from branan/use_spechelper_gem
Update module for the puppetlabs_spec_helper gem
-rw-r--r--.gemfile10
-rw-r--r--.travis.yml2
-rw-r--r--Rakefile92
-rw-r--r--spec/spec_helper.rb22
4 files changed, 4 insertions, 122 deletions
diff --git a/.gemfile b/.gemfile
index 7ba9ef9..9aad840 100644
--- a/.gemfile
+++ b/.gemfile
@@ -1,13 +1,5 @@
source :rubygems
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7']
-
gem 'puppet', puppetversion
-
-group :test do
- gem 'rake', '>= 0.9.0'
- gem 'rspec', '>= 2.8.0'
- gem 'rspec-puppet', '>= 0.1.1'
- gem 'mocha', '>= 0.11.0'
- gem 'puppet-lint', '>= 0.1.0'
-end
+gem 'puppetlabs_spec_helper', '>= 0.1.0'
diff --git a/.travis.yml b/.travis.yml
index 0ec5a08..bf7829e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,7 +3,7 @@ rvm:
- 1.8.7
before_script:
after_script:
-script: "rake spec_full"
+script: "rake spec"
branches:
only:
- master
diff --git a/Rakefile b/Rakefile
index ab25667..cd3d379 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,91 +1 @@
-require 'rake'
-require 'rspec/core/rake_task'
-require 'yaml'
-
-task :default => [:spec]
-
-desc "Run all module spec tests (Requires rspec-puppet gem)"
-RSpec::Core::RakeTask.new(:spec) do |t|
- t.rspec_opts = ['--color']
- t.pattern = 'spec/{classes,defines,unit}/**/*_spec.rb'
-end
-
-# This is a helper for the self-symlink entry of fixtures.yml
-def source_dir
- File.dirname(__FILE__)
-end
-
-def fixtures(category)
- begin
- fixtures = YAML.load_file(".fixtures.yml")["fixtures"]
- rescue Errno::ENOENT
- return {}
- end
-
- if not fixtures
- abort("malformed fixtures.yml")
- end
-
- result = {}
- if fixtures.include? category
- fixtures[category].each do |fixture, source|
- target = "spec/fixtures/modules/#{fixture}"
- real_source = eval('"'+source+'"')
- result[real_source] = target
- end
- end
- return result
-end
-
-desc "Create the fixtures directory"
-task :spec_prep do
- fixtures("repositories").each do |repo, target|
- File::exists?(target) || system("git clone #{repo} #{target}")
- end
-
- FileUtils::mkdir_p("spec/fixtures/modules")
- fixtures("symlinks").each do |source, target|
- File::exists?(target) || FileUtils::ln_s(source, target)
- end
-end
-
-desc "Clean up the fixtures directory"
-task :spec_clean do
- fixtures("repositories").each do |repo, target|
- FileUtils::rm_rf(target)
- end
-
- fixtures("symlinks").each do |source, target|
- FileUtils::rm(target)
- end
-end
-
-task :spec_full do
- Rake::Task[:spec_prep].invoke
- Rake::Task[:spec].invoke
- Rake::Task[:spec_clean].invoke
-end
-
-desc "Build puppet module package"
-task :build do
- # This will be deprecated once puppet-module is a face.
- begin
- Gem::Specification.find_by_name('puppet-module')
- rescue Gem::LoadError, NoMethodError
- require 'puppet/face'
- pmod = Puppet::Face['module', :current]
- pmod.build('./')
- end
-end
-
-desc "Clean a built module package"
-task :clean do
- FileUtils.rm_rf("pkg/")
-end
-
-desc "Check puppet manifests with puppet-lint"
-task :lint do
- # This requires pull request: https://github.com/rodjek/puppet-lint/pull/81
- system("puppet-lint manifests")
- system("puppet-lint tests")
-end
+require 'puppetlabs_spec_helper/rake_tasks'
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index efff5b4..2c6f566 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,21 +1 @@
-require 'rubygems'
-require 'puppet'
-require 'rspec-puppet'
-require 'mocha'
-require 'puppetlabs_spec_helper'
-
-def param_value(subject, type, title, param)
- subject.resource(type, title).send(:parameters)[param.to_sym]
-end
-
-Puppet.parse_config
-puppet_module_path = Puppet[:modulepath]
-
-fixture_path = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures'))
-
-RSpec.configure do |c|
- fixture_module_path = File.join(fixture_path, 'modules')
- c.module_path = [fixture_module_path, puppet_module_path].join(":")
- c.manifest_dir = File.join(fixture_path, 'manifests')
- c.mock_with :mocha
-end
+require 'puppetlabs_spec_helper/module_spec_helper'