From 7d5642cc9e3b0ab3bbfcf6e1fc0fe234ac59fbfc Mon Sep 17 00:00:00 2001 From: Pete Higgins Date: Fri, 13 Mar 2020 12:56:44 -0700 Subject: Move clear_sources? helper from resource to provider. Signed-off-by: Pete Higgins --- spec/unit/provider/package/rubygems_spec.rb | 45 +++++++++++++++++++++++++++++ spec/unit/resource/gem_package_spec.rb | 38 ------------------------ 2 files changed, 45 insertions(+), 38 deletions(-) (limited to 'spec') diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb index 1ef76c05c3..295e5f9bf9 100644 --- a/spec/unit/provider/package/rubygems_spec.rb +++ b/spec/unit/provider/package/rubygems_spec.rb @@ -992,3 +992,48 @@ describe Chef::Provider::Package::Rubygems do end end end + +describe Chef::Provider::Package::Rubygems, "clear_sources?" do + let(:new_resource) do + Chef::Resource::GemPackage.new("foo") + end + + let(:provider) do + run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new) + Chef::Provider::Package::Rubygems.new(new_resource, run_context) + end + + it "is false when clear_sources is unset" do + expect(provider.clear_sources?).to be false + end + + it "is false when clear_sources is set false" do + new_resource.clear_sources(false) + expect(provider.clear_sources?).to be false + end + + it "is true when clear_sources is set true" do + new_resource.clear_sources(true) + expect(provider.clear_sources?).to be true + end + + context "when a source is set" do + before do + new_resource.source("http://mirror.ops.rhcloud.com/mirror/ruby") + end + + it "is true when clear_sources is unset" do + expect(provider.clear_sources?).to be true + end + + it "is false when clear_sources is set false" do + new_resource.clear_sources(false) + expect(provider.clear_sources?).to be false + end + + it "is true when clear_sources is set true" do + new_resource.clear_sources(true) + expect(provider.clear_sources?).to be true + end + end +end diff --git a/spec/unit/resource/gem_package_spec.rb b/spec/unit/resource/gem_package_spec.rb index 5ecc2f46ca..b572fd0d40 100644 --- a/spec/unit/resource/gem_package_spec.rb +++ b/spec/unit/resource/gem_package_spec.rb @@ -65,41 +65,3 @@ describe Chef::Resource::GemPackage, "clear_sources" do expect(resource.clear_sources).to be true end end - -describe Chef::Resource::GemPackage, "clear_sources?" do - let(:resource) { Chef::Resource::GemPackage.new("foo") } - - it "is false when clear_sources is unset" do - expect(resource.clear_sources?).to be false - end - - it "is false when clear_sources is set false" do - resource.clear_sources(false) - expect(resource.clear_sources?).to be false - end - - it "is true when clear_sources is set true" do - resource.clear_sources(true) - expect(resource.clear_sources?).to be true - end - - context "when a source is set" do - before do - resource.source("http://mirror.ops.rhcloud.com/mirror/ruby") - end - - it "is true when clear_sources is unset" do - expect(resource.clear_sources?).to be true - end - - it "is false when clear_sources is set false" do - resource.clear_sources(false) - expect(resource.clear_sources?).to be false - end - - it "is true when clear_sources is set true" do - resource.clear_sources(true) - expect(resource.clear_sources?).to be true - end - end -end -- cgit v1.2.1