diff --git a/.gitignore b/.gitignore index 5e135f2..e9b3cf4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,20 @@ pkg/ Gemfile.lock Gemfile.local vendor/ .vendor/ spec/fixtures/manifests/ spec/fixtures/modules/ .vagrant/ .bundle/ .ruby-version coverage/ log/ .idea/ .dependencies/ .librarian/ Puppetfile.lock *.iml .*.sw? .yardoc/ Guardfile -spec/fixtures/tmpdir/ diff --git a/.sync.yml b/.sync.yml index 0644836..835ef80 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,8 +1,3 @@ --- .travis.yml: secure: "IkrfAnec7ovZLMvhvXt8ZihyYdAJTC/nm7KDm4u2G/uD2NGaMdHNOAenkwIwC1vfCzHKcgC5u/lAYFrYvHpQpJW0kHLKnk1SpndfWX9kd5SlDDzEP5mJGjMZeTY6H9sV5fsB6Pt7l/sw5ACL/0bFDl0mYBnVhGv6UxZZ5xMQIUw=" -spec/spec_helper.rb: - spec_overrides: "require 'spec_helper_methods'" -.gitignore: - paths: - - spec/fixtures/tmpdir/ diff --git a/spec/functions/extlib/cache_data_spec.rb b/spec/functions/extlib/cache_data_spec.rb index c475263..ca504b7 100644 --- a/spec/functions/extlib/cache_data_spec.rb +++ b/spec/functions/extlib/cache_data_spec.rb @@ -1,40 +1,28 @@ require 'spec_helper' describe 'extlib::cache_data' do let(:initial_data) { 'original_password' } let(:data_name) { 'mysql_password' } let(:namespace) { 'data_cache' } - let(:vardir) { "#{FIXTURES_PATH}/tmpdir" } it { expect(subject).not_to eq(nil) } it { is_expected.not_to eq(nil) } it { is_expected.to run.with_params(data_name).and_raise_error(ArgumentError) } it { is_expected.to run.with_params('', initial_data).and_raise_error(ArgumentError) } it { is_expected.to run.with_params('', 'mysql_password', initial_data).and_raise_error(ArgumentError) } describe 'data caching' do - before do - # Fool rspec-puppet into creating a consistent vardir for these tests! - allow(Dir).to receive(:mktmpdir).and_return("#{FIXTURES_PATH}/tmpdir") - # Stop rspec-puppet from blowing away the vardir between each example. Is unstubbed in the after block. - allow(FileUtils).to receive(:rm_rf).with(vardir).and_return(true) - end - after do - # Since rspec-puppet won't be removing the vardir, we'd better do that ourselves. - FileUtils.rm_rf(vardir) if File.directory?(vardir) - end - context 'when not in cache' do it 'returns supplied data' do is_expected.to run.with_params(namespace, data_name, initial_data).and_return(initial_data) end end context 'when cached' do it 'returns cached data' do is_expected.to run.with_params(namespace, data_name, initial_data).and_return(initial_data) is_expected.to run.with_params(namespace, data_name, 'new_password').and_return(initial_data) end end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 927af0c..b2b2704 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,20 +1,18 @@ # This file is managed via modulesync # https://github.com/voxpupuli/modulesync # https://github.com/voxpupuli/modulesync_config # puppetlabs_spec_helper will set up coverage if the env variable is set. # We want to do this if lib exists and it hasn't been explicitly set. ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__)) require 'voxpupuli/test/spec_helper' if File.exist?(File.join(__dir__, 'default_module_facts.yml')) facts = YAML.load(File.read(File.join(__dir__, 'default_module_facts.yml'))) if facts facts.each do |name, value| add_custom_fact name.to_sym, value end end end - -require 'spec_helper_methods' diff --git a/spec/spec_helper_methods.rb b/spec/spec_helper_methods.rb deleted file mode 100644 index f9724d4..0000000 --- a/spec/spec_helper_methods.rb +++ /dev/null @@ -1,5 +0,0 @@ -# From https://gist.github.com/stefanozanella/4190920 -# Make stdlib (i.e. its functions) available to rspec so our own functions that -# require stdlib functions can load them. -$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'fixtures', 'modules', 'stdlib', 'lib') -FIXTURES_PATH = File.expand_path(File.join(__FILE__, '..', 'fixtures'))