summaryrefslogtreecommitdiff
path: root/spec/unit/node_spec.rb
diff options
context:
space:
mode:
authorAdam Jacob <adam@hjksolutions.com>2008-05-19 01:44:05 -0700
committerAdam Jacob <adam@hjksolutions.com>2008-05-19 01:44:05 -0700
commit4ce7356d6d08cf02dde23b6e2fe2066a26ec45b2 (patch)
tree9e9953b6240efe270603a19151d91c9c8a0508dc /spec/unit/node_spec.rb
parenta125c8a450c4368bfdb1668679dd7153d53757c6 (diff)
downloadchef-4ce7356d6d08cf02dde23b6e2fe2066a26ec45b2.tar.gz
Working on network layer
Diffstat (limited to 'spec/unit/node_spec.rb')
-rw-r--r--spec/unit/node_spec.rb25
1 files changed, 17 insertions, 8 deletions
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 0ea4d864d4..753d056404 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -153,14 +153,23 @@ describe Chef::Node do
it "should serialize itself as json" do
node = Chef::Node.find("test.example.com")
- json = node.to_json
- result = JSON.load(json)
- result["name"].should == "test.example.com"
- result["type"].should == "Chef::Node"
- result["attributes"]["something"].should == "else"
- result["attributes"]["sunshine"].should == "in"
- result["recipes"].detect { |r| r == "operations-master" }.should == "operations-master"
- result["recipes"].detect { |r| r == "operations-monitoring" }.should == "operations-monitoring"
+ json = node.to_json()
+ json.should =~ /json_class/
+ json.should =~ /name/
+ json.should =~ /attributes/
+ json.should =~ /recipes/
+ end
+
+ it "should deserialize itself from json" do
+ original_node = Chef::Node.find("test.example.com")
+ json = original_node.to_json
+ serialized_node = JSON.parse(json)
+ serialized_node.should be_a_kind_of(Chef::Node)
+ serialized_node.name.should eql(original_node.name)
+ original_node.each_attribute do |k,v|
+ serialized_node[k].should eql(v)
+ end
+ serialized_node.recipes.should eql(original_node.recipes)
end
it "should return a list of node names based on which files are in the node_path" do