Skip to content

Commit e30eb0c

Browse files
committed
Refactor tesing infra
1 parent c7b11ef commit e30eb0c

File tree

7 files changed

+26
-33
lines changed

7 files changed

+26
-33
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ pkg/*
22
build/*
33
doc/
44
.yardoc
5+
Gemfile.lock

.travis.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
matrix:
3+
fast_finish: true
4+
include:
5+
- rvm: 2.0.0
6+
env: PUPPET_VERSION=3.8
7+
- rvm: 2.1.9
8+
env: PUPPET_VERSION=4.10
9+
- rvm: 2.4.1
10+
env: PUPPET_VERSION=5.0
11+
sudo: false

Gemfile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'metadata-json-lint'
4+
gem 'puppetlabs_spec_helper'
5+
gem 'puppet', ENV.key?('PUPPET_VERSION') ? "~> #{ENV['PUPPET_VERSION']}" : '>= 3.8'

Rakefile

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
require 'rubygems'
21
require 'puppetlabs_spec_helper/rake_tasks'
3-
require 'puppet-lint/tasks/puppet-lint'
4-
PuppetLint.configuration.send('disable_80chars')
5-
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
62

7-
desc "Validate manifests, templates, and ruby files"
8-
task :validate do
9-
Dir['manifests/**/*.pp'].each do |manifest|
10-
sh "puppet parser validate --noop #{manifest}"
11-
end
12-
Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file|
13-
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
14-
end
15-
Dir['templates/**/*.erb'].each do |template|
16-
sh "erb -P -x -T '-' #{template} | ruby -c"
17-
end
18-
end
3+
task :default => [:release_checks]

tests/init.pp examples/init.pp

File renamed without changes.

spec/classes/init_spec.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
require 'spec_helper'
2-
describe 'access_insights_client' do
32

3+
describe 'access_insights_client' do
44
context 'with defaults for all parameters' do
5-
it { should contain_class('access_insights_client') }
5+
it { is_expected.to compile.with_all_deps }
6+
it { is_expected.to contain_package('redhat-access-insights') }
7+
it { is_expected.to contain_file('/etc/cron.daily/redhat-access-insights').with_ensure('link') }
8+
it { is_expected.to contain_file('/etc/cron.weekly/redhat-access-insights').with_ensure('absent') }
69
end
710
end

spec/spec_helper.rb

+3-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
dir = File.expand_path(File.dirname(__FILE__))
2-
$LOAD_PATH.unshift File.join(dir, 'lib')
3-
4-
require 'mocha'
5-
require 'puppet'
6-
require 'rspec'
7-
require 'spec/autorun'
8-
9-
Spec::Runner.configure do |config|
10-
config.mock_with :mocha
1+
RSpec.configure do |c|
2+
c.mock_with :rspec
113
end
124

13-
# We need this because the RAL uses 'should' as a method. This
14-
# allows us the same behaviour but with a different method name.
15-
class Object
16-
alias :must :should
17-
end
5+
require 'puppetlabs_spec_helper/module_spec_helper'

0 commit comments

Comments
 (0)