From 78766b19c241795538836c85ef7b579ed4e3ab03 Mon Sep 17 00:00:00 2001 From: Max De Marzi Date: Tue, 10 Jan 2012 10:08:30 -0600 Subject: [PATCH] discarding nil values, closes #23 --- lib/neography/rest.rb | 2 +- spec/integration/rest_node_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/neography/rest.rb b/lib/neography/rest.rb index b6e8cc5..3242ec4 100644 --- a/lib/neography/rest.rb +++ b/lib/neography/rest.rb @@ -59,7 +59,7 @@ def get_root def create_node(*args) if args[0].respond_to?(:each_pair) && args[0] - options = { :body => args[0].to_json, :headers => {'Content-Type' => 'application/json'} } + options = { :body => args[0].delete_if { |k, v| v.nil? }.to_json, :headers => {'Content-Type' => 'application/json'} } post("/node", options) else post("/node") diff --git a/spec/integration/rest_node_spec.rb b/spec/integration/rest_node_spec.rb index 49caadf..a338ba3 100644 --- a/spec/integration/rest_node_spec.rb +++ b/spec/integration/rest_node_spec.rb @@ -24,6 +24,13 @@ new_node["data"]["name"].should == "Max" end + it "can create a node with nil properties" do + new_node = @neo.create_node("name" => "Max", "age" => nil ) + new_node["data"]["name"].should == "Max" + new_node["data"]["age"].should be_nil + end + + it "can create a node with more than one property" do new_node = @neo.create_node("age" => 31, "name" => "Max") new_node["data"]["name"].should == "Max"