summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-08-12 13:31:57 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-08-13 09:26:44 -0700
commitfec18c1696afc12a9fae3adbb5d872548c5b8254 (patch)
tree786222d8f75187a4997a4f4cae59e0a6a8f3dcc6
parentfeb9b40490dc285d4f9cfb551ed12a0856301351 (diff)
downloadchef-fec18c1696afc12a9fae3adbb5d872548c5b8254.tar.gz
add JSONCompat test for parsing JSON comments
-rw-r--r--spec/unit/json_compat_spec.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/spec/unit/json_compat_spec.rb b/spec/unit/json_compat_spec.rb
index 6d262734fd..e355a47faa 100644
--- a/spec/unit/json_compat_spec.rb
+++ b/spec/unit/json_compat_spec.rb
@@ -21,7 +21,7 @@ require 'chef/json_compat'
describe Chef::JSONCompat do
- describe "with JSON containing an existing class" do
+ describe "#from_json with JSON containing an existing class" do
let(:json) { '{"json_class": "Chef::Role"}' }
it "returns an instance of the class instead of a Hash" do
@@ -29,6 +29,22 @@ describe Chef::JSONCompat do
end
end
+ describe "#from_json with JSON containing comments" do
+ let(:json) { %Q{{\n/* comment */\n// comment 2\n"json_class": "Chef::Role"}} }
+
+ it "returns an instance of the class instead of a Hash" do
+ expect(Chef::JSONCompat.from_json(json).class).to eq Chef::Role
+ end
+ end
+
+ describe "#parse with JSON containing comments" do
+ let(:json) { %Q{{\n/* comment */\n// comment 2\n"json_class": "Chef::Role"}} }
+
+ it "returns a Hash" do
+ expect(Chef::JSONCompat.parse(json).class).to eq Hash
+ end
+ end
+
describe 'with JSON containing "Chef::Sandbox" as a json_class value' do
require 'chef/sandbox' # Only needed for this test