Update module to use puppetlabs_spec_helper gem

* Automatically populate fixtures directory on spec runs
* Avoid duplicating spec_helper and Rakefile between modules
This commit is contained in:
Branan Purvine-Riley 2012-05-31 17:06:34 -07:00
parent 4a0eb9d836
commit df7c59ccee
5 changed files with 21 additions and 59 deletions

12
.fixtures.yml Normal file
View File

@ -0,0 +1,12 @@
fixtures:
repositories:
"apt": "git://github.com/puppetlabs/puppetlabs-apt.git"
"concat": "git://github.com/ripienaar/puppet-concat.git"
"keystone": "git://github.com/puppetlabs/puppetlabs-keystone.git"
"memcached": "git://github.com/saz/puppet-memcached.git"
"rsync": "git://github.com/puppetlabs/puppetlabs-rsync.git"
"ssh": "git://github.com/saz/puppet-ssh.git"
"stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
"xinetd": "git://github.com/ghoneycutt/puppet-xinetd.git"
symlinks:
"swift": "#{source_dir}"

View File

@ -1,11 +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'
end
gem 'puppetlabs_spec_helper', '>= 0.1.0'

View File

@ -1,23 +1,16 @@
language: ruby
rvm:
- 1.8.7
- 1.9.2
before_script:
- 'git clone git://github.com/saz/puppet-ssh spec/fixtures/modules/ssh'
- 'git clone git://github.com/puppetlabs/puppetlabs-rsync spec/fixtures/modules/rsync'
- 'git clone git://github.com/ghoneycutt/puppet-xinetd spec/fixtures/modules/xinetd'
- 'git clone git://github.com/saz/puppet-memcached spec/fixtures/modules/memcached'
- 'git clone git://github.com/puppetlabs/puppetlabs-stdlib spec/fixtures/modules/stdlib'
- 'git clone git://github.com/puppetlabs/puppet-apt spec/fixtures/modules/apt'
after_script:
script: "rake spec"
branches:
only:
- master
env:
- PUPPET_VERSION=2.6.12
- PUPPET_VERSION=2.6.9
- PUPPET_VERSION=2.7.6
- PUPPET_VERSION=2.7.11
matrix:
exclude:
- rvm: 1.9.2
env: PUPPET_VERSION=2.6.12
- PUPPET_VERSION=2.7.13
notifications:
email: false
gemfile: .gemfile

View File

@ -1,21 +1 @@
require 'rubygems'
require 'rake'
require 'rspec/core/rake_task'
task :default do
system("rake -T")
end
task :specs => [:spec]
desc "Run all rspec-puppet tests"
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = ['--color']
# ignores fixtures directory.
t.pattern = 'spec/{classes,defines,unit}/**/*_spec.rb'
end
desc "Build package"
task :build do
system("puppet-module build")
end
require 'puppetlabs_spec_helper/rake_tasks'

View File

@ -1,18 +1 @@
require 'puppet'
require 'rubygems'
require 'rspec-puppet'
def param_value(subject, type, title, param)
subject.resource(type, title).send(:parameters)[param.to_sym]
end
def verify_contents(subject, title, expected_lines)
content = subject.resource('file', title).send(:parameters)[:content]
(content.split("\n") & expected_lines).should == expected_lines
end
RSpec.configure do |c|
c.module_path = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures/modules'))
# Using an empty site.pp file to avoid: https://github.com/rodjek/rspec-puppet/issues/15
c.manifest_dir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures/manifests'))
end
require 'puppetlabs_spec_helper/module_spec_helper'