diff options
author | Pete Higgins <pete@peterhiggins.org> | 2020-06-24 13:36:15 -0700 |
---|---|---|
committer | Pete Higgins <pete@peterhiggins.org> | 2020-06-24 17:47:50 -0700 |
commit | cdacf52d71a84229ee1f74b06557bfb91509d575 (patch) | |
tree | 241ace9c1cb12f3f33cf82bf71401beb52a12c23 | |
parent | b7365397f410767234619d94129757c48b8d9456 (diff) | |
download | chef-other-test-cleanup.tar.gz |
Remove other top-level methods defined in tests and do a little cleanup.other-test-cleanup
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
-rw-r--r-- | spec/unit/chef_fs/diff_spec.rb | 18 | ||||
-rw-r--r-- | spec/unit/decorator_spec.rb | 46 | ||||
-rw-r--r-- | spec/unit/provider/package/pacman_spec.rb | 37 |
3 files changed, 49 insertions, 52 deletions
diff --git a/spec/unit/chef_fs/diff_spec.rb b/spec/unit/chef_fs/diff_spec.rb index 29c25e2823..88cd6540e5 100644 --- a/spec/unit/chef_fs/diff_spec.rb +++ b/spec/unit/chef_fs/diff_spec.rb @@ -20,18 +20,18 @@ require "spec_helper" require "chef/chef_fs/file_pattern" require "chef/chef_fs/command_line" -# Removes the date stamp from the diff and replaces it with ' DATE' -# example match: "/dev/null\t2012-10-16 16:15:54.000000000 +0000" -# windows match: "--- /dev/null\tTue Oct 16 18:04:34 2012" -# https://rubular.com/r/5JdtZDqWnZhB9J -def remove_os_differences(diff) - diff = diff.gsub(/([+-]{3}.*)\t.*/, '\1 DATE') - diff.gsub(/^@@ -\d(,\d)? \+-?\d(,-?\d)? @@/, "CONTEXT_LINE_NUMBERS") -end - describe "diff", uses_diff: true do include FileSystemSupport + # Removes the date stamp from the diff and replaces it with ' DATE' + # example match: "/dev/null\t2012-10-16 16:15:54.000000000 +0000" + # windows match: "--- /dev/null\tTue Oct 16 18:04:34 2012" + # https://rubular.com/r/5JdtZDqWnZhB9J + def remove_os_differences(diff) + diff = diff.gsub(/([+-]{3}.*)\t.*/, '\1 DATE') + diff.gsub(/^@@ -\d(,\d)? \+-?\d(,-?\d)? @@/, "CONTEXT_LINE_NUMBERS") + end + context "with two filesystems with all types of difference" do let(:a) do memory_fs("a", { diff --git a/spec/unit/decorator_spec.rb b/spec/unit/decorator_spec.rb index d9527b4a0d..e88708bea7 100644 --- a/spec/unit/decorator_spec.rb +++ b/spec/unit/decorator_spec.rb @@ -18,37 +18,37 @@ require "spec_helper" -def impersonates_a(klass) - it "#is_a?(#{klass}) is true" do - expect(decorator.is_a?(klass)).to be true - end +describe Chef::Decorator do + def self.impersonates_a(klass) + it "#is_a?(#{klass}) is true" do + expect(decorator.is_a?(klass)).to be true + end - it "#is_a?(Chef::Decorator) is true" do - expect(decorator.is_a?(Chef::Decorator)).to be true - end + it "#is_a?(Chef::Decorator) is true" do + expect(decorator.is_a?(Chef::Decorator)).to be true + end - it "#kind_of?(#{klass}) is true" do - expect(decorator.is_a?(klass)).to be true - end + it "#kind_of?(#{klass}) is true" do + expect(decorator.is_a?(klass)).to be true + end - it "#kind_of?(Chef::Decorator) is true" do - expect(decorator.is_a?(Chef::Decorator)).to be true - end + it "#kind_of?(Chef::Decorator) is true" do + expect(decorator.is_a?(Chef::Decorator)).to be true + end - it "#instance_of?(#{klass}) is false" do - expect(decorator.instance_of?(klass)).to be false - end + it "#instance_of?(#{klass}) is false" do + expect(decorator.instance_of?(klass)).to be false + end - it "#instance_of?(Chef::Decorator) is true" do - expect(decorator.instance_of?(Chef::Decorator)).to be true - end + it "#instance_of?(Chef::Decorator) is true" do + expect(decorator.instance_of?(Chef::Decorator)).to be true + end - it "#class is Chef::Decorator" do - expect(decorator.class).to eql(Chef::Decorator) + it "#class is Chef::Decorator" do + expect(decorator.class).to eql(Chef::Decorator) + end end -end -describe Chef::Decorator do let(:obj) {} let(:decorator) { Chef::Decorator.new(obj) } diff --git a/spec/unit/provider/package/pacman_spec.rb b/spec/unit/provider/package/pacman_spec.rb index 2e2a3f7763..e44df52e42 100644 --- a/spec/unit/provider/package/pacman_spec.rb +++ b/spec/unit/provider/package/pacman_spec.rb @@ -17,13 +17,6 @@ # require "spec_helper" -def create_provider_for(name) - @new_resource = Chef::Resource::Package.new(name) - provider = Chef::Provider::Package::Pacman.new(@new_resource, @run_context) - allow(provider).to receive(:shell_out_compacted).and_return(@status) - provider -end - RSpec.shared_examples "current_resource" do |pkg, version, candidate| let(:current_resource) { @provider.load_current_resource } before(:each) do @@ -45,11 +38,23 @@ RSpec.shared_examples "current_resource" do |pkg, version, candidate| end describe Chef::Provider::Package::Pacman do + def create_provider_for(name) + new_resource = Chef::Resource::Package.new(name) + run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) + provider = Chef::Provider::Package::Pacman.new(new_resource, run_context) + + pacman_out = <<~PACMAN_OUT + extra nano 3.450-1 + extra emacs 0.12.0-1 [installed] + core sed 3.234-2 [installed: 3.234-1] + PACMAN_OUT + + allow(provider).to receive(:shell_out_compacted).and_return(double(stdout: pacman_out, exitstatus: 0)) + provider + end + before(:each) do - @node = Chef::Node.new - @events = Chef::EventDispatch::Dispatcher.new - @run_context = Chef::RunContext.new(@node, {}, @events) - @pacman_conf = <<~PACMAN_CONF + pacman_conf = <<~PACMAN_CONF [options] HoldPkg = pacman glibc Architecture = auto @@ -68,15 +73,7 @@ describe Chef::Provider::Package::Pacman do PACMAN_CONF allow(::File).to receive(:exist?).with("/etc/pacman.conf").and_return(true) - allow(::File).to receive(:read).with("/etc/pacman.conf").and_return(@pacman_conf) - - pacman_out = <<~PACMAN_OUT - extra nano 3.450-1 - extra emacs 0.12.0-1 [installed] - core sed 3.234-2 [installed: 3.234-1] - PACMAN_OUT - @status = double(stdout: pacman_out, exitstatus: 0) - + allow(::File).to receive(:read).with("/etc/pacman.conf").and_return(pacman_conf) end describe "loading the current resource" do |