neography 0.0.31 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -0
- data/.travis.yml +1 -1
- data/CONTRIBUTORS +2 -1
- data/README.md +247 -0
- data/Rakefile +1 -2
- data/lib/neography/config.rb +48 -16
- data/lib/neography/connection.rb +151 -0
- data/lib/neography/errors.rb +42 -0
- data/lib/neography/node.rb +17 -14
- data/lib/neography/node_relationship.rb +3 -1
- data/lib/neography/node_traverser.rb +24 -20
- data/lib/neography/property.rb +31 -28
- data/lib/neography/property_container.rb +1 -1
- data/lib/neography/relationship.rb +16 -19
- data/lib/neography/rest/auto_indexes.rb +64 -0
- data/lib/neography/rest/batch.rb +262 -0
- data/lib/neography/rest/clean.rb +19 -0
- data/lib/neography/rest/cypher.rb +24 -0
- data/lib/neography/rest/gremlin.rb +24 -0
- data/lib/neography/rest/helpers.rb +26 -0
- data/lib/neography/rest/indexes.rb +97 -0
- data/lib/neography/rest/node_auto_indexes.rb +14 -0
- data/lib/neography/rest/node_indexes.rb +35 -0
- data/lib/neography/rest/node_paths.rb +57 -0
- data/lib/neography/rest/node_properties.rb +11 -0
- data/lib/neography/rest/node_relationships.rb +53 -0
- data/lib/neography/rest/node_traversal.rb +81 -0
- data/lib/neography/rest/nodes.rb +102 -0
- data/lib/neography/rest/paths.rb +36 -0
- data/lib/neography/rest/properties.rb +56 -0
- data/lib/neography/rest/relationship_auto_indexes.rb +14 -0
- data/lib/neography/rest/relationship_indexes.rb +35 -0
- data/lib/neography/rest/relationship_properties.rb +11 -0
- data/lib/neography/rest/relationships.rb +23 -0
- data/lib/neography/rest.rb +285 -615
- data/lib/neography/tasks.rb +1 -1
- data/lib/neography/version.rb +1 -1
- data/lib/neography.rb +13 -2
- data/neography.gemspec +8 -8
- data/spec/integration/authorization_spec.rb +2 -2
- data/spec/integration/index_spec.rb +4 -4
- data/spec/integration/neography_spec.rb +2 -2
- data/spec/integration/node_path_spec.rb +2 -2
- data/spec/integration/node_relationship_spec.rb +5 -3
- data/spec/integration/node_spec.rb +20 -19
- data/spec/integration/parsing_spec.rb +2 -2
- data/spec/integration/relationship_spec.rb +2 -2
- data/spec/integration/rest_batch_spec.rb +28 -28
- data/spec/integration/rest_bulk_spec.rb +2 -2
- data/spec/integration/rest_experimental_spec.rb +2 -2
- data/spec/integration/rest_gremlin_fail_spec.rb +2 -2
- data/spec/integration/rest_header_spec.rb +4 -9
- data/spec/integration/rest_index_spec.rb +21 -1
- data/spec/integration/rest_node_spec.rb +58 -44
- data/spec/integration/rest_path_spec.rb +5 -5
- data/spec/integration/rest_plugin_spec.rb +8 -2
- data/spec/integration/rest_relationship_spec.rb +35 -30
- data/spec/integration/rest_traverse_spec.rb +2 -2
- data/spec/matchers.rb +33 -0
- data/spec/neography_spec.rb +23 -0
- data/spec/spec_helper.rb +19 -1
- data/spec/unit/config_spec.rb +46 -0
- data/spec/unit/connection_spec.rb +205 -0
- data/spec/unit/node_spec.rb +100 -0
- data/spec/unit/properties_spec.rb +136 -0
- data/spec/unit/relationship_spec.rb +118 -0
- data/spec/unit/rest/batch_spec.rb +243 -0
- data/spec/unit/rest/clean_spec.rb +17 -0
- data/spec/unit/rest/cypher_spec.rb +21 -0
- data/spec/unit/rest/gremlin_spec.rb +26 -0
- data/spec/unit/rest/node_auto_indexes_spec.rb +67 -0
- data/spec/unit/rest/node_indexes_spec.rb +126 -0
- data/spec/unit/rest/node_paths_spec.rb +80 -0
- data/spec/unit/rest/node_properties_spec.rb +80 -0
- data/spec/unit/rest/node_relationships_spec.rb +78 -0
- data/spec/unit/rest/node_traversal_spec.rb +128 -0
- data/spec/unit/rest/nodes_spec.rb +188 -0
- data/spec/unit/rest/paths_spec.rb +69 -0
- data/spec/unit/rest/relationship_auto_indexes_spec.rb +67 -0
- data/spec/unit/rest/relationship_indexes_spec.rb +128 -0
- data/spec/unit/rest/relationship_properties_spec.rb +80 -0
- data/spec/unit/rest/relationships_spec.rb +22 -0
- metadata +86 -19
- data/Gemfile.lock +0 -44
- data/README.rdoc +0 -420
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Neography::Rest do
|
|
4
4
|
before(:each) do
|
|
@@ -64,11 +64,12 @@ describe Neography::Rest do
|
|
|
64
64
|
existing_node["self"].split('/').last.should == new_node[:id]
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
it "
|
|
67
|
+
it "raises an error if it tries to get a node that does not exist" do
|
|
68
68
|
new_node = @neo.create_node
|
|
69
69
|
fake_node = new_node["self"].split('/').last.to_i + 1000
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
expect {
|
|
71
|
+
@neo.get_node(fake_node)
|
|
72
|
+
}.to raise_error Neography::NodeNotFoundException
|
|
72
73
|
end
|
|
73
74
|
end
|
|
74
75
|
|
|
@@ -84,9 +85,9 @@ describe Neography::Rest do
|
|
|
84
85
|
it "it fails to set properties on a node that does not exist" do
|
|
85
86
|
new_node = @neo.create_node
|
|
86
87
|
fake_node = new_node["self"].split('/').last.to_i + 1000
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
expect {
|
|
89
|
+
@neo.set_node_properties(fake_node, {"weight" => 150, "hair" => "blonde"})
|
|
90
|
+
}.to raise_error Neography::NodeNotFoundException
|
|
90
91
|
end
|
|
91
92
|
end
|
|
92
93
|
|
|
@@ -104,9 +105,9 @@ describe Neography::Rest do
|
|
|
104
105
|
it "it fails to reset properties on a node that does not exist" do
|
|
105
106
|
new_node = @neo.create_node
|
|
106
107
|
fake_node = new_node["self"].split('/').last.to_i + 1000
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
expect {
|
|
109
|
+
@neo.reset_node_properties(fake_node, {"weight" => 170, "eyes" => "green"})
|
|
110
|
+
}.to raise_error Neography::NodeNotFoundException
|
|
110
111
|
end
|
|
111
112
|
end
|
|
112
113
|
|
|
@@ -131,15 +132,19 @@ describe Neography::Rest do
|
|
|
131
132
|
@neo.get_node_properties(new_node).should be_nil
|
|
132
133
|
end
|
|
133
134
|
|
|
134
|
-
it "
|
|
135
|
+
it "raises error if it tries to get some of the properties on a node that does not have any" do
|
|
135
136
|
new_node = @neo.create_node
|
|
136
|
-
|
|
137
|
+
expect {
|
|
138
|
+
@neo.get_node_properties(new_node, ["weight", "height"]).should be_nil
|
|
139
|
+
}.to raise_error Neography::NoSuchPropertyException
|
|
137
140
|
end
|
|
138
141
|
|
|
139
|
-
it "
|
|
142
|
+
it "raises error if it fails to get properties on a node that does not exist" do
|
|
140
143
|
new_node = @neo.create_node
|
|
141
144
|
fake_node = new_node["self"].split('/').last.to_i + 1000
|
|
142
|
-
|
|
145
|
+
expect {
|
|
146
|
+
@neo.get_node_properties(fake_node).should be_nil
|
|
147
|
+
}.to raise_error Neography::NodeNotFoundException
|
|
143
148
|
end
|
|
144
149
|
end
|
|
145
150
|
|
|
@@ -150,10 +155,12 @@ describe Neography::Rest do
|
|
|
150
155
|
@neo.get_node_properties(new_node).should be_nil
|
|
151
156
|
end
|
|
152
157
|
|
|
153
|
-
it "
|
|
158
|
+
it "raises error if it fails to remove the properties of a node that does not exist" do
|
|
154
159
|
new_node = @neo.create_node
|
|
155
160
|
fake_node = new_node["self"].split('/').last.to_i + 1000
|
|
156
|
-
|
|
161
|
+
expect {
|
|
162
|
+
@neo.remove_node_properties(fake_node).should be_nil
|
|
163
|
+
}.to raise_error Neography::NodeNotFoundException
|
|
157
164
|
end
|
|
158
165
|
|
|
159
166
|
it "can remove a specific node property" do
|
|
@@ -177,35 +184,39 @@ describe Neography::Rest do
|
|
|
177
184
|
it "can delete an unrelated node" do
|
|
178
185
|
new_node = @neo.create_node
|
|
179
186
|
@neo.delete_node(new_node).should be_nil
|
|
180
|
-
|
|
181
|
-
|
|
187
|
+
expect {
|
|
188
|
+
@neo.get_node(new_node)
|
|
189
|
+
}.to raise_error Neography::NodeNotFoundException
|
|
182
190
|
end
|
|
183
191
|
|
|
184
192
|
it "cannot delete a node that has relationships" do
|
|
185
193
|
new_node1 = @neo.create_node
|
|
186
194
|
new_node2 = @neo.create_node
|
|
187
195
|
@neo.create_relationship("friends", new_node1, new_node2)
|
|
188
|
-
|
|
196
|
+
expect {
|
|
197
|
+
@neo.delete_node(new_node1).should be_nil
|
|
198
|
+
}.to raise_error Neography::OperationFailureException
|
|
189
199
|
existing_node = @neo.get_node(new_node1)
|
|
190
200
|
existing_node.should_not be_nil
|
|
191
201
|
end
|
|
192
202
|
|
|
193
|
-
it "
|
|
203
|
+
it "raises error if it tries to delete a node that does not exist" do
|
|
194
204
|
new_node = @neo.create_node
|
|
195
205
|
fake_node = new_node["self"].split('/').last.to_i + 1000
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
206
|
+
expect {
|
|
207
|
+
@neo.delete_node(fake_node).should be_nil
|
|
208
|
+
}.to raise_error Neography::NodeNotFoundException
|
|
199
209
|
end
|
|
200
210
|
|
|
201
|
-
it "
|
|
211
|
+
it "raises error if it tries to delete a node that has already been deleted" do
|
|
202
212
|
new_node = @neo.create_node
|
|
203
213
|
@neo.delete_node(new_node).should be_nil
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
214
|
+
expect {
|
|
215
|
+
existing_node = @neo.get_node(new_node)
|
|
216
|
+
}.to raise_error Neography::NodeNotFoundException
|
|
217
|
+
expect {
|
|
218
|
+
@neo.delete_node(new_node).should be_nil
|
|
219
|
+
}.to raise_error Neography::NodeNotFoundException
|
|
209
220
|
end
|
|
210
221
|
end
|
|
211
222
|
|
|
@@ -213,8 +224,9 @@ describe Neography::Rest do
|
|
|
213
224
|
it "can delete an unrelated node" do
|
|
214
225
|
new_node = @neo.create_node
|
|
215
226
|
@neo.delete_node!(new_node).should be_nil
|
|
216
|
-
|
|
217
|
-
|
|
227
|
+
expect {
|
|
228
|
+
existing_node = @neo.get_node(new_node)
|
|
229
|
+
}.to raise_error Neography::NodeNotFoundException
|
|
218
230
|
end
|
|
219
231
|
|
|
220
232
|
it "can delete a node that has relationships" do
|
|
@@ -222,27 +234,29 @@ describe Neography::Rest do
|
|
|
222
234
|
new_node2 = @neo.create_node
|
|
223
235
|
@neo.create_relationship("friends", new_node1, new_node2)
|
|
224
236
|
@neo.delete_node!(new_node1).should be_nil
|
|
225
|
-
|
|
226
|
-
|
|
237
|
+
expect {
|
|
238
|
+
existing_node = @neo.get_node(new_node1)
|
|
239
|
+
}.to raise_error Neography::NodeNotFoundException
|
|
227
240
|
end
|
|
228
241
|
|
|
229
|
-
it "
|
|
242
|
+
it "raises error if it tries to delete a node that does not exist" do
|
|
230
243
|
new_node = @neo.create_node
|
|
231
244
|
fake_node = new_node["self"].split('/').last.to_i + 1000
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
245
|
+
expect {
|
|
246
|
+
@neo.delete_node!(fake_node).should be_nil
|
|
247
|
+
}.to raise_error Neography::NodeNotFoundException
|
|
235
248
|
end
|
|
236
249
|
|
|
237
|
-
it "
|
|
250
|
+
it "raises error if it tries to delete a node that has already been deleted" do
|
|
238
251
|
new_node = @neo.create_node
|
|
239
252
|
@neo.delete_node!(new_node).should be_nil
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
253
|
+
expect {
|
|
254
|
+
existing_node = @neo.get_node(new_node)
|
|
255
|
+
}.to raise_error Neography::NodeNotFoundException
|
|
256
|
+
expect {
|
|
257
|
+
@neo.delete_node!(new_node).should be_nil
|
|
258
|
+
}.to raise_error Neography::NodeNotFoundException
|
|
245
259
|
end
|
|
246
260
|
end
|
|
247
261
|
|
|
248
|
-
end
|
|
262
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Neography::Rest do
|
|
4
4
|
before(:each) do
|
|
@@ -83,9 +83,9 @@ describe Neography::Rest do
|
|
|
83
83
|
@neo.create_relationship("friends", new_node3, new_node4)
|
|
84
84
|
@neo.create_relationship("friends", new_node4, new_node5)
|
|
85
85
|
@neo.create_relationship("friends", new_node3, new_node5)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
expect {
|
|
87
|
+
@neo.get_path(new_node1, new_node5, {"type"=> "friends", "direction" => "out"}, depth=2, algorithm="shortestPath")
|
|
88
|
+
}.to raise_error Neography::NotFoundException
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
it "can get a path between two nodes of a specific relationship" do
|
|
@@ -228,4 +228,4 @@ describe Neography::Rest do
|
|
|
228
228
|
end
|
|
229
229
|
|
|
230
230
|
|
|
231
|
-
end
|
|
231
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Neography::Rest do
|
|
4
4
|
before(:each) do
|
|
@@ -62,6 +62,12 @@ describe Neography::Rest do
|
|
|
62
62
|
existing_node["data"][0][0]["self"].split('/').last.should == id
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
+
it "throws an error for an invalid query" do
|
|
66
|
+
expect {
|
|
67
|
+
@neo.execute_query("this is not a query")
|
|
68
|
+
}.to raise_error(Neography::SyntaxException)
|
|
69
|
+
end
|
|
70
|
+
|
|
65
71
|
end
|
|
66
72
|
|
|
67
|
-
end
|
|
73
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Neography::Rest do
|
|
4
4
|
before(:each) do
|
|
@@ -30,7 +30,7 @@ describe Neography::Rest do
|
|
|
30
30
|
new_relationship["data"]["since"].should == '10-1-2010'
|
|
31
31
|
new_relationship["data"]["met"].should == "college"
|
|
32
32
|
end
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
it "can create a unique node with more than one property" do
|
|
35
35
|
index_name = generate_text(6)
|
|
36
36
|
key = generate_text(6)
|
|
@@ -40,7 +40,7 @@ describe Neography::Rest do
|
|
|
40
40
|
new_node["data"]["name"].should == "Max"
|
|
41
41
|
new_node["data"]["age"].should == 31
|
|
42
42
|
end
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
it "can create a unique relationship" do
|
|
45
45
|
index_name = generate_text(6)
|
|
46
46
|
key = generate_text(6)
|
|
@@ -51,7 +51,6 @@ describe Neography::Rest do
|
|
|
51
51
|
new_relationship["data"][key].should == value
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
|
|
55
54
|
end
|
|
56
55
|
|
|
57
56
|
describe "get_relationship" do
|
|
@@ -65,13 +64,14 @@ describe Neography::Rest do
|
|
|
65
64
|
existing_relationship["self"].should == new_relationship["self"]
|
|
66
65
|
end
|
|
67
66
|
|
|
68
|
-
it "
|
|
67
|
+
it "raises error if it tries to get a relationship that does not exist" do
|
|
69
68
|
new_node1 = @neo.create_node
|
|
70
69
|
new_node2 = @neo.create_node
|
|
71
70
|
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
|
72
71
|
fake_relationship = new_relationship["self"].split('/').last.to_i + 1000
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
expect {
|
|
73
|
+
existing_relationship = @neo.get_relationship(fake_relationship)
|
|
74
|
+
}.to raise_error Neography::RelationshipNotFoundException
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
77
|
|
|
@@ -93,9 +93,9 @@ describe Neography::Rest do
|
|
|
93
93
|
new_node2 = @neo.create_node
|
|
94
94
|
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
|
95
95
|
fake_relationship = new_relationship["self"].split('/').last.to_i + 1000
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
expect {
|
|
97
|
+
@neo.set_relationship_properties(fake_relationship, {"since" => '10-1-2010', "met" => "college"})
|
|
98
|
+
}.to raise_error Neography::RelationshipNotFoundException
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
|
|
@@ -117,9 +117,9 @@ describe Neography::Rest do
|
|
|
117
117
|
new_node2 = @neo.create_node
|
|
118
118
|
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
|
119
119
|
fake_relationship = new_relationship["self"].split('/').last.to_i + 1000
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
expect {
|
|
121
|
+
@neo.reset_relationship_properties(fake_relationship, {"since" => '10-1-2010', "met" => "college"})
|
|
122
|
+
}.to raise_error Neography::RelationshipNotFoundException
|
|
123
123
|
end
|
|
124
124
|
end
|
|
125
125
|
|
|
@@ -151,21 +151,23 @@ describe Neography::Rest do
|
|
|
151
151
|
relationship_properties.should be_nil
|
|
152
152
|
end
|
|
153
153
|
|
|
154
|
-
it "
|
|
154
|
+
it "raises error if it tries to get some of the properties on a relationship that does not have any" do
|
|
155
155
|
new_node1 = @neo.create_node
|
|
156
156
|
new_node2 = @neo.create_node
|
|
157
157
|
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
expect {
|
|
159
|
+
@neo.get_relationship_properties(new_relationship, ["since", "roommates"])
|
|
160
|
+
}.to raise_error Neography::NoSuchPropertyException
|
|
160
161
|
end
|
|
161
162
|
|
|
162
|
-
it "
|
|
163
|
+
it "raises error if it fails to get properties on a relationship that does not exist" do
|
|
163
164
|
new_node1 = @neo.create_node
|
|
164
165
|
new_node2 = @neo.create_node
|
|
165
166
|
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
|
166
167
|
fake_relationship = new_relationship["self"].split('/').last.to_i + 1000
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
expect {
|
|
169
|
+
@neo.get_relationship_properties(fake_relationship)
|
|
170
|
+
}.to raise_error Neography::RelationshipNotFoundException
|
|
169
171
|
end
|
|
170
172
|
end
|
|
171
173
|
|
|
@@ -178,13 +180,14 @@ describe Neography::Rest do
|
|
|
178
180
|
@neo.get_relationship_properties(new_relationship).should be_nil
|
|
179
181
|
end
|
|
180
182
|
|
|
181
|
-
it "
|
|
183
|
+
it "raises error if it fails to remove the properties of a relationship that does not exist" do
|
|
182
184
|
new_node1 = @neo.create_node
|
|
183
185
|
new_node2 = @neo.create_node
|
|
184
186
|
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2010', "met" => "college"})
|
|
185
187
|
fake_relationship = new_relationship["self"].split('/').last.to_i + 1000
|
|
186
|
-
|
|
187
|
-
|
|
188
|
+
expect {
|
|
189
|
+
@neo.remove_relationship_properties(fake_relationship)
|
|
190
|
+
}.to raise_error Neography::RelationshipNotFoundException
|
|
188
191
|
end
|
|
189
192
|
|
|
190
193
|
it "can remove a specific relationship property" do
|
|
@@ -192,7 +195,7 @@ describe Neography::Rest do
|
|
|
192
195
|
new_node2 = @neo.create_node
|
|
193
196
|
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2010', "met" => "college"})
|
|
194
197
|
@neo.remove_relationship_properties(new_relationship, "met")
|
|
195
|
-
relationship_properties = @neo.get_relationship_properties(new_relationship
|
|
198
|
+
relationship_properties = @neo.get_relationship_properties(new_relationship)
|
|
196
199
|
relationship_properties["met"].should be_nil
|
|
197
200
|
relationship_properties["since"].should == '10-1-2010'
|
|
198
201
|
end
|
|
@@ -202,7 +205,7 @@ describe Neography::Rest do
|
|
|
202
205
|
new_node2 = @neo.create_node
|
|
203
206
|
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2010', "met" => "college", "roommates" => "no"})
|
|
204
207
|
@neo.remove_relationship_properties(new_relationship, ["met", "since"])
|
|
205
|
-
relationship_properties = @neo.get_relationship_properties(new_relationship
|
|
208
|
+
relationship_properties = @neo.get_relationship_properties(new_relationship)
|
|
206
209
|
relationship_properties["met"].should be_nil
|
|
207
210
|
relationship_properties["since"].should be_nil
|
|
208
211
|
relationship_properties["roommates"].should == "no"
|
|
@@ -219,13 +222,14 @@ describe Neography::Rest do
|
|
|
219
222
|
relationships.should be_nil
|
|
220
223
|
end
|
|
221
224
|
|
|
222
|
-
it "
|
|
225
|
+
it "raises error if it tries to delete a relationship that does not exist" do
|
|
223
226
|
new_node1 = @neo.create_node
|
|
224
227
|
new_node2 = @neo.create_node
|
|
225
228
|
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2010', "met" => "college"})
|
|
226
229
|
fake_relationship = new_relationship["self"].split('/').last.to_i + 1000
|
|
227
|
-
|
|
228
|
-
|
|
230
|
+
expect {
|
|
231
|
+
existing_relationship = @neo.delete_relationship(fake_relationship)
|
|
232
|
+
}.to raise_error Neography::RelationshipNotFoundException
|
|
229
233
|
end
|
|
230
234
|
|
|
231
235
|
it "returns nil if it tries to delete a relationship that has already been deleted" do
|
|
@@ -234,8 +238,9 @@ describe Neography::Rest do
|
|
|
234
238
|
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2010', "met" => "college"})
|
|
235
239
|
existing_relationship = @neo.delete_relationship(new_relationship)
|
|
236
240
|
existing_relationship.should be_nil
|
|
237
|
-
|
|
238
|
-
|
|
241
|
+
expect {
|
|
242
|
+
existing_relationship = @neo.delete_relationship(new_relationship)
|
|
243
|
+
}.to raise_error Neography::RelationshipNotFoundException
|
|
239
244
|
end
|
|
240
245
|
end
|
|
241
246
|
|
|
@@ -346,4 +351,4 @@ describe Neography::Rest do
|
|
|
346
351
|
end
|
|
347
352
|
end
|
|
348
353
|
|
|
349
|
-
end
|
|
354
|
+
end
|
data/spec/matchers.rb
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Convenience matcher for matching JSON fields with a hash
|
|
2
|
+
RSpec::Matchers.define :json_match do |field, expected|
|
|
3
|
+
|
|
4
|
+
match do |actual|
|
|
5
|
+
expected == JSON.parse(actual[field])
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
failure_message_for_should do
|
|
9
|
+
"expected JSON in field '#{field}' to match '#{expected}'"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
description do
|
|
13
|
+
"JSON in field '#{field}' should match '#{expected.inspect}'"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Convenience matcher for matching fields in a hash
|
|
19
|
+
RSpec::Matchers.define :hash_match do |field, expected|
|
|
20
|
+
|
|
21
|
+
match do |actual|
|
|
22
|
+
expected == actual[field]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
failure_message_for_should do
|
|
26
|
+
"expected field '#{field}' to match '#{expected}'"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
description do
|
|
30
|
+
"field '#{field}' should match '#{expected.inspect}'"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Neography do
|
|
4
|
+
|
|
5
|
+
describe "::configure" do
|
|
6
|
+
|
|
7
|
+
it "returns the same configuration" do
|
|
8
|
+
Neography.configuration.should == Neography.configuration
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "returns the Config" do
|
|
12
|
+
Neography.configuration.should be_a Neography::Config
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "yields the configuration" do
|
|
16
|
+
Neography.configure do |config|
|
|
17
|
+
config.should == Neography.configuration
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'neography'
|
|
2
2
|
require 'benchmark'
|
|
3
|
+
require 'matchers'
|
|
3
4
|
|
|
4
5
|
# If you want to see more, uncomment the next few lines
|
|
5
6
|
# require 'net-http-spy'
|
|
@@ -15,4 +16,21 @@ end
|
|
|
15
16
|
|
|
16
17
|
RSpec.configure do |c|
|
|
17
18
|
c.filter_run_excluding :slow => true, :break_gremlin => true
|
|
18
|
-
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def json_content_type
|
|
23
|
+
{"Content-Type"=>"application/json"}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def error_response(attributes)
|
|
27
|
+
stub(
|
|
28
|
+
code: attributes[:code],
|
|
29
|
+
body: {
|
|
30
|
+
message: attributes[:message],
|
|
31
|
+
exception: attributes[:exception],
|
|
32
|
+
stacktrace: attributes[:stacktrace]
|
|
33
|
+
}.reject { |k,v| v.nil? }.to_json
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Neography
|
|
4
|
+
describe Config do
|
|
5
|
+
|
|
6
|
+
subject(:config)
|
|
7
|
+
|
|
8
|
+
context "defaults" do
|
|
9
|
+
|
|
10
|
+
its(:protocol) { should == 'http://' }
|
|
11
|
+
its(:server) { should == 'localhost' }
|
|
12
|
+
its(:port) { should == 7474 }
|
|
13
|
+
its(:directory) { should == '' }
|
|
14
|
+
its(:cypher_path) { should == '/cypher' }
|
|
15
|
+
its(:gremlin_path) { should == '/ext/GremlinPlugin/graphdb/execute_script' }
|
|
16
|
+
its(:log_file) { should == 'neography.log' }
|
|
17
|
+
its(:log_enabled) { should == false }
|
|
18
|
+
its(:max_threads) { should == 20 }
|
|
19
|
+
its(:authentication) { should == nil }
|
|
20
|
+
its(:username) { should == nil }
|
|
21
|
+
its(:password) { should == nil }
|
|
22
|
+
its(:parser) { should == { :parser => MultiJsonParser } }
|
|
23
|
+
|
|
24
|
+
it "has a hash representation" do
|
|
25
|
+
expected_hash = {
|
|
26
|
+
:protocol => 'http://',
|
|
27
|
+
:server => 'localhost',
|
|
28
|
+
:port => 7474,
|
|
29
|
+
:directory => '',
|
|
30
|
+
:cypher_path => '/cypher',
|
|
31
|
+
:gremlin_path => '/ext/GremlinPlugin/graphdb/execute_script',
|
|
32
|
+
:log_file => 'neography.log',
|
|
33
|
+
:log_enabled => false,
|
|
34
|
+
:max_threads => 20,
|
|
35
|
+
:authentication => nil,
|
|
36
|
+
:username => nil,
|
|
37
|
+
:password => nil,
|
|
38
|
+
:parser => { :parser => MultiJsonParser }
|
|
39
|
+
}
|
|
40
|
+
config.to_hash.should == expected_hash
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
end
|