-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
93 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
require 'spec_helper' | ||
|
||
module Neography | ||
class Rest | ||
describe NodeProperties do | ||
|
||
let(:connection) { stub } | ||
subject { NodeProperties.new(connection) } | ||
|
||
it "sets properties" do | ||
options1 = { | ||
:body => '"bar"', | ||
:headers => json_content_type | ||
} | ||
options2 = { | ||
:body => '"qux"', | ||
:headers => json_content_type | ||
} | ||
connection.should_receive(:put).with("/node/42/properties/foo", options1) | ||
connection.should_receive(:put).with("/node/42/properties/baz", options2) | ||
subject.set("42", {:foo => "bar", :baz => "qux"}) | ||
end | ||
|
||
it "resets properties" do | ||
options = { | ||
:body => '{"foo":"bar"}', | ||
:headers => json_content_type | ||
} | ||
connection.should_receive(:put).with("/node/42/properties", options) | ||
subject.reset("42", {:foo => "bar"}) | ||
end | ||
|
||
context "getting properties" do | ||
|
||
it "gets all properties" do | ||
connection.should_receive(:get).with("/node/42/properties") | ||
subject.get("42") | ||
end | ||
|
||
it "gets multiple properties" do | ||
connection.should_receive(:get).with("/node/42/properties/foo") | ||
connection.should_receive(:get).with("/node/42/properties/bar") | ||
subject.get("42", "foo", "bar") | ||
end | ||
|
||
it "returns multiple properties as a hash" do | ||
connection.stub(:get).and_return("baz", "qux") | ||
subject.get("42", "foo", "bar").should == { "foo" => "baz", "bar" => "qux" } | ||
end | ||
|
||
it "returns nil if no properties were found" do | ||
connection.stub(:get).and_return(nil, nil) | ||
subject.get("42", "foo", "bar").should be_nil | ||
end | ||
|
||
it "returns hash without nil return values" do | ||
connection.stub(:get).and_return("baz", nil) | ||
subject.get("42", "foo", "bar").should == { "foo" => "baz" } | ||
end | ||
|
||
end | ||
|
||
context "removing properties" do | ||
|
||
it "removes all properties" do | ||
connection.should_receive(:delete).with("/node/42/properties") | ||
subject.remove("42") | ||
end | ||
|
||
it "removes multiple properties" do | ||
connection.should_receive(:delete).with("/node/42/properties/foo") | ||
connection.should_receive(:delete).with("/node/42/properties/bar") | ||
subject.remove("42", "foo", "bar") | ||
end | ||
|
||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,12 +183,6 @@ class Rest | |
|
||
end | ||
|
||
private | ||
|
||
def json_content_type | ||
{"Content-Type"=>"application/json"} | ||
end | ||
|
||
end | ||
end | ||
end |