diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2018-08-13 10:22:57 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-13 10:22:57 -0700 |
commit | 606267f92d21cefaf5e1e7e93db06cd645eaab58 (patch) | |
tree | 5a68dd15ca58c80d930d5afb6d884013abd81d7a /spec | |
parent | 1d874bf5ef81f884b60284597753cec8de492066 (diff) | |
parent | c51c36c94f039f9da8338dd02a587c458a5f92e5 (diff) | |
download | chef-606267f92d21cefaf5e1e7e93db06cd645eaab58.tar.gz |
Merge pull request #7529 from chef/lcg/rspec-testing
Run rspec tests within a kitchen container on CentOS 7
Diffstat (limited to 'spec')
-rw-r--r-- | spec/functional/resource/mount_spec.rb | 2 | ||||
-rw-r--r-- | spec/functional/resource/yum_package_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/provider/mount/mount_spec.rb | 1 | ||||
-rw-r--r-- | spec/unit/provider/package/rubygems_spec.rb | 19 |
4 files changed, 22 insertions, 6 deletions
diff --git a/spec/functional/resource/mount_spec.rb b/spec/functional/resource/mount_spec.rb index f4e528c755..f6c7f91bcd 100644 --- a/spec/functional/resource/mount_spec.rb +++ b/spec/functional/resource/mount_spec.rb @@ -1,6 +1,6 @@ # # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>) -# Copyright:: Copyright 2013-2016, Chef Software Inc. +# Copyright:: Copyright 2013-2018, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/functional/resource/yum_package_spec.rb b/spec/functional/resource/yum_package_spec.rb index 17e4669255..3735e67cf2 100644 --- a/spec/functional/resource/yum_package_spec.rb +++ b/spec/functional/resource/yum_package_spec.rb @@ -443,11 +443,13 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$") end - it "downgrade on a local file raises an error" do + it "downgrade on a local file is ignored" do preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm") yum_package.version "1.2-1" yum_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm") - expect { yum_package.run_action(:install) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed) + yum_package.run_action(:install) + expect(yum_package.updated_by_last_action?).to be false + expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$") end it "downgrade on a local file with allow_downgrade true works" do diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb index 2af3c93fc9..2353d992d0 100644 --- a/spec/unit/provider/mount/mount_spec.rb +++ b/spec/unit/provider/mount/mount_spec.rb @@ -43,6 +43,7 @@ describe Chef::Provider::Mount::Mount do describe "when discovering the current fs state" do before do allow(@provider).to receive(:shell_out_compacted!).and_return(OpenStruct.new(stdout: "")) + allow(::File).to receive(:exist?).with("/etc/fstab").and_return(true) allow(::File).to receive(:foreach).with("/etc/fstab") end diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb index 6b33ab97f9..2e9888fb78 100644 --- a/spec/unit/provider/package/rubygems_spec.rb +++ b/spec/unit/provider/package/rubygems_spec.rb @@ -27,6 +27,19 @@ module GemspecBackcompatCreator end end +# this is a global variable we construct of the highest rspec-core version which is installed, using APIs which +# will break out of the bundle -- and done this way so that we can mock all these internal Gem APIs later... +class RspecVersionString + def self.rspec_version_string + @rspec_version_string ||= begin + stubs = Gem::Specification.send(:installed_stubs, Gem::Specification.dirs, "rspec-core-*.gemspec") + stubs.select! { |stub| stub.name == "rspec-core" && Gem::Dependency.new("rspec-core", ">= 0").requirement.satisfied_by?(stub.version) } + stubs.max_by(&:version).version.to_s + end + end +end +RspecVersionString.rspec_version_string + require "spec_helper" require "ostruct" @@ -57,7 +70,7 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do end it "determines the installed versions of gems from the source index (part2: the unmockening)" do - expected = ["rspec-core", Gem::Version.new(RSpec::Core::Version::STRING)] + expected = ["rspec-core", Gem::Version.new( RspecVersionString.rspec_version_string )] actual = @gem_env.installed_versions(Gem::Dependency.new("rspec-core", nil)).map { |spec| [spec.name, spec.version] } expect(actual).to include(expected) end @@ -247,7 +260,7 @@ describe Chef::Provider::Package::Rubygems::AlternateGemEnvironment do end skip("cant find your gem executable") if path_to_gem.empty? gem_env = Chef::Provider::Package::Rubygems::AlternateGemEnvironment.new(path_to_gem) - expected = ["rspec-core", Gem::Version.new(RSpec::Core::Version::STRING)] + expected = ["rspec-core", Gem::Version.new( RspecVersionString.rspec_version_string )] actual = gem_env.installed_versions(Gem::Dependency.new("rspec-core", nil)).map { |s| [s.name, s.version] } expect(actual).to include(expected) end @@ -400,7 +413,7 @@ describe Chef::Provider::Package::Rubygems do end describe "when new_resource version is an rspec version" do - let(:current_version) { RSpec::Core::Version::STRING } + let(:current_version) { RspecVersionString.rspec_version_string } let(:target_version) { current_version } it "triggers a gem configuration load so a later one will not stomp its config values" do |