diff --git a/.sync.yml b/.sync.yml new file mode 100644 index 0000000..9bbb71a --- /dev/null +++ b/.sync.yml @@ -0,0 +1,6 @@ +--- +spec/spec_helper.rb: + mock_with: ':rspec' +.travis.yml: + branches: + - master diff --git a/Rakefile b/Rakefile index cb7ed0c..0a5093b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,88 +1,87 @@ # frozen_string_literal: true require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-syntax/tasks/puppet-syntax' require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any? require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any? def changelog_user return unless Rake.application.top_level_tasks.include? "changelog" returnVal = nil || JSON.load(File.read('metadata.json'))['author'] raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil? puts "GitHubChangelogGenerator user:#{returnVal}" returnVal end def changelog_project return unless Rake.application.top_level_tasks.include? "changelog" returnVal = nil returnVal ||= begin metadata_source = JSON.load(File.read('metadata.json'))['source'] metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z}) metadata_source_match && metadata_source_match[1] end raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil? puts "GitHubChangelogGenerator project:#{returnVal}" returnVal end def changelog_future_release return unless Rake.application.top_level_tasks.include? "changelog" returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version'] raise "unable to find the future_release (version) in metadata.json" if returnVal.nil? puts "GitHubChangelogGenerator future_release:#{returnVal}" returnVal end PuppetLint.configuration.send('disable_relative') if Bundler.rubygems.find_name('github_changelog_generator').any? 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? config.user = "#{changelog_user}" config.project = "#{changelog_project}" config.future_release = "#{changelog_future_release}" config.exclude_labels = ['maintenance'] config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)." config.add_pr_wo_labels = true config.issues = false - config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM" + config.merge_prefix = "### UNCATEGORIZED PRS; LABEL THEM ON GITHUB" config.configure_sections = { "Changed" => { "prefix" => "### Changed", "labels" => ["backwards-incompatible"], }, "Added" => { "prefix" => "### Added", - "labels" => ["feature", "enhancement"], + "labels" => ["enhancement", "feature"], }, "Fixed" => { "prefix" => "### Fixed", - "labels" => ["bugfix"], + "labels" => ["bug", "documentation", "bugfix"], }, } end else desc 'Generate a Changelog from GitHub' task :changelog do raise <= Gem::Version.new('2.2.2')" + version: '~> 1.15' + condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')" EOM end end diff --git a/metadata.json b/metadata.json index 4ec345b..d4db6c0 100644 --- a/metadata.json +++ b/metadata.json @@ -1,44 +1,44 @@ { "name": "stm-debconf", "version": "3.2.0", "author": "stm", "summary": "Manage debconf database items on Debian based systems.", "license": "BSD-2-Clause", "source": "https://github.com/smoeding/puppet-debconf", "project_page": "https://github.com/smoeding/puppet-debconf", "issues_url": "https://github.com/smoeding/puppet-debconf/issues", "dependencies": [ ], "operatingsystem_support": [ { "operatingsystem": "Debian", "operatingsystemrelease": [ "8", "9", "10" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "14.04", "16.04", "18.04", "20.04" ] } ], "requirements": [ { "name": "puppet", "version_requirement": ">= 5.0.0 < 7.0.0" } ], "tags": [ "debconf" ], - "pdk-version": "1.18.0", - "template-url": "https://github.com/puppetlabs/pdk-templates#master", - "template-ref": "heads/master-0-g9c14433" + "pdk-version": "1.18.1", + "template-url": "pdk-default#1.18.1", + "template-ref": "tags/1.18.1-0-g3d2e75c" } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d3778ca..b367fde 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,57 +1,61 @@ # frozen_string_literal: true +RSpec.configure do |c| + c.mock_with :rspec +end + require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) include RspecPuppetFacts default_facts = { puppetversion: Puppet.version, facterversion: Facter.version, } default_fact_files = [ File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')), File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')), ] default_fact_files.each do |f| next unless File.exist?(f) && File.readable?(f) && File.size?(f) begin default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) rescue => e RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" end end # read default_facts and merge them over what is provided by facterdb default_facts.each do |fact, value| add_custom_fact fact, value end RSpec.configure do |c| c.default_facts = default_facts c.before :each do # set to strictest setting for testing # by default Puppet runs at warning level Puppet.settings[:strict] = :warning Puppet.settings[:strict_variables] = true end c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] c.after(:suite) do end end # Ensures that a module is defined # @param module_name Name of the module def ensure_module_defined(module_name) module_name.split('::').reduce(Object) do |last_module, next_module| last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false) last_module.const_get(next_module, false) end end # 'spec_overrides' from sync.yml will appear below this line diff --git a/spec/unit/provider/debian_spec.rb b/spec/unit/provider/debian_spec.rb index 2b2805d..599de2b 100644 --- a/spec/unit/provider/debian_spec.rb +++ b/spec/unit/provider/debian_spec.rb @@ -1,25 +1,25 @@ require 'spec_helper' provider_class = Puppet::Type.type(:debconf).provider(:debian) describe provider_class do let(:name) { 'foo' } let(:resource) do Puppet::Type.type(:debconf).new( name: name, provider: 'debian', ) end let(:provider) do provider = provider_class.new provider.resource = resource provider end it 'is the default provider on :osfamily => Debian' do - Facter.expects(:value).with(:osfamily).returns('Debian') + expect(Facter.fact(:osfamily)).to receive(:value).and_return('Debian') expect(described_class).to be_default end end diff --git a/spec/unit/type/debconf_spec.rb b/spec/unit/type/debconf_spec.rb index 7a3928d..f090237 100644 --- a/spec/unit/type/debconf_spec.rb +++ b/spec/unit/type/debconf_spec.rb @@ -1,33 +1,30 @@ require 'spec_helper' describe Puppet::Type.type(:debconf) do - on_supported_os.each do |os, facts| + on_supported_os.each do |os, _facts| context "on #{os}" do before(:each) do Facter.clear - facts.each do |k, v| - Facter.stubs(:fact).with(k).returns Facter.add(k) { setcode { v } } - end end describe 'when validating attributes' do [:item, :package, :type].each do |param| it "has a #{param} parameter" do expect(described_class.attrtype(param)).to eq(:param) end end [:value].each do |prop| it "has a #{prop} property" do expect(described_class.attrtype(prop)).to eq(:property) end end end describe 'namevar validation' do it 'has :item as its namevar' do expect(described_class.key_attributes).to eq([:item]) end end end end end