require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'rid/document' describe "Document" do before do @doc = Rid::Document.new @hash = {} end describe "read!" do end describe "to_json" do it "should convert key-value pair" do @doc.hash = { "key" => "value" } @doc.to_json.should == '{"key":"value"}' end it "should convert nested hash" do @doc.hash = { "hash" => { "key" => "value" } } @doc.to_json.should == '{"hash":{"key":"value"}}' end end describe "json=" do it "should read key-value pair" do @doc.json = '{"key":"value"}' @doc.hash.should == { "key" => "value" } end it "should read nested hash" do @doc.json = '{"hash":{"key":"value"}}' @doc.hash.should == { "hash" => { "key" => "value" } } end end end