Add shared helper method to detect if running version is prerelease

This commit is contained in:
Chris Roberts 2017-03-07 10:36:14 -08:00
parent 363476fbae
commit abf38106c0
2 changed files with 20 additions and 0 deletions

View File

@ -102,4 +102,12 @@ module Vagrant
Pathname.new(path).expand_path
end
# This returns true/false if the running version of Vagrant is
# a pre-release version (development)
#
# @return [Boolean]
def self.prerelease?
Gem::Version.new(Vagrant::VERSION).prerelease?
end
end

View File

@ -131,4 +131,16 @@ describe Vagrant do
end
end
end
describe "#prerelease?" do
it "should return true when Vagrant version is development" do
stub_const("Vagrant::VERSION", "1.0.0.dev")
expect(subject.prerelease?).to be(true)
end
it "should return false when Vagrant version is release" do
stub_const("Vagrant::VERSION", "1.0.0")
expect(subject.prerelease?).to be(false)
end
end
end