From 27458aff988aac083007a677793081568356d85d Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Tue, 5 Apr 2016 14:32:06 +0100 Subject: (maint) Update to current modulesync_configs [953280c] This removes much of the assorted cruft that accumulated in the unmanaged files and moves the remaining necessary parts to spec_helper_local. --- spec/puppetlabs_spec_helper_clone.rb | 34 ------------------------ spec/spec.opts | 6 ----- spec/spec_helper.rb | 51 ++++-------------------------------- spec/spec_helper_local.rb | 29 ++++++++++++++++++++ 4 files changed, 34 insertions(+), 86 deletions(-) delete mode 100644 spec/puppetlabs_spec_helper_clone.rb delete mode 100644 spec/spec.opts create mode 100644 spec/spec_helper_local.rb (limited to 'spec') diff --git a/spec/puppetlabs_spec_helper_clone.rb b/spec/puppetlabs_spec_helper_clone.rb deleted file mode 100644 index 6a94a3b..0000000 --- a/spec/puppetlabs_spec_helper_clone.rb +++ /dev/null @@ -1,34 +0,0 @@ -#This file pulls in only the minimum necessary to let unmigrated specs still work - -# Define the main module namespace for use by the helper modules -module PuppetlabsSpec - # FIXTURE_DIR represents the standard locations of all fixture data. Normally - # this represents /spec/fixtures. This will be used by the fixtures - # library to find relative fixture data. - FIXTURE_DIR = File.join("spec", "fixtures") unless defined?(FIXTURE_DIR) -end - -# Require all necessary helper libraries so they can be used later -require 'puppetlabs_spec_helper/puppetlabs_spec/files' -require 'puppetlabs_spec_helper/puppetlabs_spec/fixtures' -#require 'puppetlabs_spec_helper/puppetlabs_spec/puppet_internals' -require 'puppetlabs_spec_helper/puppetlabs_spec/matchers' - -RSpec.configure do |config| - # Include PuppetlabsSpec helpers so they can be called at convenience - config.extend PuppetlabsSpec::Files - config.extend PuppetlabsSpec::Fixtures - config.include PuppetlabsSpec::Fixtures - - config.parser = 'future' if ENV['FUTURE_PARSER'] == 'yes' - config.strict_variables = true if ENV['STRICT_VARIABLES'] == 'yes' - config.stringify_facts = false if ENV['STRINGIFY_FACTS'] == 'no' - config.trusted_node_data = true if ENV['TRUSTED_NODE_DATA'] == 'yes' - config.ordering = ENV['ORDERING'] if ENV['ORDERING'] - - # This will cleanup any files that were created with tmpdir or tmpfile - config.after :each do - PuppetlabsSpec::Files.cleanup - end -end - diff --git a/spec/spec.opts b/spec/spec.opts deleted file mode 100644 index 91cd642..0000000 --- a/spec/spec.opts +++ /dev/null @@ -1,6 +0,0 @@ ---format -s ---colour ---loadby -mtime ---backtrace diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 416036b..22d5d68 100755 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,49 +1,8 @@ -#! /usr/bin/env ruby -S rspec -dir = File.expand_path(File.dirname(__FILE__)) -$LOAD_PATH.unshift File.join(dir, 'lib') - -# So everyone else doesn't have to include this base constant. -module PuppetSpec - FIXTURE_DIR = File.join(dir = File.expand_path(File.dirname(__FILE__)), "fixtures") unless defined?(FIXTURE_DIR) -end - -require 'puppet' -require 'rspec-puppet' +#This file is generated by ModuleSync, do not edit. require 'puppetlabs_spec_helper/module_spec_helper' -require 'monkey_patches/alias_should_to_must' -require 'mocha/api' -#require 'puppetlabs_spec_helper/module_spec_helper' -require 'puppetlabs_spec_helper_clone' - -# hack to enable all the expect syntax (like allow_any_instance_of) in rspec-puppet examples -RSpec::Mocks::Syntax.enable_expect(RSpec::Puppet::ManifestMatchers) - -RSpec.configure do |config| - config.module_path = File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures', 'modules') - config.manifest_dir = File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures', 'manifests') - config.environmentpath = spec_path = File.expand_path(File.join(Dir.pwd, 'spec')) - - config.add_setting :puppet_future - #config.puppet_future = (ENV['FUTURE_PARSER'] == 'yes' or Puppet.version.to_f >= 4.0) - config.puppet_future = Puppet.version.to_f >= 4.0 - - config.before :each do - # Ensure that we don't accidentally cache facts and environment between - # test cases. This requires each example group to explicitly load the - # facts being exercised with something like - # Facter.collection.loader.load(:ipaddress) - Facter.clear - Facter.clear_messages - - RSpec::Mocks.setup - end - - config.after :each do - RSpec::Mocks.verify - RSpec::Mocks.teardown - end -end -# Helper class to test handling of arguments which are derived from string -class AlsoString < String +# put local configuration and setup into spec_helper_local +begin + require 'spec_helper_local' +rescue LoadError end diff --git a/spec/spec_helper_local.rb b/spec/spec_helper_local.rb new file mode 100644 index 0000000..023a862 --- /dev/null +++ b/spec/spec_helper_local.rb @@ -0,0 +1,29 @@ + +# hack to enable all the expect syntax (like allow_any_instance_of) in rspec-puppet examples +RSpec::Mocks::Syntax.enable_expect(RSpec::Puppet::ManifestMatchers) + +RSpec.configure do |config| + # supply tests with a possibility to test for the future parser + config.add_setting :puppet_future + config.puppet_future = Puppet.version.to_f >= 4.0 + + config.before :each do + # Ensure that we don't accidentally cache facts and environment between + # test cases. This requires each example group to explicitly load the + # facts being exercised with something like + # Facter.collection.loader.load(:ipaddress) + Facter.clear + Facter.clear_messages + + RSpec::Mocks.setup + end + + config.after :each do + RSpec::Mocks.verify + RSpec::Mocks.teardown + end +end + +# Helper class to test handling of arguments which are derived from string +class AlsoString < String +end -- cgit v1.2.3 From 3860512d5611d9c3a93f75d9594c2df43ee64acb Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Tue, 5 Apr 2016 14:42:53 +0100 Subject: (maint) remove failing test This removes the failing test special casing for puppet 4. --- spec/functions/get_module_path_spec.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'spec') diff --git a/spec/functions/get_module_path_spec.rb b/spec/functions/get_module_path_spec.rb index b1f682f..a39e413 100755 --- a/spec/functions/get_module_path_spec.rb +++ b/spec/functions/get_module_path_spec.rb @@ -5,11 +5,7 @@ describe 'get_module_path' do it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) } it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) } it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) } - if Puppet.version.to_f >= 4.0 - it { is_expected.to run.with_params('one').and_raise_error(Puppet::Environments::EnvironmentNotFound, /Could not find a directory environment/) } - else - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /Could not find module/) } - end + it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /Could not find module/) } class StubModule attr_reader :path -- cgit v1.2.3