summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2021-07-26 16:39:41 -0700
committerGitHub <noreply@github.com>2021-07-26 16:39:41 -0700
commit77aeaf8d19cd983c6f676e399b28dc868b9c03cb (patch)
tree643ad5697aeb8ffa8db94ca31bcd33520e39895d
parent50cf38b76e326924f6c03425f2bb201d9f3a4bc7 (diff)
parent5ccb409740a064bb55b2ce80eb099c16fce8a4bf (diff)
downloadchef-77aeaf8d19cd983c6f676e399b28dc868b9c03cb.tar.gz
Merge pull request #11842 from byplayer/homebrew_cask_name_issue
Support '-' and '@' for homebrew cask name
-rw-r--r--lib/chef/resource/homebrew_cask.rb2
-rw-r--r--spec/unit/resource/homebrew_cask_spec.rb40
2 files changed, 30 insertions, 12 deletions
diff --git a/lib/chef/resource/homebrew_cask.rb b/lib/chef/resource/homebrew_cask.rb
index 7a862e8638..9bc187b712 100644
--- a/lib/chef/resource/homebrew_cask.rb
+++ b/lib/chef/resource/homebrew_cask.rb
@@ -34,7 +34,7 @@ class Chef
property :cask_name, String,
description: "An optional property to set the cask name if it differs from the resource block's name.",
- regex: %r{^[\w/-]+$},
+ regex: %r{^[\w/\-@]+$},
validation_message: "The provided Homebrew cask name is not valid. Cask names can contain alphanumeric characters, _, -, or / only!",
name_property: true
diff --git a/spec/unit/resource/homebrew_cask_spec.rb b/spec/unit/resource/homebrew_cask_spec.rb
index ed68bc613f..0d2a774754 100644
--- a/spec/unit/resource/homebrew_cask_spec.rb
+++ b/spec/unit/resource/homebrew_cask_spec.rb
@@ -19,22 +19,40 @@ require "spec_helper"
describe Chef::Resource::HomebrewCask do
- let(:resource) { Chef::Resource::HomebrewCask.new("fakey_fakerton") }
+ context 'name with under bar' do
+ let(:resource) { Chef::Resource::HomebrewCask.new("fakey_fakerton") }
- it "has a resource name of :homebrew_cask" do
- expect(resource.resource_name).to eql(:homebrew_cask)
- end
+ it "has a resource name of :homebrew_cask" do
+ expect(resource.resource_name).to eql(:homebrew_cask)
+ end
+
+ it "the cask_name property is the name_property" do
+ expect(resource.cask_name).to eql("fakey_fakerton")
+ end
+
+ it "sets the default action as :install" do
+ expect(resource.action).to eql([:install])
+ end
- it "the cask_name property is the name_property" do
- expect(resource.cask_name).to eql("fakey_fakerton")
+ it "supports :install, :remove actions" do
+ expect { resource.action :install }.not_to raise_error
+ expect { resource.action :remove }.not_to raise_error
+ end
end
- it "sets the default action as :install" do
- expect(resource.action).to eql([:install])
+ context 'name with high fun' do
+ let(:resource) { Chef::Resource::HomebrewCask.new("fakey-fakerton") }
+
+ it "the cask_name property is the name_property" do
+ expect(resource.cask_name).to eql("fakey-fakerton")
+ end
end
- it "supports :install, :remove actions" do
- expect { resource.action :install }.not_to raise_error
- expect { resource.action :remove }.not_to raise_error
+ context 'name with at mark' do
+ let(:resource) { Chef::Resource::HomebrewCask.new("fakey-fakerton@10") }
+
+ it "the cask_name property is the name_property" do
+ expect(resource.cask_name).to eql("fakey-fakerton@10")
+ end
end
end