Removed lib/inspec/utils/latest_version.rb and associated code.

There is no reason why our tests should be failing because we deploy a
new version. That test shouldn't even be hitting the network for real.

Besides, the functionality has no place in our codebase. It's
functionality provided via `gem outdated` so why did we re-implement
it? And we expect most people to be running via omnibus, so they're
pinned to a specific version in the first place. Even if they updated,
they still couldn't run it and that would be more confusing.

Signed-off-by: Ryan Davis <zenspider@chef.io>
This commit is contained in:
Ryan Davis 2019-07-29 11:57:08 -07:00
parent 6e307797da
commit 3d6a4143a1
3 changed files with 1 additions and 24 deletions

View file

@ -385,14 +385,7 @@ class Inspec::InspecCLI < Inspec::BaseCLI
v = { version: Inspec::VERSION }
puts v.to_json
else
require "inspec/utils/latest_version"
puts Inspec::VERSION
# display outdated version
# TODO: remove this. Don't notify of update to a gem when they install omnibus
latest = LatestInSpecVersion.new.latest || Inspec::VERSION
if Gem::Version.new(Inspec::VERSION) < Gem::Version.new(latest)
puts "\nYour version of #{Inspec::Dist::PRODUCT_NAME} is out of date! The latest version is #{latest}."
end
end
end
map %w{-v --version} => :version

View file

@ -1,13 +0,0 @@
require "json"
require "open-uri"
class LatestInSpecVersion
# fetches the latest version from rubygems server
def latest
uri = URI("https://rubygems.org/api/v1/gems/inspec.json")
inspec_info = JSON.parse(uri.read(open_timeout: 1.5, read_timeout: 1.5))
inspec_info["version"]
rescue StandardError
nil
end
end

View file

@ -7,10 +7,7 @@ describe "command tests" do
it "provides the version number on stdout" do
out = inspec("version")
# Tolerate working on an out of date branch
output = out.stdout.split("\n").reject { |l| l.start_with?("Your version of InSpec is out of date!") }.join("\n") + "\n"
output.must_equal Inspec::VERSION + "\n"
out.stdout.must_equal Inspec::VERSION + "\n"
out.stderr.must_equal ""
assert_exit_code 0, out