Skip to content

Commit

Permalink
Update to use puppetlabs_spec_helper gem
Browse files Browse the repository at this point in the history
* Automatically populate fixtures directory on spec runs
* Avoid duplicating spec_helper and Rakefile between modules
* Prepend fixtures to modulepath instead of overriding
* Remove recursive symlink in fixtures dir
  • Loading branch information
Branan Purvine-Riley committed Jun 1, 2012
1 parent bfc6f89 commit afba13e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 33 deletions.
9 changes: 9 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fixtures:
repositories:
"apt": "git://github.com/puppetlabs/puppetlabs-apt.git"
"keystone": "git://github.com/puppetlabs/puppetlabs-keystone.git"
"mysql": "git://github.com/puppetlabs/puppetlabs-mysql.git"
"stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
"sysctl": "git://github.com/duritong/puppet-sysctl.git"
symlinks:
"nova": "#{source_dir}"
5 changes: 5 additions & 0 deletions .gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source :rubygems

puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7']
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 0.1.0'
15 changes: 1 addition & 14 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@
require 'rake'
require 'rubygems'
require 'rspec/core/rake_task'

task :default => [:spec]

desc "Run all module spec tests (Requires rspec-puppet gem)"
RSpec::Core::RakeTask.new(:spec)

desc "Build package"
task :build do
system("puppet-module build")
end

require 'puppetlabs_spec_helper/rake_tasks'
1 change: 0 additions & 1 deletion spec/fixtures/modules/nova

This file was deleted.

19 changes: 1 addition & 18 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1 @@
require 'puppet'
require 'rspec'
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'

0 comments on commit afba13e

Please sign in to comment.