Remove VALID_FEATURES constant
This commit is contained in:
parent
accabdd7ca
commit
2783b121f9
|
@ -174,11 +174,6 @@ begin
|
|||
ui.warn(I18n.t("vagrant.general.experimental.all"), bold: true, prefix: true, channel: :error)
|
||||
else
|
||||
ui.warn(I18n.t("vagrant.general.experimental.features", features: experimental.join(", ")), bold: true, prefix: true, channel: :error)
|
||||
|
||||
diff = Vagrant::Util::Experimental.features_valid?
|
||||
if !diff.empty?
|
||||
ui.error(I18n.t("vagrant.general.experimental.unknown_features", unknown: diff.join(", ")), bold: true, prefix: true, channel: :error)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
module Vagrant
|
||||
module Util
|
||||
class Experimental
|
||||
VALID_FEATURES = []
|
||||
class << self
|
||||
|
||||
# A method for determining if the experimental flag has been enabled with
|
||||
# any features
|
||||
#
|
||||
|
@ -27,7 +25,7 @@ module Vagrant
|
|||
def global_enabled?
|
||||
if !defined?(@_global_enabled)
|
||||
experimental = features_requested
|
||||
if experimental.size == 1 && experimental.first == "1" || (experimental.size > 0 && experimental.sort == VALID_FEATURES.sort)
|
||||
if experimental.size == 1 && experimental.first == "1"
|
||||
@_global_enabled = true
|
||||
else
|
||||
@_global_enabled = false
|
||||
|
@ -45,19 +43,7 @@ module Vagrant
|
|||
experimental = features_requested
|
||||
feature = feature.to_s
|
||||
|
||||
return global_enabled? || (VALID_FEATURES.include?(feature) && experimental.include?(feature))
|
||||
end
|
||||
|
||||
# Determines if there are any unrecognized requested features
|
||||
#
|
||||
# @return [Array]
|
||||
def features_valid?
|
||||
if !defined?(@_features_diff)
|
||||
@_features_diff = []
|
||||
features = features_requested
|
||||
features.each { |f| @_features_diff << f if !VALID_FEATURES.include?(f) }
|
||||
end
|
||||
@_features_diff
|
||||
return global_enabled? || experimental.include?(feature)
|
||||
end
|
||||
|
||||
# Returns the features requested for the experimental flag
|
||||
|
|
|
@ -405,10 +405,6 @@ en:
|
|||
|
||||
Please use with caution, as some of the features may not be fully
|
||||
functional yet.
|
||||
unknown_features: |-
|
||||
Requested unknown feature flags will be ignored:
|
||||
|
||||
Unknown: %{unknown}
|
||||
not_in_installer: |-
|
||||
You appear to be running Vagrant outside of the official installers.
|
||||
Note that the installers are what ensure that Vagrant has all required
|
||||
|
|
|
@ -40,12 +40,6 @@ describe Vagrant::Util::Experimental do
|
|||
expect(subject.global_enabled?).to eq(false)
|
||||
end
|
||||
|
||||
it "returns true if enabled with a complete list of features" do
|
||||
stub_const("Vagrant::Util::Experimental::VALID_FEATURES", ["list","of","features"])
|
||||
allow(ENV).to receive(:[]).with("VAGRANT_EXPERIMENTAL").and_return("list,of,features")
|
||||
expect(subject.global_enabled?).to eq(true)
|
||||
end
|
||||
|
||||
it "returns false if disabled" do
|
||||
allow(ENV).to receive(:[]).with("VAGRANT_EXPERIMENTAL").and_return("0")
|
||||
expect(subject.global_enabled?).to eq(false)
|
||||
|
@ -58,10 +52,6 @@ describe Vagrant::Util::Experimental do
|
|||
end
|
||||
|
||||
describe "#feature_enabled?" do
|
||||
before(:each) do
|
||||
stub_const("Vagrant::Util::Experimental::VALID_FEATURES", ["secret_feature"])
|
||||
end
|
||||
|
||||
it "returns true if flag set to 1" do
|
||||
allow(ENV).to receive(:[]).with("VAGRANT_EXPERIMENTAL").and_return("1")
|
||||
expect(subject.feature_enabled?("anything")).to eq(true)
|
||||
|
@ -98,22 +88,6 @@ describe Vagrant::Util::Experimental do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#features_valid" do
|
||||
before(:each) do
|
||||
stub_const("Vagrant::Util::Experimental::VALID_FEATURES", ["cool_feature", "other_feature", "secret_feature"])
|
||||
end
|
||||
|
||||
it "returns an empty array if no diffs found" do
|
||||
allow(ENV).to receive(:[]).with("VAGRANT_EXPERIMENTAL").and_return("cool_feature,other_feature")
|
||||
expect(subject.features_valid?).to eq([])
|
||||
end
|
||||
|
||||
it "returns the invalid flag if found" do
|
||||
allow(ENV).to receive(:[]).with("VAGRANT_EXPERIMENTAL").and_return("fake_feature")
|
||||
expect(subject.features_valid?).to eq(["fake_feature"])
|
||||
end
|
||||
end
|
||||
|
||||
describe "#features_requested" do
|
||||
it "returns an array of requested features" do
|
||||
allow(ENV).to receive(:[]).with("VAGRANT_EXPERIMENTAL").and_return("secret_feature,other_secret")
|
||||
|
@ -122,10 +96,6 @@ describe Vagrant::Util::Experimental do
|
|||
end
|
||||
|
||||
describe "#guard_with" do
|
||||
before(:each) do
|
||||
stub_const("Vagrant::Util::Experimental::VALID_FEATURES", ["secret_feature"])
|
||||
end
|
||||
|
||||
it "does not execute the block if the feature is not requested" do
|
||||
allow(ENV).to receive(:[]).with("VAGRANT_EXPERIMENTAL").and_return(nil)
|
||||
expect{|b| subject.guard_with("secret_feature", &b) }.not_to yield_control
|
||||
|
|
Loading…
Reference in New Issue