neography-ajaycb 0.0.21

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.
Files changed (54) hide show
  1. data/.gitignore +5 -0
  2. data/.project +12 -0
  3. data/.travis.yml +1 -0
  4. data/CONTRIBUTORS +12 -0
  5. data/Gemfile +4 -0
  6. data/Gemfile.lock +39 -0
  7. data/LICENSE +19 -0
  8. data/README.rdoc +350 -0
  9. data/Rakefile +15 -0
  10. data/examples/facebook.rb +40 -0
  11. data/examples/facebook_v2.rb +25 -0
  12. data/examples/greatest.rb +43 -0
  13. data/examples/linkedin.rb +39 -0
  14. data/examples/linkedin_v2.rb +22 -0
  15. data/examples/traversal_example1.rb +65 -0
  16. data/examples/traversal_example2.rb +54 -0
  17. data/lib/neography.rb +46 -0
  18. data/lib/neography/config.rb +17 -0
  19. data/lib/neography/equal.rb +21 -0
  20. data/lib/neography/index.rb +13 -0
  21. data/lib/neography/neography.rb +10 -0
  22. data/lib/neography/node.rb +45 -0
  23. data/lib/neography/node_path.rb +29 -0
  24. data/lib/neography/node_relationship.rb +35 -0
  25. data/lib/neography/node_traverser.rb +142 -0
  26. data/lib/neography/path_traverser.rb +94 -0
  27. data/lib/neography/property.rb +53 -0
  28. data/lib/neography/property_container.rb +17 -0
  29. data/lib/neography/railtie.rb +8 -0
  30. data/lib/neography/relationship.rb +68 -0
  31. data/lib/neography/relationship_traverser.rb +80 -0
  32. data/lib/neography/rest.rb +534 -0
  33. data/lib/neography/tasks.rb +131 -0
  34. data/lib/neography/version.rb +3 -0
  35. data/neography.gemspec +29 -0
  36. data/spec/integration/authorization_spec.rb +48 -0
  37. data/spec/integration/index_spec.rb +32 -0
  38. data/spec/integration/neography_spec.rb +10 -0
  39. data/spec/integration/node_path_spec.rb +222 -0
  40. data/spec/integration/node_relationship_spec.rb +374 -0
  41. data/spec/integration/node_spec.rb +215 -0
  42. data/spec/integration/relationship_spec.rb +37 -0
  43. data/spec/integration/rest_batch_spec.rb +221 -0
  44. data/spec/integration/rest_bulk_spec.rb +106 -0
  45. data/spec/integration/rest_experimental_spec.rb +22 -0
  46. data/spec/integration/rest_gremlin_fail_spec.rb +46 -0
  47. data/spec/integration/rest_index_spec.rb +297 -0
  48. data/spec/integration/rest_node_spec.rb +232 -0
  49. data/spec/integration/rest_path_spec.rb +209 -0
  50. data/spec/integration/rest_plugin_spec.rb +67 -0
  51. data/spec/integration/rest_relationship_spec.rb +327 -0
  52. data/spec/integration/rest_traverse_spec.rb +149 -0
  53. data/spec/spec_helper.rb +18 -0
  54. metadata +222 -0
@@ -0,0 +1,232 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe Neography::Rest do
4
+ before(:each) do
5
+ @neo = Neography::Rest.new
6
+ end
7
+
8
+ describe "get_root" do
9
+ it "can get the root node" do
10
+ root_node = @neo.get_root
11
+ root_node.should have_key("self")
12
+ root_node["self"].split('/').last.should == "0"
13
+ end
14
+ end
15
+
16
+ describe "create_node" do
17
+ it "can create an empty node" do
18
+ new_node = @neo.create_node
19
+ new_node.should_not be_nil
20
+ end
21
+
22
+ it "can create a node with one property" do
23
+ new_node = @neo.create_node("name" => "Max")
24
+ new_node["data"]["name"].should == "Max"
25
+ end
26
+
27
+ it "can create a node with nil properties" do
28
+ new_node = @neo.create_node("name" => "Max", "age" => nil )
29
+ new_node["data"]["name"].should == "Max"
30
+ new_node["data"]["age"].should be_nil
31
+ end
32
+
33
+
34
+ it "can create a node with more than one property" do
35
+ new_node = @neo.create_node("age" => 31, "name" => "Max")
36
+ new_node["data"]["name"].should == "Max"
37
+ new_node["data"]["age"].should == 31
38
+ end
39
+ end
40
+
41
+ describe "get_node" do
42
+ it "can get a node that exists" do
43
+ new_node = @neo.create_node
44
+ new_node[:id] = new_node["self"].split('/').last
45
+ existing_node = @neo.get_node(new_node)
46
+ existing_node.should_not be_nil
47
+ existing_node.should have_key("self")
48
+ existing_node["self"].split('/').last.should == new_node[:id]
49
+ end
50
+
51
+ it "returns nil if it tries to get a node that does not exist" do
52
+ new_node = @neo.create_node
53
+ fake_node = new_node["self"].split('/').last.to_i + 1000
54
+ existing_node = @neo.get_node(fake_node)
55
+ existing_node.should be_nil
56
+ end
57
+ end
58
+
59
+ describe "set_node_properties" do
60
+ it "can set a node's properties" do
61
+ new_node = @neo.create_node
62
+ @neo.set_node_properties(new_node, {"weight" => 200, "eyes" => "brown"})
63
+ existing_node = @neo.get_node(new_node)
64
+ existing_node["data"]["weight"].should == 200
65
+ existing_node["data"]["eyes"].should == "brown"
66
+ end
67
+
68
+ it "it fails to set properties on a node that does not exist" do
69
+ new_node = @neo.create_node
70
+ fake_node = new_node["self"].split('/').last.to_i + 1000
71
+ @neo.set_node_properties(fake_node, {"weight" => 150, "hair" => "blonde"})
72
+ node_properties = @neo.get_node_properties(fake_node)
73
+ node_properties.should be_nil
74
+ end
75
+ end
76
+
77
+ describe "reset_node_properties" do
78
+ it "can reset a node's properties" do
79
+ new_node = @neo.create_node
80
+ @neo.set_node_properties(new_node, {"weight" => 200, "eyes" => "brown", "hair" => "black"})
81
+ @neo.reset_node_properties(new_node, {"weight" => 190, "eyes" => "blue"})
82
+ existing_node = @neo.get_node(new_node)
83
+ existing_node["data"]["weight"].should == 190
84
+ existing_node["data"]["eyes"].should == "blue"
85
+ existing_node["data"]["hair"].should be_nil
86
+ end
87
+
88
+ it "it fails to reset properties on a node that does not exist" do
89
+ new_node = @neo.create_node
90
+ fake_node = new_node["self"].split('/').last.to_i + 1000
91
+ @neo.reset_node_properties(fake_node, {"weight" => 170, "eyes" => "green"})
92
+ node_properties = @neo.get_node_properties(fake_node)
93
+ node_properties.should be_nil
94
+ end
95
+ end
96
+
97
+ describe "get_node_properties" do
98
+ it "can get all of a node's properties" do
99
+ new_node = @neo.create_node("weight" => 200, "eyes" => "brown")
100
+ node_properties = @neo.get_node_properties(new_node)
101
+ node_properties["weight"].should == 200
102
+ node_properties["eyes"].should == "brown"
103
+ end
104
+
105
+ it "can get some of a node's properties" do
106
+ new_node = @neo.create_node("weight" => 200, "eyes" => "brown", "height" => "2m")
107
+ node_properties = @neo.get_node_properties(new_node, ["weight", "height"])
108
+ node_properties["weight"].should == 200
109
+ node_properties["height"].should == "2m"
110
+ node_properties["eyes"].should be_nil
111
+ end
112
+
113
+ it "returns nil if it gets the properties on a node that does not have any" do
114
+ new_node = @neo.create_node
115
+ @neo.get_node_properties(new_node).should be_nil
116
+ end
117
+
118
+ it "returns nil if it tries to get some of the properties on a node that does not have any" do
119
+ new_node = @neo.create_node
120
+ @neo.get_node_properties(new_node, ["weight", "height"]).should be_nil
121
+ end
122
+
123
+ it "returns nil if it fails to get properties on a node that does not exist" do
124
+ new_node = @neo.create_node
125
+ fake_node = new_node["self"].split('/').last.to_i + 1000
126
+ @neo.get_node_properties(fake_node).should be_nil
127
+ end
128
+ end
129
+
130
+ describe "remove_node_properties" do
131
+ it "can remove a node's properties" do
132
+ new_node = @neo.create_node("weight" => 200, "eyes" => "brown")
133
+ @neo.remove_node_properties(new_node)
134
+ @neo.get_node_properties(new_node).should be_nil
135
+ end
136
+
137
+ it "returns nil if it fails to remove the properties of a node that does not exist" do
138
+ new_node = @neo.create_node
139
+ fake_node = new_node["self"].split('/').last.to_i + 1000
140
+ @neo.remove_node_properties(fake_node).should be_nil
141
+ end
142
+
143
+ it "can remove a specific node property" do
144
+ new_node = @neo.create_node("weight" => 200, "eyes" => "brown")
145
+ @neo.remove_node_properties(new_node, "weight")
146
+ node_properties = @neo.get_node_properties(new_node)
147
+ node_properties["weight"].should be_nil
148
+ node_properties["eyes"].should == "brown"
149
+ end
150
+
151
+ it "can remove more than one property" do
152
+ new_node = @neo.create_node("weight" => 200, "eyes" => "brown", "height" => "2m")
153
+ @neo.remove_node_properties(new_node, ["weight", "eyes"])
154
+ node_properties = @neo.get_node_properties(new_node)
155
+ node_properties["weight"].should be_nil
156
+ node_properties["eyes"].should be_nil
157
+ end
158
+ end
159
+
160
+ describe "delete_node" do
161
+ it "can delete an unrelated node" do
162
+ new_node = @neo.create_node
163
+ @neo.delete_node(new_node).should be_nil
164
+ existing_node = @neo.get_node(new_node)
165
+ existing_node.should be_nil
166
+ end
167
+
168
+ it "cannot delete a node that has relationships" do
169
+ new_node1 = @neo.create_node
170
+ new_node2 = @neo.create_node
171
+ @neo.create_relationship("friends", new_node1, new_node2)
172
+ @neo.delete_node(new_node1).should be_nil
173
+ existing_node = @neo.get_node(new_node1)
174
+ existing_node.should_not be_nil
175
+ end
176
+
177
+ it "returns nil if it tries to delete a node that does not exist" do
178
+ new_node = @neo.create_node
179
+ fake_node = new_node["self"].split('/').last.to_i + 1000
180
+ @neo.delete_node(fake_node).should be_nil
181
+ existing_node = @neo.get_node(fake_node)
182
+ existing_node.should be_nil
183
+ end
184
+
185
+ it "returns nil if it tries to delete a node that has already been deleted" do
186
+ new_node = @neo.create_node
187
+ @neo.delete_node(new_node).should be_nil
188
+ existing_node = @neo.get_node(new_node)
189
+ existing_node.should be_nil
190
+ @neo.delete_node(new_node).should be_nil
191
+ existing_node = @neo.get_node(new_node)
192
+ existing_node.should be_nil
193
+ end
194
+ end
195
+
196
+ describe "delete_node!" do
197
+ it "can delete an unrelated node" do
198
+ new_node = @neo.create_node
199
+ @neo.delete_node!(new_node).should be_nil
200
+ existing_node = @neo.get_node(new_node)
201
+ existing_node.should be_nil
202
+ end
203
+
204
+ it "can delete a node that has relationships" do
205
+ new_node1 = @neo.create_node
206
+ new_node2 = @neo.create_node
207
+ @neo.create_relationship("friends", new_node1, new_node2)
208
+ @neo.delete_node!(new_node1).should be_nil
209
+ existing_node = @neo.get_node(new_node1)
210
+ existing_node.should be_nil
211
+ end
212
+
213
+ it "returns nil if it tries to delete a node that does not exist" do
214
+ new_node = @neo.create_node
215
+ fake_node = new_node["self"].split('/').last.to_i + 1000
216
+ @neo.delete_node!(fake_node).should be_nil
217
+ existing_node = @neo.get_node(fake_node)
218
+ existing_node.should be_nil
219
+ end
220
+
221
+ it "returns nil if it tries to delete a node that has already been deleted" do
222
+ new_node = @neo.create_node
223
+ @neo.delete_node!(new_node).should be_nil
224
+ existing_node = @neo.get_node(new_node)
225
+ existing_node.should be_nil
226
+ @neo.delete_node!(new_node).should be_nil
227
+ existing_node = @neo.get_node(new_node)
228
+ existing_node.should be_nil
229
+ end
230
+ end
231
+
232
+ end
@@ -0,0 +1,209 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe Neography::Rest do
4
+ before(:each) do
5
+ @neo = Neography::Rest.new
6
+ end
7
+
8
+ describe "get path" do
9
+ it "can get a path between two nodes" do
10
+ new_node1 = @neo.create_node
11
+ new_node2 = @neo.create_node
12
+ new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2005', "met" => "college"})
13
+ path = @neo.get_path(new_node1, new_node2, {"type"=> "friends", "direction" => "out"})
14
+ path["start"].should == new_node1["self"]
15
+ path["end"].should == new_node2["self"]
16
+ path["nodes"].should == [new_node1["self"], new_node2["self"]]
17
+ end
18
+
19
+ it "can get the shortest path between two nodes" do
20
+ new_node1 = @neo.create_node
21
+ new_node2 = @neo.create_node
22
+ new_node3 = @neo.create_node
23
+ new_node4 = @neo.create_node
24
+ new_node5 = @neo.create_node
25
+ @neo.create_relationship("friends", new_node1, new_node2)
26
+ @neo.create_relationship("friends", new_node2, new_node3)
27
+ @neo.create_relationship("friends", new_node3, new_node4)
28
+ @neo.create_relationship("friends", new_node4, new_node5)
29
+ @neo.create_relationship("friends", new_node3, new_node5)
30
+ path = @neo.get_path(new_node1, new_node5, {"type"=> "friends", "direction" => "out"}, depth=3, algorithm="shortestPath")
31
+ path["start"].should == new_node1["self"]
32
+ path["end"].should == new_node5["self"]
33
+ path["nodes"].should == [new_node1["self"], new_node2["self"], new_node3["self"], new_node5["self"]]
34
+ end
35
+
36
+ it "can get a simple path between two nodes" do
37
+ new_node1 = @neo.create_node
38
+ new_node2 = @neo.create_node
39
+ new_node3 = @neo.create_node
40
+ new_node4 = @neo.create_node
41
+ new_node5 = @neo.create_node
42
+ @neo.create_relationship("friends", new_node1, new_node2)
43
+ @neo.create_relationship("friends", new_node2, new_node3)
44
+ @neo.create_relationship("friends", new_node3, new_node4)
45
+ @neo.create_relationship("friends", new_node4, new_node5)
46
+ @neo.create_relationship("friends", new_node3, new_node5)
47
+ path = @neo.get_path(new_node1, new_node5, {"type"=> "friends", "direction" => "out"}, depth=3, algorithm="simplePaths")
48
+ path["start"].should == new_node1["self"]
49
+ path["end"].should == new_node5["self"]
50
+ path["nodes"].should == [new_node1["self"], new_node2["self"], new_node3["self"], new_node5["self"]]
51
+ end
52
+
53
+ it "fails to get a path between two nodes 3 nodes apart when using max depth of 2" do
54
+ new_node1 = @neo.create_node
55
+ new_node2 = @neo.create_node
56
+ new_node3 = @neo.create_node
57
+ new_node4 = @neo.create_node
58
+ new_node5 = @neo.create_node
59
+ @neo.create_relationship("friends", new_node1, new_node2)
60
+ @neo.create_relationship("friends", new_node2, new_node3)
61
+ @neo.create_relationship("friends", new_node3, new_node4)
62
+ @neo.create_relationship("friends", new_node4, new_node5)
63
+ @neo.create_relationship("friends", new_node3, new_node5)
64
+ path = @neo.get_path(new_node1, new_node5, {"type"=> "friends", "direction" => "out"}, depth=2, algorithm="shortestPath")
65
+ path["start"].should be_nil
66
+ path["end"].should be_nil
67
+ end
68
+
69
+ it "can get a path between two nodes of a specific relationship" do
70
+ new_node1 = @neo.create_node
71
+ new_node2 = @neo.create_node
72
+ new_node3 = @neo.create_node
73
+ new_node4 = @neo.create_node
74
+ new_node5 = @neo.create_node
75
+ @neo.create_relationship("classmates", new_node1, new_node2)
76
+ @neo.create_relationship("classmates", new_node2, new_node5)
77
+ @neo.create_relationship("friends", new_node1, new_node2)
78
+ @neo.create_relationship("friends", new_node2, new_node3)
79
+ @neo.create_relationship("friends", new_node3, new_node4)
80
+ @neo.create_relationship("friends", new_node4, new_node5)
81
+ path = @neo.get_path(new_node1, new_node5, {"type"=> "friends", "direction" => "out"}, depth=4, algorithm="shortestPath")
82
+ path["start"].should == new_node1["self"]
83
+ path["end"].should == new_node5["self"]
84
+ path["nodes"].should == [new_node1["self"], new_node2["self"], new_node3["self"], new_node4["self"], new_node5["self"]]
85
+ end
86
+ end
87
+
88
+ describe "get paths" do
89
+ it "can get the shortest paths between two nodes" do
90
+ new_node1 = @neo.create_node
91
+ new_node2 = @neo.create_node
92
+ new_node3 = @neo.create_node
93
+ new_node4 = @neo.create_node
94
+ new_node5 = @neo.create_node
95
+ @neo.create_relationship("friends", new_node1, new_node2)
96
+ @neo.create_relationship("friends", new_node2, new_node5)
97
+ @neo.create_relationship("friends", new_node1, new_node3)
98
+ @neo.create_relationship("friends", new_node3, new_node4)
99
+ @neo.create_relationship("friends", new_node4, new_node5)
100
+ @neo.create_relationship("friends", new_node3, new_node5)
101
+ paths = @neo.get_paths(new_node1, new_node5, {"type"=> "friends", "direction" => "out"}, depth=4, algorithm="shortestPath")
102
+ paths.length.should == 2
103
+ paths[0]["length"].should == 2
104
+ paths[0]["start"].should == new_node1["self"]
105
+ paths[0]["end"].should == new_node5["self"]
106
+ paths[1]["length"].should == 2
107
+ paths[1]["start"].should == new_node1["self"]
108
+ paths[1]["end"].should == new_node5["self"]
109
+ end
110
+
111
+ it "can get all paths between two nodes" do
112
+ new_node1 = @neo.create_node
113
+ new_node2 = @neo.create_node
114
+ new_node3 = @neo.create_node
115
+ new_node4 = @neo.create_node
116
+ new_node5 = @neo.create_node
117
+ @neo.create_relationship("friends", new_node1, new_node2)
118
+ @neo.create_relationship("friends", new_node2, new_node5)
119
+ @neo.create_relationship("friends", new_node1, new_node3)
120
+ @neo.create_relationship("friends", new_node3, new_node4)
121
+ @neo.create_relationship("friends", new_node4, new_node5)
122
+ @neo.create_relationship("friends", new_node3, new_node5)
123
+ paths = @neo.get_paths(new_node1, new_node5, {"type"=> "friends", "direction" => "out"}, depth=4, algorithm="allPaths")
124
+ paths.length.should == 3
125
+ paths[0]["length"].should == 2
126
+ paths[0]["start"].should == new_node1["self"]
127
+ paths[0]["end"].should == new_node5["self"]
128
+ paths[1]["length"].should == 3
129
+ paths[1]["start"].should == new_node1["self"]
130
+ paths[1]["end"].should == new_node5["self"]
131
+ paths[2]["length"].should == 2
132
+ paths[2]["start"].should == new_node1["self"]
133
+ paths[2]["end"].should == new_node5["self"]
134
+ end
135
+
136
+ it "can get all simple paths between two nodes" do
137
+ new_node1 = @neo.create_node
138
+ new_node2 = @neo.create_node
139
+ new_node3 = @neo.create_node
140
+ new_node4 = @neo.create_node
141
+ new_node5 = @neo.create_node
142
+ @neo.create_relationship("friends", new_node1, new_node2)
143
+ @neo.create_relationship("friends", new_node2, new_node1)
144
+ @neo.create_relationship("friends", new_node2, new_node5)
145
+ @neo.create_relationship("friends", new_node1, new_node3)
146
+ @neo.create_relationship("friends", new_node3, new_node4)
147
+ @neo.create_relationship("friends", new_node4, new_node5)
148
+ @neo.create_relationship("friends", new_node3, new_node5)
149
+ paths = @neo.get_paths(new_node1, new_node5, {"type"=> "friends", "direction" => "out"}, depth=4, algorithm="allSimplePaths")
150
+ paths.length.should == 3
151
+ paths[0]["length"].should == 2
152
+ paths[0]["start"].should == new_node1["self"]
153
+ paths[0]["end"].should == new_node5["self"]
154
+ paths[1]["length"].should == 3
155
+ paths[1]["start"].should == new_node1["self"]
156
+ paths[1]["end"].should == new_node5["self"]
157
+ paths[2]["length"].should == 2
158
+ paths[2]["start"].should == new_node1["self"]
159
+ paths[2]["end"].should == new_node5["self"]
160
+ end
161
+
162
+ it "can get paths between two nodes of max depth 2" do
163
+ new_node1 = @neo.create_node
164
+ new_node2 = @neo.create_node
165
+ new_node3 = @neo.create_node
166
+ new_node4 = @neo.create_node
167
+ new_node5 = @neo.create_node
168
+ @neo.create_relationship("friends", new_node1, new_node2)
169
+ @neo.create_relationship("friends", new_node2, new_node5)
170
+ @neo.create_relationship("friends", new_node1, new_node3)
171
+ @neo.create_relationship("friends", new_node3, new_node4)
172
+ @neo.create_relationship("friends", new_node4, new_node5)
173
+ @neo.create_relationship("friends", new_node3, new_node5)
174
+ paths = @neo.get_paths(new_node1, new_node5, {"type"=> "friends", "direction" => "out"}, depth=2, algorithm="allPaths")
175
+ paths.length.should == 2
176
+ paths[0]["length"].should == 2
177
+ paths[0]["start"].should == new_node1["self"]
178
+ paths[0]["end"].should == new_node5["self"]
179
+ paths[1]["length"].should == 2
180
+ paths[1]["start"].should == new_node1["self"]
181
+ paths[1]["end"].should == new_node5["self"] end
182
+
183
+ it "can get paths between two nodes of a specific relationship" do
184
+ new_node1 = @neo.create_node
185
+ new_node2 = @neo.create_node
186
+ new_node3 = @neo.create_node
187
+ new_node4 = @neo.create_node
188
+ new_node5 = @neo.create_node
189
+ @neo.create_relationship("classmates", new_node1, new_node2)
190
+ @neo.create_relationship("classmates", new_node2, new_node5)
191
+ @neo.create_relationship("friends", new_node1, new_node2)
192
+ @neo.create_relationship("friends", new_node2, new_node3)
193
+ @neo.create_relationship("friends", new_node3, new_node4)
194
+ @neo.create_relationship("friends", new_node4, new_node5)
195
+ @neo.create_relationship("classmates", new_node1, new_node3)
196
+ @neo.create_relationship("classmates", new_node3, new_node5)
197
+ paths = @neo.get_paths(new_node1, new_node5, {"type"=> "classmates", "direction" => "out"}, depth=4, algorithm="allPaths")
198
+ paths[0]["length"].should == 2
199
+ paths[0]["start"].should == new_node1["self"]
200
+ paths[0]["end"].should == new_node5["self"]
201
+ paths[1]["length"].should == 2
202
+ paths[1]["start"].should == new_node1["self"]
203
+ paths[1]["end"].should == new_node5["self"]
204
+ end
205
+
206
+ end
207
+
208
+
209
+ end
@@ -0,0 +1,67 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe Neography::Rest do
4
+ before(:each) do
5
+ @neo = Neography::Rest.new
6
+ end
7
+
8
+ describe "execute gremlin script" do
9
+ it "can get the root node id" do
10
+ root_node = @neo.execute_script("g.v(0)")
11
+ root_node.should have_key("self")
12
+ root_node["self"].split('/').last.should == "0"
13
+ end
14
+
15
+ it "can get the a node" do
16
+ new_node = @neo.create_node
17
+ id = new_node["self"].split('/').last
18
+ existing_node = @neo.execute_script("g.v(#{id})")
19
+ existing_node.should_not be_nil
20
+ existing_node.should have_key("self")
21
+ existing_node["self"].split('/').last.should == id
22
+ end
23
+
24
+ it "can get the a node with a variable" do
25
+ new_node = @neo.create_node
26
+ id = new_node["self"].split('/').last
27
+ existing_node = @neo.execute_script("g.v(id)", {:id => id.to_i})
28
+ existing_node.should_not be_nil
29
+ existing_node.should have_key("self")
30
+ existing_node["self"].split('/').last.should == id
31
+ end
32
+ end
33
+
34
+ describe "execute cypher query" do
35
+ it "can get the root node id" do
36
+ root_node = @neo.execute_query("start n=node(0) return n")
37
+ root_node.should have_key("data")
38
+ root_node.should have_key("columns")
39
+ root_node["data"][0][0].should have_key("self")
40
+ root_node["data"][0][0]["self"].split('/').last.should == "0"
41
+ end
42
+
43
+ it "can get the a node" do
44
+ new_node = @neo.create_node
45
+ id = new_node["self"].split('/').last
46
+ existing_node = @neo.execute_query("start n=node(#{id}) return n")
47
+ existing_node.should_not be_nil
48
+ existing_node.should have_key("data")
49
+ existing_node.should have_key("columns")
50
+ existing_node["data"][0][0].should have_key("self")
51
+ existing_node["data"][0][0]["self"].split('/').last.should == id
52
+ end
53
+
54
+ it "can get the a node with a variable" do
55
+ new_node = @neo.create_node
56
+ id = new_node["self"].split('/').last
57
+ existing_node = @neo.execute_query("start n=node({id}) return n", {:id => id.to_i})
58
+ existing_node.should_not be_nil
59
+ existing_node.should have_key("data")
60
+ existing_node.should have_key("columns")
61
+ existing_node["data"][0][0].should have_key("self")
62
+ existing_node["data"][0][0]["self"].split('/').last.should == id
63
+ end
64
+
65
+ end
66
+
67
+ end