summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlan Rabinovitch <ilan@ooyala.com>2013-11-28 10:45:40 -0800
committerBryan McLellan <btm@opscode.com>2013-12-20 10:06:45 -0800
commit543c6b4b00267d50cb044f34f50e0a8620de6cff (patch)
tree430443cfbd02a44dfb1b30afcb54557fa7ec2141
parentd676779215aaa7b45675592942d4b4ea50b7e4f7 (diff)
downloadchef-543c6b4b00267d50cb044f34f50e0a8620de6cff.tar.gz
CHEF-3531: add tests for allowing dots in data bag names or ids
-rw-r--r--spec/unit/data_bag_item_spec.rb8
-rw-r--r--spec/unit/data_bag_spec.rb6
2 files changed, 14 insertions, 0 deletions
diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb
index 6bc5954fa5..4f017ebb60 100644
--- a/spec/unit/data_bag_item_spec.rb
+++ b/spec/unit/data_bag_item_spec.rb
@@ -70,6 +70,14 @@ describe Chef::DataBagItem do
lambda { @data_bag_item.raw_data = { "id" => "h1-_" } }.should_not raise_error(ArgumentError)
end
+ it "should accept alphanum.alphanum for the id" do
+ lambda { @data_bag_item.raw_data = { "id" => "foo.bar" } }.should_not raise_error(ArgumentError)
+ end
+
+ it "should accept .alphanum for the id" do
+ lambda { @data_bag_item.raw_data = { "id" => ".bozo" } }.should_not raise_error(ArgumentError)
+ end
+
it "should raise an exception if the id contains anything but alphanum/-/_" do
lambda { @data_bag_item.raw_data = { "id" => "!@#" } }.should raise_error(ArgumentError)
end
diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb
index 9fbdc64d98..8c9465caf7 100644
--- a/spec/unit/data_bag_spec.rb
+++ b/spec/unit/data_bag_spec.rb
@@ -47,6 +47,12 @@ describe Chef::DataBag do
it "should throw an ArgumentError if you feed it anything but a string" do
lambda { @data_bag.name Hash.new }.should raise_error(ArgumentError)
end
+
+ [ ".", "-", "_", "1"].each do |char|
+ it "should allow a '#{char}' character in the data bag name" do
+ @data_bag.name("clown#{char}clown").should == "clown#{char}clown"
+ end
+ end
end
describe "deserialize" do