@@ -4,8 +4,7 @@ module Neography
4
4
class Rest
5
5
describe NodeProperties do
6
6
7
- let ( :connection ) { double }
8
- subject { NodeProperties . new ( connection ) }
7
+ subject { Neography ::Rest . new }
9
8
10
9
it "sets properties" do
11
10
options1 = {
@@ -16,61 +15,61 @@ class Rest
16
15
:body => '"qux"' ,
17
16
:headers => json_content_type
18
17
}
19
- connection . should_receive ( :put ) . with ( "/node/42/properties/foo" , options1 )
20
- connection . should_receive ( :put ) . with ( "/node/42/properties/baz" , options2 )
21
- subject . set ( "42" , { :foo => "bar" , :baz => "qux" } )
18
+ subject . connection . should_receive ( :put ) . with ( "/node/42/properties/foo" , options1 )
19
+ subject . connection . should_receive ( :put ) . with ( "/node/42/properties/baz" , options2 )
20
+ subject . set_node_properties ( "42" , { :foo => "bar" , :baz => "qux" } )
22
21
end
23
22
24
23
it "resets properties" do
25
24
options = {
26
25
:body => '{"foo":"bar"}' ,
27
26
:headers => json_content_type
28
27
}
29
- connection . should_receive ( :put ) . with ( "/node/42/properties" , options )
30
- subject . reset ( "42" , { :foo => "bar" } )
28
+ subject . connection . should_receive ( :put ) . with ( "/node/42/properties" , options )
29
+ subject . reset_node_properties ( "42" , { :foo => "bar" } )
31
30
end
32
31
33
32
context "getting properties" do
34
33
35
34
it "gets all properties" do
36
- connection . should_receive ( :get ) . with ( "/node/42/properties" )
37
- subject . get ( "42" )
35
+ subject . connection . should_receive ( :get ) . with ( "/node/42/properties" )
36
+ subject . get_node_properties ( "42" )
38
37
end
39
38
40
39
it "gets multiple properties" do
41
- connection . should_receive ( :get ) . with ( "/node/42/properties/foo" )
42
- connection . should_receive ( :get ) . with ( "/node/42/properties/bar" )
43
- subject . get ( "42" , "foo" , "bar" )
40
+ subject . connection . should_receive ( :get ) . with ( "/node/42/properties/foo" )
41
+ subject . connection . should_receive ( :get ) . with ( "/node/42/properties/bar" )
42
+ subject . get_node_properties ( "42" , "foo" , "bar" )
44
43
end
45
44
46
45
it "returns multiple properties as a hash" do
47
- connection . stub ( :get ) . and_return ( "baz" , "qux" )
48
- subject . get ( "42" , "foo" , "bar" ) . should == { "foo" => "baz" , "bar" => "qux" }
46
+ subject . connection . stub ( :get ) . and_return ( "baz" , "qux" )
47
+ subject . get_node_properties ( "42" , "foo" , "bar" ) . should == { "foo" => "baz" , "bar" => "qux" }
49
48
end
50
49
51
50
it "returns nil if no properties were found" do
52
- connection . stub ( :get ) . and_return ( nil , nil )
53
- subject . get ( "42" , "foo" , "bar" ) . should be_nil
51
+ subject . connection . stub ( :get ) . and_return ( nil , nil )
52
+ subject . get_node_properties ( "42" , "foo" , "bar" ) . should be_nil
54
53
end
55
54
56
55
it "returns hash without nil return values" do
57
- connection . stub ( :get ) . and_return ( "baz" , nil )
58
- subject . get ( "42" , "foo" , "bar" ) . should == { "foo" => "baz" }
56
+ subject . connection . stub ( :get ) . and_return ( "baz" , nil )
57
+ subject . get_node_properties ( "42" , "foo" , "bar" ) . should == { "foo" => "baz" }
59
58
end
60
59
61
60
end
62
61
63
62
context "removing properties" do
64
63
65
64
it "removes all properties" do
66
- connection . should_receive ( :delete ) . with ( "/node/42/properties" )
67
- subject . remove ( "42" )
65
+ subject . connection . should_receive ( :delete ) . with ( "/node/42/properties" )
66
+ subject . remove_node_properties ( "42" )
68
67
end
69
68
70
69
it "removes multiple properties" do
71
- connection . should_receive ( :delete ) . with ( "/node/42/properties/foo" )
72
- connection . should_receive ( :delete ) . with ( "/node/42/properties/bar" )
73
- subject . remove ( "42" , "foo" , "bar" )
70
+ subject . connection . should_receive ( :delete ) . with ( "/node/42/properties/foo" )
71
+ subject . connection . should_receive ( :delete ) . with ( "/node/42/properties/bar" )
72
+ subject . remove_node_properties ( "42" , "foo" , "bar" )
74
73
end
75
74
76
75
end
0 commit comments