Allow feature_enabled? to accept symbols

This commit is contained in:
Brian Cain 2018-12-07 10:50:34 -08:00
parent fc4ba7f420
commit d551738bc7
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
2 changed files with 7 additions and 0 deletions

View File

@ -26,6 +26,8 @@ module Vagrant
# @return [Boolean] - A hash containing the original array and if it is valid
def feature_enabled?(feature)
experimental = features_requested
feature = feature.to_s
if experimental.size == 1 && experimental.first == "1"
return true
elsif VALID_FEATURES.include?(feature) &&

View File

@ -44,6 +44,11 @@ describe Vagrant::Util::Experimental do
expect(subject.feature_enabled?("secret_feature")).to eq(true)
end
it "returns true if flag contains feature requested and the request is a symbol" do
allow(ENV).to receive(:[]).with("VAGRANT_EXPERIMENTAL").and_return("secret_feature")
expect(subject.feature_enabled?(:secret_feature)).to eq(true)
end
it "returns true if flag contains feature requested with other features 'enabled'" do
allow(ENV).to receive(:[]).with("VAGRANT_EXPERIMENTAL").and_return("secret_feature,other_secret")
expect(subject.feature_enabled?("secret_feature")).to eq(true)