neography 1.3.14 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/lib/neography/rest.rb +29 -472
  3. data/lib/neography/rest/batch.rb +80 -87
  4. data/lib/neography/rest/clean.rb +8 -10
  5. data/lib/neography/rest/constraints.rb +15 -25
  6. data/lib/neography/rest/cypher.rb +2 -6
  7. data/lib/neography/rest/extensions.rb +4 -8
  8. data/lib/neography/rest/gremlin.rb +2 -6
  9. data/lib/neography/rest/helpers.rb +58 -0
  10. data/lib/neography/rest/node_auto_indexes.rb +54 -8
  11. data/lib/neography/rest/node_indexes.rb +92 -17
  12. data/lib/neography/rest/node_labels.rb +15 -26
  13. data/lib/neography/rest/node_paths.rb +8 -16
  14. data/lib/neography/rest/node_properties.rb +45 -4
  15. data/lib/neography/rest/node_relationships.rb +8 -17
  16. data/lib/neography/rest/node_traversal.rb +7 -63
  17. data/lib/neography/rest/nodes.rb +21 -29
  18. data/lib/neography/rest/other_node_relationships.rb +6 -13
  19. data/lib/neography/rest/relationship_auto_indexes.rb +54 -8
  20. data/lib/neography/rest/relationship_indexes.rb +104 -14
  21. data/lib/neography/rest/relationship_properties.rb +45 -4
  22. data/lib/neography/rest/relationship_types.rb +4 -11
  23. data/lib/neography/rest/relationships.rb +6 -13
  24. data/lib/neography/rest/schema_indexes.rb +8 -16
  25. data/lib/neography/rest/spatial.rb +16 -33
  26. data/lib/neography/rest/transactions.rb +25 -26
  27. data/lib/neography/tasks.rb +2 -2
  28. data/lib/neography/version.rb +1 -1
  29. data/spec/unit/rest/batch_spec.rb +49 -50
  30. data/spec/unit/rest/clean_spec.rb +3 -4
  31. data/spec/unit/rest/constraints_spec.rb +12 -13
  32. data/spec/unit/rest/cypher_spec.rb +3 -4
  33. data/spec/unit/rest/extensions_spec.rb +5 -6
  34. data/spec/unit/rest/gremlin_spec.rb +5 -6
  35. data/spec/unit/rest/helpers_spec.rb +124 -0
  36. data/spec/unit/rest/labels_spec.rb +21 -22
  37. data/spec/unit/rest/node_auto_indexes_spec.rb +23 -24
  38. data/spec/unit/rest/node_indexes_spec.rb +42 -43
  39. data/spec/unit/rest/node_paths_spec.rb +10 -13
  40. data/spec/unit/rest/node_properties_spec.rb +22 -23
  41. data/spec/unit/rest/node_relationships_spec.rb +18 -39
  42. data/spec/unit/rest/node_traversal_spec.rb +4 -97
  43. data/spec/unit/rest/nodes_spec.rb +47 -48
  44. data/spec/unit/rest/relationship_auto_indexes_spec.rb +23 -24
  45. data/spec/unit/rest/relationship_indexes_spec.rb +42 -43
  46. data/spec/unit/rest/relationship_properties_spec.rb +22 -23
  47. data/spec/unit/rest/relationship_types_spec.rb +3 -4
  48. data/spec/unit/rest/relationships_spec.rb +5 -6
  49. data/spec/unit/rest/schema_index_spec.rb +7 -8
  50. data/spec/unit/rest/transactions_spec.rb +10 -11
  51. metadata +27 -31
  52. data/lib/neography/rest/auto_indexes.rb +0 -64
  53. data/lib/neography/rest/indexes.rb +0 -102
  54. data/lib/neography/rest/paths.rb +0 -46
  55. data/lib/neography/rest/properties.rb +0 -56
  56. data/spec/unit/rest/paths_spec.rb +0 -69
@@ -4,35 +4,34 @@ module Neography
4
4
  class Rest
5
5
  describe Nodes do
6
6
 
7
- let(:connection) { double }
8
- subject { Nodes.new(connection) }
7
+ subject { Neography::Rest.new }
9
8
 
10
9
  context "get nodes" do
11
10
  it "gets single nodes" do
12
- connection.should_receive(:get).with("/node/42")
13
- subject.get("42")
11
+ subject.connection.should_receive(:get).with("/node/42")
12
+ subject.get_node("42")
14
13
  end
15
14
 
16
15
  it "gets multiple nodes" do
17
- connection.should_receive(:get).with("/node/42")
18
- connection.should_receive(:get).with("/node/43")
19
- subject.get_each("42", "43")
16
+ subject.connection.should_receive(:get).with("/node/42")
17
+ subject.connection.should_receive(:get).with("/node/43")
18
+ subject.get_nodes("42", "43")
20
19
  end
21
20
 
22
21
  it "returns multiple nodes in an array" do
23
- connection.stub(:get).and_return("foo", "bar")
24
- subject.get_each("42", "43").should == [ "foo", "bar" ]
22
+ subject.connection.stub(:get).and_return("foo", "bar")
23
+ subject.get_nodes("42", "43").should == [ "foo", "bar" ]
25
24
  end
26
25
 
27
26
  it "gets the root node" do
28
- connection.stub(:get).with("/").and_return({ "reference_node" => "42" })
29
- connection.should_receive(:get).with("/node/42")
30
- subject.root
27
+ subject.connection.stub(:get).with("/").and_return({ "reference_node" => "42" })
28
+ subject.connection.should_receive(:get).with("/node/42")
29
+ subject.get_root
31
30
  end
32
31
 
33
32
  it "returns the root node" do
34
- connection.stub(:get).and_return({ "reference_node" => "42" }, "foo")
35
- subject.root.should == "foo"
33
+ subject.connection.stub(:get).and_return({ "reference_node" => "42" }, "foo")
34
+ subject.get_root.should == "foo"
36
35
  end
37
36
  end
38
37
 
@@ -43,13 +42,13 @@ module Neography
43
42
  :body => '{"foo":"bar","baz":"qux"}',
44
43
  :headers => json_content_type
45
44
  }
46
- connection.should_receive(:post).with("/node", options)
47
- subject.create_with_attributes({:foo => "bar", :baz => "qux"})
45
+ subject.connection.should_receive(:post).with("/node", options)
46
+ subject.create_node_with_attributes({:foo => "bar", :baz => "qux"})
48
47
  end
49
48
 
50
49
  it "returns the created node" do
51
- connection.stub(:post).and_return("foo")
52
- subject.create_with_attributes({}).should == "foo"
50
+ subject.connection.stub(:post).and_return("foo")
51
+ subject.create_node_with_attributes({}).should == "foo"
53
52
  end
54
53
 
55
54
  it "creates with attributes using #create method" do
@@ -57,23 +56,23 @@ module Neography
57
56
  :body => '{"foo":"bar","baz":"qux"}',
58
57
  :headers => json_content_type
59
58
  }
60
- connection.should_receive(:post).with("/node", options)
61
- subject.create({:foo => "bar", :baz => "qux"})
59
+ subject.connection.should_receive(:post).with("/node", options)
60
+ subject.create_node({:foo => "bar", :baz => "qux"})
62
61
  end
63
62
 
64
63
  it "creates empty nodes" do
65
- connection.should_receive(:post).with("/node")
66
- subject.create_empty
64
+ subject.connection.should_receive(:post).with("/node")
65
+ subject.create_empty_node
67
66
  end
68
67
 
69
68
  it "returns an empty node" do
70
- connection.stub(:post).and_return("foo")
71
- subject.create_empty.should == "foo"
69
+ subject.connection.stub(:post).and_return("foo")
70
+ subject.create_empty_node.should == "foo"
72
71
  end
73
72
 
74
73
  it "creates empty nodes using #create method" do
75
- connection.should_receive(:post).with("/node")
76
- subject.create
74
+ subject.connection.should_receive(:post).with("/node")
75
+ subject.create_node
77
76
  end
78
77
 
79
78
  end
@@ -81,8 +80,8 @@ module Neography
81
80
  context "delete nodes" do
82
81
 
83
82
  it "deletes a node" do
84
- connection.should_receive(:delete).with("/node/42")
85
- subject.delete("42")
83
+ subject.connection.should_receive(:delete).with("/node/42")
84
+ subject.delete_node("42")
86
85
  end
87
86
 
88
87
  end
@@ -98,18 +97,18 @@ module Neography
98
97
  :body => '{"foo2":"bar2","baz2":"qux2"}',
99
98
  :headers => json_content_type
100
99
  }
101
- connection.should_receive(:post).with("/node", options1)
102
- connection.should_receive(:post).with("/node", options2)
100
+ subject.connection.should_receive(:post).with("/node", options1)
101
+ subject.connection.should_receive(:post).with("/node", options2)
103
102
 
104
- subject.create_multiple([
103
+ subject.create_nodes([
105
104
  {:foo1 => "bar1", :baz1 => "qux1"},
106
105
  {:foo2 => "bar2", :baz2 => "qux2"}
107
106
  ])
108
107
  end
109
108
 
110
109
  it "returns multiple nodes with attributes in an array" do
111
- connection.stub(:post).and_return("foo", "bar")
112
- subject.create_multiple([{},{}]).should == ["foo", "bar"]
110
+ subject.connection.stub(:post).and_return("foo", "bar")
111
+ subject.create_nodes([{},{}]).should == ["foo", "bar"]
113
112
  end
114
113
 
115
114
  # exotic?
@@ -118,23 +117,23 @@ module Neography
118
117
  :body => '{"foo1":"bar1","baz1":"qux1"}',
119
118
  :headers => json_content_type
120
119
  }
121
- connection.should_receive(:post).with("/node", options1)
122
- connection.should_receive(:post).with("/node")
120
+ subject.connection.should_receive(:post).with("/node", options1)
121
+ subject.connection.should_receive(:post).with("/node")
123
122
 
124
- subject.create_multiple([
123
+ subject.create_nodes([
125
124
  {:foo1 => "bar1", :baz1 => "qux1"},
126
125
  "not a hash" # ?
127
126
  ])
128
127
  end
129
128
 
130
129
  it "creates multiple empty nodes" do
131
- connection.should_receive(:post).with("/node").twice
132
- subject.create_multiple(2)
130
+ subject.connection.should_receive(:post).with("/node").twice
131
+ subject.create_nodes(2)
133
132
  end
134
133
 
135
134
  it "returns multiple empty nodes in an array" do
136
- connection.stub(:post).and_return("foo", "bar")
137
- subject.create_multiple(2).should == ["foo", "bar"]
135
+ subject.connection.stub(:post).and_return("foo", "bar")
136
+ subject.create_nodes(2).should == ["foo", "bar"]
138
137
  end
139
138
 
140
139
  end
@@ -152,10 +151,10 @@ module Neography
152
151
  :body => '{"foo2":"bar2","baz2":"qux2"}',
153
152
  :headers => json_content_type
154
153
  }
155
- connection.should_receive(:post).with("/node", options1)
156
- connection.should_receive(:post).with("/node", options2)
154
+ subject.connection.should_receive(:post).with("/node", options1)
155
+ subject.connection.should_receive(:post).with("/node", options2)
157
156
 
158
- subject.create_multiple_threaded([
157
+ subject.create_nodes_threaded([
159
158
  {:foo1 => "bar1", :baz1 => "qux1"},
160
159
  {:foo2 => "bar2", :baz2 => "qux2"}
161
160
  ])
@@ -167,18 +166,18 @@ module Neography
167
166
  :body => '{"foo1":"bar1","baz1":"qux1"}',
168
167
  :headers => json_content_type
169
168
  }
170
- connection.should_receive(:post).with("/node", options1)
171
- connection.should_receive(:post).with("/node")
169
+ subject.connection.should_receive(:post).with("/node", options1)
170
+ subject.connection.should_receive(:post).with("/node")
172
171
 
173
- subject.create_multiple_threaded([
172
+ subject.create_nodes_threaded([
174
173
  {:foo1 => "bar1", :baz1 => "qux1"},
175
174
  "not a hash" # ?
176
175
  ])
177
176
  end
178
177
 
179
178
  it "creates multiple empty nodes" do
180
- connection.should_receive(:post).with("/node").twice
181
- subject.create_multiple_threaded(2)
179
+ subject.connection.should_receive(:post).with("/node").twice
180
+ subject.create_nodes_threaded(2)
182
181
  end
183
182
 
184
183
  end
@@ -4,62 +4,61 @@ module Neography
4
4
  class Rest
5
5
  describe RelationshipAutoIndexes do
6
6
 
7
- let(:connection) { double }
8
- subject { RelationshipAutoIndexes.new(connection) }
7
+ subject { Neography::Rest.new }
9
8
 
10
9
  it "gets a relationship from an auto index" do
11
- connection.should_receive(:get).with("/index/auto/relationship/some_key/some_value")
12
- subject.get("some_key", "some_value")
10
+ subject.connection.should_receive(:get).with("/index/auto/relationship/some_key/some_value")
11
+ subject.get_relationship_auto_index("some_key", "some_value")
13
12
  end
14
13
 
15
14
  it "returns nil if nothing was found in the auto index" do
16
- connection.stub(:get).and_return(nil)
17
- subject.get("some_key", "some_value").should be_nil
15
+ subject.connection.stub(:get).and_return(nil)
16
+ subject.get_relationship_auto_index("some_key", "some_value").should be_nil
18
17
  end
19
18
 
20
19
  it "finds by key and value if value passed to #find_or_query" do
21
- connection.should_receive(:get).with("/index/auto/relationship/some_key/some_value")
22
- subject.find_or_query("some_key", "some_value")
20
+ subject.connection.should_receive(:get).with("/index/auto/relationship/some_key/some_value")
21
+ subject.find_relationship_auto_index("some_key", "some_value")
23
22
  end
24
23
 
25
24
  it "finds by query if no value passed to #find_or_query" do
26
- connection.should_receive(:get).with("/index/auto/relationship/?query=some_query")
27
- subject.find_or_query("some_query")
25
+ subject.connection.should_receive(:get).with("/index/auto/relationship/?query=some_query")
26
+ subject.find_relationship_auto_index("some_query")
28
27
  end
29
28
 
30
29
  it "finds by key and value" do
31
- connection.should_receive(:get).with("/index/auto/relationship/some_key/some_value")
32
- subject.find("some_key", "some_value")
30
+ subject.connection.should_receive(:get).with("/index/auto/relationship/some_key/some_value")
31
+ subject.find_relationship_auto_index("some_key", "some_value")
33
32
  end
34
33
 
35
34
  it "finds by query" do
36
- connection.should_receive(:get).with("/index/auto/relationship/?query=some_query")
37
- subject.query("some_query")
35
+ subject.connection.should_receive(:get).with("/index/auto/relationship/?query=some_query")
36
+ subject.find_relationship_auto_index("some_query")
38
37
  end
39
38
 
40
39
  it "gets the status" do
41
- connection.should_receive(:get).with("/index/auto/relationship/status")
42
- subject.status
40
+ subject.connection.should_receive(:get).with("/index/auto/relationship/status")
41
+ subject.get_relationship_auto_index_status
43
42
  end
44
43
 
45
44
  it "sets the status" do
46
- connection.should_receive(:put).with("/index/auto/relationship/status", hash_match(:body, '"foo"'))
47
- subject.status = "foo"
45
+ subject.connection.should_receive(:put).with("/index/auto/relationship/status", hash_match(:body, '"foo"'))
46
+ subject.set_relationship_auto_index_status("foo")
48
47
  end
49
48
 
50
49
  it "gets auto index properties" do
51
- connection.should_receive(:get).with("/index/auto/relationship/properties")
52
- subject.properties
50
+ subject.connection.should_receive(:get).with("/index/auto/relationship/properties")
51
+ subject.get_relationship_auto_index_properties
53
52
  end
54
53
 
55
54
  it "adds a property to an auto index" do
56
- connection.should_receive(:post).with("/index/auto/relationship/properties", hash_match(:body, "foo"))
57
- subject.add_property("foo")
55
+ subject.connection.should_receive(:post).with("/index/auto/relationship/properties", hash_match(:body, "foo"))
56
+ subject.add_relationship_auto_index_property("foo")
58
57
  end
59
58
 
60
59
  it "removes a property from an auto index" do
61
- connection.should_receive(:delete).with("/index/auto/relationship/properties/foo")
62
- subject.remove_property("foo")
60
+ subject.connection.should_receive(:delete).with("/index/auto/relationship/properties/foo")
61
+ subject.remove_relationship_auto_index_property("foo")
63
62
  end
64
63
 
65
64
  end
@@ -4,12 +4,11 @@ module Neography
4
4
  class Rest
5
5
  describe RelationshipIndexes do
6
6
 
7
- let(:connection) { double(:configuration => "http://configuration") }
8
- subject { RelationshipIndexes.new(connection) }
7
+ subject { Neography::Rest.new }
9
8
 
10
9
  it "lists all indexes" do
11
- connection.should_receive(:get).with("/index/relationship")
12
- subject.list
10
+ subject.connection.should_receive(:get).with("/index/relationship")
11
+ subject.list_relationship_indexes
13
12
  end
14
13
 
15
14
  it "creates a relationship index" do
@@ -20,13 +19,13 @@ module Neography
20
19
  },
21
20
  "name" => "some_index"
22
21
  }
23
- connection.should_receive(:post).with("/index/relationship", json_match(:body, expected_body))
24
- subject.create("some_index", "some_type", "some_provider")
22
+ subject.connection.should_receive(:post).with("/index/relationship", json_match(:body, expected_body))
23
+ subject.create_relationship_index("some_index", "some_type", "some_provider")
25
24
  end
26
25
 
27
26
  it "returns the post result after creation" do
28
- connection.stub(:post).and_return("foo")
29
- subject.create("some_index", "some_type", "some_provider").should == "foo"
27
+ subject.connection.stub(:post).and_return("foo")
28
+ subject.create_relationship_index("some_index", "some_type", "some_provider").should == "foo"
30
29
  end
31
30
 
32
31
  it "creates an auto-index" do
@@ -37,8 +36,8 @@ module Neography
37
36
  },
38
37
  "name" => "relationship_auto_index"
39
38
  }
40
- connection.should_receive(:post).with("/index/relationship", json_match(:body, expected_body))
41
- subject.create_auto("some_type", "some_provider")
39
+ subject.connection.should_receive(:post).with("/index/relationship", json_match(:body, expected_body))
40
+ subject.create_relationship_auto_index("some_type", "some_provider")
42
41
  end
43
42
 
44
43
  it "creates a unique relationship in an index" do
@@ -46,87 +45,87 @@ module Neography
46
45
  "key" => "key",
47
46
  "value" => "value",
48
47
  "type" => "type",
49
- "start" => "http://configuration/node/42",
50
- "end" => "http://configuration/node/43",
48
+ "start" => "http://localhost:7474/node/42",
49
+ "end" => "http://localhost:7474/node/43",
51
50
  "properties" => "properties"
52
51
  }
53
- connection.should_receive(:post).with("/index/relationship/some_index?unique", json_match(:body, expected_body))
54
- subject.create_unique("some_index", "key", "value", "type", "42", "43", "properties")
52
+ subject.connection.should_receive(:post).with("/index/relationship/some_index?unique", json_match(:body, expected_body))
53
+ subject.create_unique_relationship("some_index", "key", "value", "type", "42", "43", "properties")
55
54
  end
56
55
 
57
56
  it "adds a relationship to an index" do
58
57
  expected_body = {
59
- "uri" => "http://configuration/relationship/42",
58
+ "uri" => "http://localhost:7474/relationship/42",
60
59
  "key" => "key",
61
60
  "value" => "value"
62
61
  }
63
- connection.should_receive(:post).with("/index/relationship/some_index", json_match(:body, expected_body))
64
- subject.add("some_index", "key", "value", "42")
62
+ subject.connection.should_receive(:post).with("/index/relationship/some_index", json_match(:body, expected_body))
63
+ subject.add_relationship_to_index("some_index", "key", "value", "42")
65
64
  end
66
65
 
67
66
  it "gets a relationship from an index" do
68
- connection.should_receive(:get).with("/index/relationship/some_index/some_key/some_value")
69
- subject.get("some_index", "some_key", "some_value")
67
+ subject.connection.should_receive(:get).with("/index/relationship/some_index/some_key/some_value")
68
+ subject.get_relationship_index("some_index", "some_key", "some_value")
70
69
  end
71
70
 
72
71
  it "returns nil if nothing was found in the index" do
73
- connection.stub(:get).and_return(nil)
74
- subject.get("some_index", "some_key", "some_value").should be_nil
72
+ subject.connection.stub(:get).and_return(nil)
73
+ subject.get_relationship_index("some_index", "some_key", "some_value").should be_nil
75
74
  end
76
75
 
77
76
  it "finds by key and value if both passed to #find" do
78
- connection.should_receive(:get).with("/index/relationship/some_index/some_key/some_value")
79
- subject.find("some_index", "some_key", "some_value")
77
+ subject.connection.should_receive(:get).with("/index/relationship/some_index/some_key/some_value")
78
+ subject.find_relationship_index("some_index", "some_key", "some_value")
80
79
  end
81
80
 
82
81
  it "finds by query if no value passed to #find" do
83
- connection.should_receive(:get).with("/index/relationship/some_index?query=some_query")
84
- subject.find("some_index", "some_query")
82
+ subject.connection.should_receive(:get).with("/index/relationship/some_index?query=some_query")
83
+ subject.find_relationship_index("some_index", "some_query")
85
84
  end
86
85
 
87
86
  it "finds by key query" do
88
- connection.should_receive(:get).with("/index/relationship/some_index/some_key/some_value")
89
- subject.find_by_key_value("some_index", "some_key", "some_value")
87
+ subject.connection.should_receive(:get).with("/index/relationship/some_index/some_key/some_value")
88
+ subject.find_relationship_index_by_key_value("some_index", "some_key", "some_value")
90
89
  end
91
90
 
92
91
  it "finds by query" do
93
- connection.should_receive(:get).with("/index/relationship/some_index?query=some_query")
94
- subject.find_by_query("some_index", "some_query")
92
+ subject.connection.should_receive(:get).with("/index/relationship/some_index?query=some_query")
93
+ subject.find_relationship_index_by_query("some_index", "some_query")
95
94
  end
96
95
 
97
96
  it "removes a relationship from an index for #remove with two arguments" do
98
- connection.should_receive(:delete).with("/index/relationship/some_index/42")
99
- subject.remove("some_index", "42")
97
+ subject.connection.should_receive(:delete).with("/index/relationship/some_index/42")
98
+ subject.remove_relationship_from_index("some_index", "42")
100
99
  end
101
100
 
102
101
  it "removes a relationship from an index by key for #remove with three arguments" do
103
- connection.should_receive(:delete).with("/index/relationship/some_index/some_key/42")
104
- subject.remove("some_index", "some_key", "42")
102
+ subject.connection.should_receive(:delete).with("/index/relationship/some_index/some_key/42")
103
+ subject.remove_relationship_from_index("some_index", "some_key", "42")
105
104
  end
106
105
 
107
106
  it "removes a relationship from an index by key and value for #remove with four arguments" do
108
- connection.should_receive(:delete).with("/index/relationship/some_index/some_key/some_value/42")
109
- subject.remove("some_index", "some_key", "some_value", "42")
107
+ subject.connection.should_receive(:delete).with("/index/relationship/some_index/some_key/some_value/42")
108
+ subject.remove_relationship_from_index("some_index", "some_key", "some_value", "42")
110
109
  end
111
110
 
112
111
  it "removes a relationship from an index" do
113
- connection.should_receive(:delete).with("/index/relationship/some_index/42")
114
- subject.remove_by_id("some_index", "42")
112
+ subject.connection.should_receive(:delete).with("/index/relationship/some_index/42")
113
+ subject.remove_relationship_index_by_id("some_index", "42")
115
114
  end
116
115
 
117
116
  it "removes a relationship from an index by key" do
118
- connection.should_receive(:delete).with("/index/relationship/some_index/some_key/42")
119
- subject.remove_by_key("some_index", "42", "some_key")
117
+ subject.connection.should_receive(:delete).with("/index/relationship/some_index/some_key/42")
118
+ subject.remove_relationship_index_by_key("some_index", "42", "some_key")
120
119
  end
121
120
 
122
121
  it "removes a relationship from an index by key and value" do
123
- connection.should_receive(:delete).with("/index/relationship/some_index/some_key/some_value/42")
124
- subject.remove_by_value("some_index", "42", "some_key", "some_value")
122
+ subject.connection.should_receive(:delete).with("/index/relationship/some_index/some_key/some_value/42")
123
+ subject.remove_relationship_index_by_value("some_index", "42", "some_key", "some_value")
125
124
  end
126
125
 
127
126
  it "drops an index" do
128
- connection.should_receive(:delete).with("/index/relationship/some_index")
129
- subject.drop("some_index")
127
+ subject.connection.should_receive(:delete).with("/index/relationship/some_index")
128
+ subject.drop_relationship_index("some_index")
130
129
  end
131
130
  end
132
131
  end
@@ -4,8 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe RelationshipProperties do
6
6
 
7
- let(:connection) { double }
8
- subject { RelationshipProperties.new(connection) }
7
+ subject { Neography::Rest.new }
9
8
 
10
9
  it "sets properties" do
11
10
  options1 = {
@@ -16,9 +15,9 @@ module Neography
16
15
  :body => '"qux"',
17
16
  :headers => json_content_type
18
17
  }
19
- connection.should_receive(:put).with("/relationship/42/properties/foo", options1)
20
- connection.should_receive(:put).with("/relationship/42/properties/baz", options2)
21
- subject.set("42", {:foo => "bar", :baz => "qux"})
18
+ subject.connection.should_receive(:put).with("/relationship/42/properties/foo", options1)
19
+ subject.connection.should_receive(:put).with("/relationship/42/properties/baz", options2)
20
+ subject.set_relationship_properties("42", {:foo => "bar", :baz => "qux"})
22
21
  end
23
22
 
24
23
  it "resets properties" do
@@ -26,36 +25,36 @@ module Neography
26
25
  :body => '{"foo":"bar"}',
27
26
  :headers => json_content_type
28
27
  }
29
- connection.should_receive(:put).with("/relationship/42/properties", options)
30
- subject.reset("42", {:foo => "bar"})
28
+ subject.connection.should_receive(:put).with("/relationship/42/properties", options)
29
+ subject.reset_relationship_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("/relationship/42/properties")
37
- subject.get("42")
35
+ subject.connection.should_receive(:get).with("/relationship/42/properties")
36
+ subject.get_relationship_properties("42")
38
37
  end
39
38
 
40
39
  it "gets multiple properties" do
41
- connection.should_receive(:get).with("/relationship/42/properties/foo")
42
- connection.should_receive(:get).with("/relationship/42/properties/bar")
43
- subject.get("42", "foo", "bar")
40
+ subject.connection.should_receive(:get).with("/relationship/42/properties/foo")
41
+ subject.connection.should_receive(:get).with("/relationship/42/properties/bar")
42
+ subject.get_relationship_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_relationship_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_relationship_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_relationship_properties("42", "foo", "bar").should == { "foo" => "baz" }
59
58
  end
60
59
 
61
60
  end
@@ -63,14 +62,14 @@ module Neography
63
62
  context "removing properties" do
64
63
 
65
64
  it "removes all properties" do
66
- connection.should_receive(:delete).with("/relationship/42/properties")
67
- subject.remove("42")
65
+ subject.connection.should_receive(:delete).with("/relationship/42/properties")
66
+ subject.remove_relationship_properties("42")
68
67
  end
69
68
 
70
69
  it "removes multiple properties" do
71
- connection.should_receive(:delete).with("/relationship/42/properties/foo")
72
- connection.should_receive(:delete).with("/relationship/42/properties/bar")
73
- subject.remove("42", "foo", "bar")
70
+ subject.connection.should_receive(:delete).with("/relationship/42/properties/foo")
71
+ subject.connection.should_receive(:delete).with("/relationship/42/properties/bar")
72
+ subject.remove_relationship_properties("42", "foo", "bar")
74
73
  end
75
74
 
76
75
  end