summaryrefslogtreecommitdiff
path: root/spec/unit
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit')
-rw-r--r--spec/unit/application/solo_spec.rb2
-rw-r--r--spec/unit/data_bag_item_spec.rb7
-rw-r--r--spec/unit/node/attribute_spec.rb2
-rw-r--r--spec/unit/provider/package/rubygems_spec.rb28
4 files changed, 16 insertions, 23 deletions
diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb
index f9302a0bb2..16f4a7785b 100644
--- a/spec/unit/application/solo_spec.rb
+++ b/spec/unit/application/solo_spec.rb
@@ -108,7 +108,7 @@ describe Chef::Application::Solo do
tarfile = StringIO.new("remote_tarball_content")
target_file = StringIO.new
- expect(app).to receive(:open).with("http://junglist.gen.nz/recipes.tgz").and_yield(tarfile)
+ expect(URI).to receive(:open).with("http://junglist.gen.nz/recipes.tgz").and_yield(tarfile)
expect(File).to receive(:open).with("#{Dir.tmpdir}/chef-solo/recipes.tgz", "wb").and_yield(target_file)
archive = double(Mixlib::Archive)
diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb
index 9a12804443..61e0a80444 100644
--- a/spec/unit/data_bag_item_spec.rb
+++ b/spec/unit/data_bag_item_spec.rb
@@ -148,12 +148,7 @@ describe Chef::DataBagItem do
end
it "implements all the methods of Hash" do
- methods = %i{rehash to_hash [] fetch []= store default
- default= default_proc index size length
- empty? each_value each_key each_pair each keys values
- values_at delete delete_if reject! clear
- invert update replace merge! merge has_key? has_value?
- key? value?}
+ methods = Hash.public_instance_methods
methods.each do |m|
expect(data_bag_item).to respond_to(m)
end
diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb
index 6e78725bd9..e73d449225 100644
--- a/spec/unit/node/attribute_spec.rb
+++ b/spec/unit/node/attribute_spec.rb
@@ -898,7 +898,7 @@ describe Chef::Node::Attribute do
end
end
- describe "index" do
+ describe "index", ruby: "< 3.0.0" do
# Hash#index is deprecated and triggers warnings.
def silence
old_verbose = $VERBOSE
diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb
index 58a7eccb04..7153d6be3e 100644
--- a/spec/unit/provider/package/rubygems_spec.rb
+++ b/spec/unit/provider/package/rubygems_spec.rb
@@ -113,12 +113,11 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
end
it "finds a matching gem candidate version on rubygems 2.0.0+" do
- stub_request(:head, "https://rubygems.org/api/v1/dependencies")
-
- stub_request(:get, "https://rubygems.org/api/v1/dependencies?gems=sexp_processor")
- .to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor")))
-
- stub_request(:get, "https://rubygems.org/quick/Marshal.4.8/sexp_processor-4.15.1.gemspec.rz")
+ stub_request(:head, "https://index.rubygems.org/")
+ .to_return(status: 200, body: "", headers: {})
+ stub_request(:get, "https://index.rubygems.org/info/sexp_processor")
+ .to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor-info")))
+ stub_request(:get, "https://index.rubygems.org/quick/Marshal.4.8/sexp_processor-4.15.1.gemspec.rz")
.to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor-4.15.1.gemspec.rz")))
dep = Gem::Dependency.new("sexp_processor", ">= 0")
@@ -126,21 +125,20 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
end
it "gives the candidate version as nil if none is found" do
- stub_request(:head, "https://rubygems.org/api/v1/dependencies")
-
- stub_request(:get, "https://rubygems.org/api/v1/dependencies?gems=nonexistent_gem")
- .to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "nonexistent_gem")))
+ stub_request(:head, "https://index.rubygems.org/")
+ .to_return(status: 200, body: "", headers: {})
+ stub_request(:get, "https://index.rubygems.org/info/nonexistent_gem")
+ .to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "nonexistent_gem-info")))
dep = Gem::Dependency.new("nonexistent_gem", ">= 0")
expect(@gem_env.candidate_version_from_remote(dep)).to be_nil
end
it "finds a matching gem from a specific gemserver when explicit sources are given (to a server that doesn't respond to api requests)" do
- stub_request(:head, "https://rubygems2.org/api/v1/dependencies")
-
- stub_request(:get, "https://rubygems2.org/api/v1/dependencies?gems=sexp_processor")
- .to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor")))
-
+ stub_request(:head, "https://rubygems2.org/")
+ .to_return(status: 200, body: "", headers: {})
+ stub_request(:get, "https://rubygems2.org/info/sexp_processor")
+ .to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor-info")))
stub_request(:get, "https://rubygems2.org/quick/Marshal.4.8/sexp_processor-4.15.1.gemspec.rz")
.to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor-4.15.1.gemspec.rz")))