Skip to content

Commit

Permalink
(PDK-508) Setup easy testing of test_module
Browse files Browse the repository at this point in the history
By pulling in puppetlabs_spec_helper into the main project, we can run
tests for the `test_module` in the main test suite without friction.
This makes it easier and quicker to run this kind of tests.

See the next commits for usage.

This requires puppetlabs/puppetlabs_spec_helper#234
  • Loading branch information
DavidS committed Mar 12, 2018
1 parent 2c9ca6f commit 89c282c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .dependency_decisions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,10 @@
:why: https://github.com/masover/blankslate/blob/f0a73b80c34bc3ad94dc3195d12a227a8fe30019/MIT-LICENSE
:versions: []
:when: 2017-11-17 14:05:09.534340925 Z
- - :license
- puppetlabs_spec_helper
- Apache 2.0
- :who: DavidS
:why:
:versions: []
:when: 2018-03-09 18:04:29.175843919 Z
8 changes: 8 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file can be used to install module depdencies for unit testing
# See https://github.com/puppetlabs/puppetlabs_spec_helper#using-fixtures for details
---
fixtures:
forge_modules:
# stdlib: "puppetlabs/stdlib"
symlinks:
test_module: "#{source_dir}/spec/fixtures/test_module"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@

# rspec failure tracking
.rspec_status

# puppetlabs_spec_helper automatic fixtures
spec/fixtures/modules/test_module
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ group :tests do
gem 'rubocop-rspec'
gem 'rubocop'
gem 'simplecov-console'
# the test gems required for module testing
gem 'puppetlabs_spec_helper', github: 'DavidS/puppetlabs_spec_helper', ref: 'refactor'
gem 'rspec-puppet'
end

group :development do
Expand All @@ -39,5 +42,5 @@ end
if ENV['PUPPET_GEM_VERSION']
gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'])
else
gem 'puppet', git: 'https://github.com/DavidS/puppet', ref: 'device-apply'
gem 'puppet', github: 'DavidS/puppet', ref: 'device-apply'
end
5 changes: 4 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'bundler/gem_tasks'
require 'puppetlabs_spec_helper/tasks/fixtures'

task :default => :spec

Expand All @@ -13,7 +14,9 @@ end
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec) do |t|
excludes = ['fixtures/**/*.rb']
Rake::Task[:spec_prep].invoke
# thanks to the fixtures/modules/ symlinks this needs to exclude fixture modules explicitely
excludes = ['fixtures/**/*.rb,fixtures/modules/*/**/*.rb']
if RUBY_PLATFORM == 'java'
excludes += ['acceptance/**/*.rb', 'integration/**/*.rb', 'puppet/resource_api/*_context_spec.rb', 'puppet/util/network_device/simple/device_spec.rb']
t.rspec_opts = '--tag ~agent_test'
Expand Down
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

require 'bundler/setup'
require 'puppet/resource_api'
require 'puppetlabs_spec_helper/module_spec_helper'

RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
Expand All @@ -42,4 +43,7 @@
config.expect_with :rspec do |c|
c.syntax = :expect
end

# override legacy default from puppetlabs_spec_helper
config.mock_with :rspec
end

0 comments on commit 89c282c

Please sign in to comment.