Skip to content

Commit

Permalink
Convert test fixtures over to new style provided by PL - fixes #12
Browse files Browse the repository at this point in the history
  • Loading branch information
Tray Torrance committed Jun 20, 2013
1 parent c00d50d commit b955693
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 58 deletions.
4 changes: 4 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixtures:
symlinks:
cron: "#{source_dir}"
10 changes: 4 additions & 6 deletions .travis/Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
source :rubygems
source 'https://rubygems.org'

gem 'puppet'
puppet_version = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7']

gem 'rake'
gem 'rspec'
gem 'rspec-puppet'
gem 'puppetlabs_spec_helper'
gem 'puppet', puppet_version
gem 'puppetlabs_spec_helper', '>= 0.1.0'

6 changes: 5 additions & 1 deletion .travis/travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
language: ruby
script: "rake spec"
rvm:
- 1.8.7
- 1.9.3

- 2.0.0
env:
- PUPPET_VERSION=2.7.22
- PUPPET_VERSION=3.2.2
gemfile: .travis/Gemfile

43 changes: 2 additions & 41 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,42 +1,3 @@
require 'rake'
require 'json'
require 'fileutils'
require 'rspec/core/rake_task'

task :default => :spec

RSpec::Core::RakeTask.new( :spec ) do |task|
task.rspec_opts = %w[ --color --format doc ]
task.pattern = 'spec/*/*_spec.rb'
end

task :build => [:spec, :clean] do
`puppet module build`

# TODO: Find a way to package without such a nasty hack
pkg = Dir['pkg/*.tar.gz'].first
pkg_dir = pkg.gsub('.tar.gz', '')
name = pkg.match(%r{^pkg/(\w+-\w+)})[1]
version = pkg.match(%r{\d\.\d\.\d})[0]

# Blow away and re-create the module without specs
# (Works around https://github.com/torrancew/puppet-cron/issues/12)
FileUtils.rm_f pkg
Dir["#{pkg_dir}/{Rakefile,spec}"].each { |f| FileUtils.rm_rf f }

metadata = JSON.parse(File.read("#{pkg_dir}/metadata.json"))

metadata["checksums"].delete_if do |key, value|
key.match(%r{^(spec/|Rakefile)})
end

File.open("#{pkg_dir}/metadata.json", 'w') { |f| f.write(JSON.dump(metadata)) }
puts 'Building module'
`tar cvzf #{pkg} -C pkg/ #{name}-#{version}/`
end

task :clean do
puts 'Cleaning module builds'
Dir['pkg/*'].each { |f| FileUtils.rm_rf f }
end
require 'rubygems'
require 'puppetlabs_spec_helper/rake_tasks'

Empty file removed spec/fixtures/manifests/site.pp
Empty file.
1 change: 0 additions & 1 deletion spec/fixtures/modules/cron/manifests

This file was deleted.

1 change: 0 additions & 1 deletion spec/fixtures/modules/cron/templates

This file was deleted.

10 changes: 2 additions & 8 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
require 'rspec-puppet'

fixture_path = File.expand_path( File.join( __FILE__, '..', 'fixtures' ))

RSpec.configure do |spec|
spec.module_path = File.join( fixture_path, 'modules' )
spec.manifest_dir = File.join( fixture_path, 'manifests' )
end
require 'rubygems'
require 'puppetlabs_spec_helper/module_spec_helper'

def get_timestamp( params = {} )
stamp = ''
Expand Down

0 comments on commit b955693

Please sign in to comment.