From feb9b40490dc285d4f9cfb551ed12a0856301351 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Tue, 12 Aug 2014 13:27:59 -0700 Subject: adding some comments to fixtures --- spec/data/object_loader/environments/test.json | 2 ++ spec/data/object_loader/environments/test_json_class.json | 2 ++ spec/data/object_loader/nodes/test.json | 2 ++ spec/data/object_loader/nodes/test_json_class.json | 2 ++ spec/data/object_loader/roles/test.json | 2 ++ spec/data/object_loader/roles/test_json_class.json | 2 ++ 6 files changed, 12 insertions(+) diff --git a/spec/data/object_loader/environments/test.json b/spec/data/object_loader/environments/test.json index cb4c790e44..f879552d1f 100644 --- a/spec/data/object_loader/environments/test.json +++ b/spec/data/object_loader/environments/test.json @@ -1,4 +1,6 @@ { + /* thing that we support c-style comments */ + // testing that we support c++-style comments as well "name": "test", "description": "prod", "run_list": [] diff --git a/spec/data/object_loader/environments/test_json_class.json b/spec/data/object_loader/environments/test_json_class.json index 28345198c9..e9156b8dbe 100644 --- a/spec/data/object_loader/environments/test_json_class.json +++ b/spec/data/object_loader/environments/test_json_class.json @@ -1,4 +1,6 @@ { + /* thing that we support c-style comments */ + // testing that we support c++-style comments as well "name": "test", "json_class": "Chef::Environment", "description": "prod", diff --git a/spec/data/object_loader/nodes/test.json b/spec/data/object_loader/nodes/test.json index 49f297d039..70aa8927c6 100644 --- a/spec/data/object_loader/nodes/test.json +++ b/spec/data/object_loader/nodes/test.json @@ -1,4 +1,6 @@ { + /* thing that we support c-style comments */ + // testing that we support c++-style comments as well "name": "test", "environment": "prod", "run_list": [] diff --git a/spec/data/object_loader/nodes/test_json_class.json b/spec/data/object_loader/nodes/test_json_class.json index f485ae8748..55002b47e0 100644 --- a/spec/data/object_loader/nodes/test_json_class.json +++ b/spec/data/object_loader/nodes/test_json_class.json @@ -1,4 +1,6 @@ { + /* thing that we support c-style comments */ + // testing that we support c++-style comments as well "name": "test", "json_class": "Chef::Node", "environment": "prod", diff --git a/spec/data/object_loader/roles/test.json b/spec/data/object_loader/roles/test.json index cb4c790e44..f879552d1f 100644 --- a/spec/data/object_loader/roles/test.json +++ b/spec/data/object_loader/roles/test.json @@ -1,4 +1,6 @@ { + /* thing that we support c-style comments */ + // testing that we support c++-style comments as well "name": "test", "description": "prod", "run_list": [] diff --git a/spec/data/object_loader/roles/test_json_class.json b/spec/data/object_loader/roles/test_json_class.json index ce922f592d..fa72d78c95 100644 --- a/spec/data/object_loader/roles/test_json_class.json +++ b/spec/data/object_loader/roles/test_json_class.json @@ -1,4 +1,6 @@ { + /* thing that we support c-style comments */ + // testing that we support c++-style comments as well "name": "test", "json_class": "Chef::Role", "description": "prod", -- cgit v1.2.1 From fec18c1696afc12a9fae3adbb5d872548c5b8254 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Tue, 12 Aug 2014 13:31:57 -0700 Subject: add JSONCompat test for parsing JSON comments --- spec/unit/json_compat_spec.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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 -- cgit v1.2.1 From c33e9c16655b5fb18e71bfcee5c32edc29856f78 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Tue, 12 Aug 2014 13:54:25 -0700 Subject: fix typo in comment --- spec/data/object_loader/environments/test.json | 2 +- spec/data/object_loader/environments/test_json_class.json | 2 +- spec/data/object_loader/nodes/test.json | 2 +- spec/data/object_loader/nodes/test_json_class.json | 2 +- spec/data/object_loader/roles/test.json | 2 +- spec/data/object_loader/roles/test_json_class.json | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/data/object_loader/environments/test.json b/spec/data/object_loader/environments/test.json index f879552d1f..744819c60a 100644 --- a/spec/data/object_loader/environments/test.json +++ b/spec/data/object_loader/environments/test.json @@ -1,5 +1,5 @@ { - /* thing that we support c-style comments */ + /* testing that we support c-style comments */ // testing that we support c++-style comments as well "name": "test", "description": "prod", diff --git a/spec/data/object_loader/environments/test_json_class.json b/spec/data/object_loader/environments/test_json_class.json index e9156b8dbe..f51943f60e 100644 --- a/spec/data/object_loader/environments/test_json_class.json +++ b/spec/data/object_loader/environments/test_json_class.json @@ -1,5 +1,5 @@ { - /* thing that we support c-style comments */ + /* testing that we support c-style comments */ // testing that we support c++-style comments as well "name": "test", "json_class": "Chef::Environment", diff --git a/spec/data/object_loader/nodes/test.json b/spec/data/object_loader/nodes/test.json index 70aa8927c6..a370d6378d 100644 --- a/spec/data/object_loader/nodes/test.json +++ b/spec/data/object_loader/nodes/test.json @@ -1,5 +1,5 @@ { - /* thing that we support c-style comments */ + /* testing that we support c-style comments */ // testing that we support c++-style comments as well "name": "test", "environment": "prod", diff --git a/spec/data/object_loader/nodes/test_json_class.json b/spec/data/object_loader/nodes/test_json_class.json index 55002b47e0..3c5b12ce6c 100644 --- a/spec/data/object_loader/nodes/test_json_class.json +++ b/spec/data/object_loader/nodes/test_json_class.json @@ -1,5 +1,5 @@ { - /* thing that we support c-style comments */ + /* testing that we support c-style comments */ // testing that we support c++-style comments as well "name": "test", "json_class": "Chef::Node", diff --git a/spec/data/object_loader/roles/test.json b/spec/data/object_loader/roles/test.json index f879552d1f..744819c60a 100644 --- a/spec/data/object_loader/roles/test.json +++ b/spec/data/object_loader/roles/test.json @@ -1,5 +1,5 @@ { - /* thing that we support c-style comments */ + /* testing that we support c-style comments */ // testing that we support c++-style comments as well "name": "test", "description": "prod", diff --git a/spec/data/object_loader/roles/test_json_class.json b/spec/data/object_loader/roles/test_json_class.json index fa72d78c95..f975c8be43 100644 --- a/spec/data/object_loader/roles/test_json_class.json +++ b/spec/data/object_loader/roles/test_json_class.json @@ -1,5 +1,5 @@ { - /* thing that we support c-style comments */ + /* testing that we support c-style comments */ // testing that we support c++-style comments as well "name": "test", "json_class": "Chef::Role", -- cgit v1.2.1