summaryrefslogtreecommitdiff
path: root/spec/unit/json_compat_spec.rb
diff options
context:
space:
mode:
authorChristopher Maier <cm@opscode.com>2012-11-28 16:57:00 -0500
committerChristopher Maier <cm@opscode.com>2012-11-28 16:58:15 -0500
commitea3678bdbde7465927bc23f897b6fc9e16d8640a (patch)
tree61104d36efa87d6ceb20b65ff66b24b54206ba9c /spec/unit/json_compat_spec.rb
parenta91543fab1581d2519df9a0c9023c7465ace05f2 (diff)
downloadchef-ea3678bdbde7465927bc23f897b6fc9e16d8640a.tar.gz
Add test to verify "auto-inflation" of JSON into Ruby classes
Diffstat (limited to 'spec/unit/json_compat_spec.rb')
-rw-r--r--spec/unit/json_compat_spec.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/unit/json_compat_spec.rb b/spec/unit/json_compat_spec.rb
index aa688c0791..674e2ae17a 100644
--- a/spec/unit/json_compat_spec.rb
+++ b/spec/unit/json_compat_spec.rb
@@ -20,6 +20,14 @@ require File.expand_path('../../spec_helper', __FILE__)
require 'chef/json_compat'
describe Chef::JSONCompat do
+
+ describe "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
+ Chef::JSONCompat.from_json(json).class.should eq Chef::Role
+ end
+ end
+
describe "with a file with 1000 or less nested entries" do
before(:all) do
@json = IO.read(File.join(CHEF_SPEC_DATA, 'big_json.json'))