diff --git a/Rakefile b/Rakefile index 267d07e..f078f1d 100644 --- a/Rakefile +++ b/Rakefile @@ -1,56 +1,56 @@ # This file is managed centrally by modulesync # https://github.com/theforeman/foreman-installer-modulesync require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' # blacksmith isn't always present, e.g. on Travis with --without development begin require 'puppet_blacksmith/rake_tasks' Blacksmith::RakeTask.new do |t| t.tag_pattern = "%s" t.tag_message_pattern = "Version %s" t.tag_sign = true end rescue LoadError end begin require 'github_changelog_generator/task' # https://github.com/github-changelog-generator/github-changelog-generator/issues/313 module GitHubChangelogGeneratorExtensions def compound_changelog super.gsub(/(fixes|fixing|refs) \\#(\d+)/i, '\1 [\\#\2](https://projects.theforeman.org/issues/\2)') end end class GitHubChangelogGenerator::Generator prepend GitHubChangelogGeneratorExtensions end GitHubChangelogGenerator::RakeTask.new :changelog do |config| raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil? metadata = JSON.load(File.read('metadata.json')) - config.user = metadata['author'] + config.user = 'theforeman' config.project = "puppet-#{metadata['name'].split('-').last}" config.future_release = metadata['version'] config.exclude_labels = ['duplicate', 'question', 'invalid', 'wontfix', 'Modulesync', 'skip-changelog'] end rescue LoadError end PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "vendor/**/*.pp"] PuppetLint.configuration.log_format = '%{path}:%{line}:%{KIND}: %{message}' require 'puppet-lint-param-docs/tasks' PuppetLintParamDocs.define_selective do |config| config.pattern = ["manifests/init.pp"] end require 'kafo_module_lint/tasks' KafoModuleLint::RakeTask.new do |config| config.pattern = ["manifests/init.pp"] end task :default => [:release_checks] diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c6931af..b8153cf 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,75 +1,74 @@ # This file is managed centrally by modulesync # https://github.com/theforeman/foreman-installer-modulesync require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' include RspecPuppetFacts # Original fact sources: -add_custom_fact :concat_basedir, '/tmp' # puppetlabs-concat add_custom_fact :puppet_environmentpath, '/etc/puppetlabs/code/environments' # puppetlabs-stdlib add_custom_fact :root_home, '/root' # puppetlabs-stdlib # Workaround for no method in rspec-puppet to pass undef through :params class Undef def inspect; 'undef'; end end # Running tests with the ONLY_OS environment variable set # limits the tested platforms to the specified values. # Example: ONLY_OS=centos-7-x86_64,ubuntu-14-x86_64 def only_test_os if ENV.key?('ONLY_OS') ENV['ONLY_OS'].split(',') end end # Running tests with the EXCLUDE_OS environment variable set # limits the tested platforms to all but the specified values. # Example: EXCLUDE_OS=centos-7-x86_64,ubuntu-14-x86_64 def exclude_test_os if ENV.key?('EXCLUDE_OS') ENV['EXCLUDE_OS'].split(',') end end # Use the above environment variables to limit the platforms under test def on_os_under_test on_supported_os.reject do |os, facts| (only_test_os() && !only_test_os.include?(os)) || (exclude_test_os() && exclude_test_os.include?(os)) end end def get_content(subject, title) is_expected.to contain_file(title) content = subject.resource('file', title).send(:parameters)[:content] content.split(/\n/).reject { |line| line =~ /(^#|^$|^\s+#)/ } end def verify_exact_contents(subject, title, expected_lines) expect(get_content(subject, title)).to match_array(expected_lines) end def verify_concat_fragment_contents(subject, title, expected_lines) is_expected.to contain_concat__fragment(title) content = subject.resource('concat::fragment', title).send(:parameters)[:content] expect(content.split("\n") & expected_lines).to match_array(expected_lines) end def verify_concat_fragment_exact_contents(subject, title, expected_lines) is_expected.to contain_concat__fragment(title) content = subject.resource('concat::fragment', title).send(:parameters)[:content] expect(content.split(/\n/).reject { |line| line =~ /(^#|^$|^\s+#)/ }).to match_array(expected_lines) end aio = on_os_under_test.reject do |os, facts| ['FreeBSD', 'DragonFly', 'Windows'].include?(facts[:operatingsystem]) end.keys add_custom_fact :rubysitedir, '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0', :confine => aio def unsupported_puppetmaster_osfamily(osfamily) ['Archlinux', 'windows', 'Suse'].include?(osfamily) end