neography 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CHANGELOG.md +939 -0
- data/Guardfile +14 -0
- data/README.md +16 -14
- data/lib/neography/connection.rb +1 -0
- data/lib/neography/errors.rb +3 -0
- data/lib/neography/node.rb +21 -25
- data/lib/neography/property.rb +60 -11
- data/lib/neography/property_container.rb +5 -6
- data/lib/neography/rest/batch.rb +10 -0
- data/lib/neography/rest/node_properties.rb +1 -1
- data/lib/neography/version.rb +1 -1
- data/neography.gemspec +4 -2
- data/spec/integration/authorization_spec.rb +4 -4
- data/spec/integration/broken_spatial_spec.rb +6 -6
- data/spec/integration/index_spec.rb +6 -6
- data/spec/integration/neography_spec.rb +1 -1
- data/spec/integration/node_encoding_spec.rb +19 -19
- data/spec/integration/node_path_spec.rb +36 -36
- data/spec/integration/node_relationship_spec.rb +84 -84
- data/spec/integration/node_spec.rb +50 -50
- data/spec/integration/parsing_spec.rb +2 -2
- data/spec/integration/relationship_spec.rb +10 -10
- data/spec/integration/rest_batch_no_streaming_spec.rb +6 -6
- data/spec/integration/rest_batch_spec.rb +209 -188
- data/spec/integration/rest_batch_streaming_spec.rb +8 -8
- data/spec/integration/rest_bulk_spec.rb +23 -23
- data/spec/integration/rest_constraints_spec.rb +17 -17
- data/spec/integration/rest_experimental_spec.rb +2 -2
- data/spec/integration/rest_gremlin_fail_spec.rb +4 -4
- data/spec/integration/rest_header_spec.rb +3 -2
- data/spec/integration/rest_index_spec.rb +76 -76
- data/spec/integration/rest_labels_spec.rb +13 -13
- data/spec/integration/rest_node_spec.rb +50 -50
- data/spec/integration/rest_other_node_relationship_spec.rb +50 -50
- data/spec/integration/rest_path_spec.rb +55 -55
- data/spec/integration/rest_plugin_spec.rb +59 -59
- data/spec/integration/rest_relationship_spec.rb +77 -77
- data/spec/integration/rest_relationship_types_spec.rb +2 -2
- data/spec/integration/rest_schema_index_spec.rb +6 -6
- data/spec/integration/rest_spatial_spec.rb +50 -50
- data/spec/integration/rest_transaction_spec.rb +67 -67
- data/spec/integration/rest_traverse_spec.rb +40 -40
- data/spec/integration/unmanaged_spec.rb +3 -3
- data/spec/matchers.rb +2 -2
- data/spec/neography_spec.rb +3 -3
- data/spec/spec_helper.rb +2 -2
- data/spec/unit/config_spec.rb +95 -20
- data/spec/unit/connection_spec.rb +40 -40
- data/spec/unit/node_spec.rb +12 -12
- data/spec/unit/properties_spec.rb +174 -29
- data/spec/unit/relationship_spec.rb +16 -16
- data/spec/unit/rest/batch_spec.rb +23 -23
- data/spec/unit/rest/clean_spec.rb +1 -1
- data/spec/unit/rest/constraints_spec.rb +6 -6
- data/spec/unit/rest/cypher_spec.rb +1 -1
- data/spec/unit/rest/extensions_spec.rb +2 -2
- data/spec/unit/rest/gremlin_spec.rb +3 -3
- data/spec/unit/rest/helpers_spec.rb +19 -19
- data/spec/unit/rest/labels_spec.rb +10 -10
- data/spec/unit/rest/node_auto_indexes_spec.rb +13 -13
- data/spec/unit/rest/node_indexes_spec.rb +22 -22
- data/spec/unit/rest/node_paths_spec.rb +7 -7
- data/spec/unit/rest/node_properties_spec.rb +15 -15
- data/spec/unit/rest/node_relationships_spec.rb +10 -10
- data/spec/unit/rest/node_traversal_spec.rb +1 -1
- data/spec/unit/rest/nodes_spec.rb +32 -32
- data/spec/unit/rest/relationship_auto_indexes_spec.rb +12 -12
- data/spec/unit/rest/relationship_indexes_spec.rb +21 -21
- data/spec/unit/rest/relationship_properties_spec.rb +15 -15
- data/spec/unit/rest/relationship_types_spec.rb +1 -1
- data/spec/unit/rest/relationships_spec.rb +2 -2
- data/spec/unit/rest/schema_index_spec.rb +3 -3
- data/spec/unit/rest/transactions_spec.rb +4 -4
- metadata +32 -3
- data/ChangeLog +0 -658
@@ -12,7 +12,7 @@ module Neography
|
|
12
12
|
{ "id" => 1, "method" => "GET", "to" => "/node/bar" }
|
13
13
|
]
|
14
14
|
|
15
|
-
subject.connection.
|
15
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
16
16
|
subject.batch [:get_node, "foo"], [:get_node, "bar"]
|
17
17
|
end
|
18
18
|
|
@@ -22,7 +22,7 @@ module Neography
|
|
22
22
|
{ "id" => 1, "method" => "GET", "to" => "/node/bar" }
|
23
23
|
]
|
24
24
|
|
25
|
-
subject.connection.
|
25
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
26
26
|
subject.batch ["get_node", "foo"], [:get_node, "bar"]
|
27
27
|
end
|
28
28
|
|
@@ -32,7 +32,7 @@ module Neography
|
|
32
32
|
{ "id" => 1, "method" => "POST", "to" => "/node", "body" => { "baz" => "qux" } }
|
33
33
|
]
|
34
34
|
|
35
|
-
subject.connection.
|
35
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
36
36
|
subject.batch [:create_node, { "foo" => "bar" }], [:create_node, { "baz" => "qux" }]
|
37
37
|
end
|
38
38
|
|
@@ -42,7 +42,7 @@ module Neography
|
|
42
42
|
{ "id" => 1, "method" => "DELETE", "to" => "/node/bar" }
|
43
43
|
]
|
44
44
|
|
45
|
-
subject.connection.
|
45
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
46
46
|
subject.batch [:delete_node, "foo"], [:delete_node, "bar"]
|
47
47
|
end
|
48
48
|
|
@@ -52,7 +52,7 @@ module Neography
|
|
52
52
|
{ "id" => 1, "method" => "POST", "to" => "/index/node/quux?unique", "body" => { "key" => "corge", "value" => "grault", "properties" => "garply" } }
|
53
53
|
]
|
54
54
|
|
55
|
-
subject.connection.
|
55
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
56
56
|
subject.batch [:create_unique_node, "foo", "bar", "baz", "qux" ],
|
57
57
|
[:create_unique_node, "quux", "corge", "grault", "garply"]
|
58
58
|
end
|
@@ -63,7 +63,7 @@ module Neography
|
|
63
63
|
{ "id" => 1, "method" => "POST", "to" => "/index/node/quux", "body" => { "uri" => "{0}", "key" => "corge", "value" => "grault" } }
|
64
64
|
]
|
65
65
|
|
66
|
-
subject.connection.
|
66
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
67
67
|
subject.batch [:add_node_to_index, "foo", "bar", "baz", "qux" ],
|
68
68
|
[:add_node_to_index, "quux", "corge", "grault", "{0}"]
|
69
69
|
end
|
@@ -74,7 +74,7 @@ module Neography
|
|
74
74
|
{ "id" => 1, "method" => "GET", "to" => "/index/node/qux/quux/corge" }
|
75
75
|
]
|
76
76
|
|
77
|
-
subject.connection.
|
77
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
78
78
|
subject.batch [:get_node_index, "foo", "bar", "baz" ],
|
79
79
|
[:get_node_index, "qux", "quux", "corge" ]
|
80
80
|
end
|
@@ -86,7 +86,7 @@ module Neography
|
|
86
86
|
{ "id" => 2, "method" => "DELETE", "to" => "/index/node/index3/key3/value3/id3" }
|
87
87
|
]
|
88
88
|
|
89
|
-
subject.connection.
|
89
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
90
90
|
subject.batch [:remove_node_from_index, "index1", "id1", ],
|
91
91
|
[:remove_node_from_index, "index2", "key2", "id2" ],
|
92
92
|
[:remove_node_from_index, "index3", "key3", "value3", "id3" ]
|
@@ -98,7 +98,7 @@ module Neography
|
|
98
98
|
{ "id" => 1, "method" => "PUT", "to" => "/node/index2/properties/key2", "body" => "value2" }
|
99
99
|
]
|
100
100
|
|
101
|
-
subject.connection.
|
101
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
102
102
|
subject.batch [:set_node_property, "index1", { "key1" => "value1" } ],
|
103
103
|
[:set_node_property, "index2", { "key2" => "value2" } ]
|
104
104
|
end
|
@@ -109,7 +109,7 @@ module Neography
|
|
109
109
|
{ "id" => 1, "method" => "PUT", "to" => "/node/index2/properties", "body" => { "key2" => "value2" } }
|
110
110
|
]
|
111
111
|
|
112
|
-
subject.connection.
|
112
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
113
113
|
subject.batch [:reset_node_properties, "index1", { "key1" => "value1" } ],
|
114
114
|
[:reset_node_properties, "index2", { "key2" => "value2" } ]
|
115
115
|
end
|
@@ -119,7 +119,7 @@ module Neography
|
|
119
119
|
{ "id" => 0, "method" => "POST", "to" => "{0}/labels", "body" => "foo" },
|
120
120
|
{ "id" => 1, "method" => "POST", "to" => "{0}/labels", "body" => "bar" },
|
121
121
|
]
|
122
|
-
subject.connection.
|
122
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
123
123
|
subject.batch [:add_label, "{0}", "foo"],
|
124
124
|
[:add_label, "{0}", "bar"]
|
125
125
|
end
|
@@ -130,7 +130,7 @@ module Neography
|
|
130
130
|
{ "id" => 1, "method" => "GET", "to" => "/node/id2/relationships/all" }
|
131
131
|
]
|
132
132
|
|
133
|
-
subject.connection.
|
133
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
134
134
|
subject.batch [:get_node_relationships, "id1", "direction1" ],
|
135
135
|
[:get_node_relationships, "id2" ]
|
136
136
|
end
|
@@ -141,7 +141,7 @@ module Neography
|
|
141
141
|
{ "id" => 1, "method" => "GET", "to" => "/relationship/bar" }
|
142
142
|
]
|
143
143
|
|
144
|
-
subject.connection.
|
144
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
145
145
|
subject.batch [:get_relationship, "foo"], [:get_relationship, "bar"]
|
146
146
|
end
|
147
147
|
|
@@ -151,7 +151,7 @@ module Neography
|
|
151
151
|
{ "id" => 1, "method" => "POST", "to" => "{0}/relationships", "body" => { "to" => "{1}", "type" => "type2", "data" => "data2" } }
|
152
152
|
]
|
153
153
|
|
154
|
-
subject.connection.
|
154
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
155
155
|
subject.batch [:create_relationship, "type1", "from1", "to1", "data1" ],
|
156
156
|
[:create_relationship, "type2", "{0}", "{1}", "data2" ]
|
157
157
|
end
|
@@ -162,7 +162,7 @@ module Neography
|
|
162
162
|
{ "id" => 1, "method" => "DELETE", "to" => "/relationship/bar" }
|
163
163
|
]
|
164
164
|
|
165
|
-
subject.connection.
|
165
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
166
166
|
subject.batch [:delete_relationship, "foo"], [:delete_relationship, "bar"]
|
167
167
|
end
|
168
168
|
|
@@ -172,7 +172,7 @@ module Neography
|
|
172
172
|
{ "id" => 1, "method" => "POST", "to" => "/index/relationship/index2?unique", "body" => { "key" => "key2", "value" => "value2", "type" => "type2", "start" => "{0}", "end" => "{1}", "properties" => "properties" } }
|
173
173
|
]
|
174
174
|
|
175
|
-
subject.connection.
|
175
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
176
176
|
subject.batch [:create_unique_relationship, "index1", "key1", "value1", "type1", "node1", "node2","properties" ],
|
177
177
|
[:create_unique_relationship, "index2", "key2", "value2", "type2", "{0}", "{1}", "properties" ]
|
178
178
|
end
|
@@ -183,7 +183,7 @@ module Neography
|
|
183
183
|
{ "id" => 1, "method" => "POST", "to" => "/index/relationship/index2", "body" => { "uri" => "{0}", "key" => "key2", "value" => "value2" } }
|
184
184
|
]
|
185
185
|
|
186
|
-
subject.connection.
|
186
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
187
187
|
subject.batch [:add_relationship_to_index, "index1", "key1", "value1", "rel1" ],
|
188
188
|
[:add_relationship_to_index, "index2", "key2", "value2", "{0}"]
|
189
189
|
end
|
@@ -194,7 +194,7 @@ module Neography
|
|
194
194
|
{ "id" => 1, "method" => "GET", "to" => "/index/relationship/qux/quux/corge" }
|
195
195
|
]
|
196
196
|
|
197
|
-
subject.connection.
|
197
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
198
198
|
subject.batch [:get_relationship_index, "foo", "bar", "baz" ],
|
199
199
|
[:get_relationship_index, "qux", "quux", "corge" ]
|
200
200
|
end
|
@@ -206,7 +206,7 @@ module Neography
|
|
206
206
|
{ "id" => 2, "method" => "DELETE", "to" => "/index/relationship/index3/key3/value3/id3" }
|
207
207
|
]
|
208
208
|
|
209
|
-
subject.connection.
|
209
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
210
210
|
subject.batch [:remove_relationship_from_index, "index1", "id1", ],
|
211
211
|
[:remove_relationship_from_index, "index2", "key2", "id2" ],
|
212
212
|
[:remove_relationship_from_index, "index3", "key3", "value3", "id3" ]
|
@@ -218,7 +218,7 @@ module Neography
|
|
218
218
|
{ "id" => 1, "method" => "PUT", "to" => "/relationship/index2/properties/key2", "body" => "value2" }
|
219
219
|
]
|
220
220
|
|
221
|
-
subject.connection.
|
221
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
222
222
|
subject.batch [:set_relationship_property, "index1", { "key1" => "value1" } ],
|
223
223
|
[:set_relationship_property, "index2", { "key2" => "value2" } ]
|
224
224
|
end
|
@@ -229,7 +229,7 @@ module Neography
|
|
229
229
|
{ "id" => 1, "method" => "PUT", "to" => "{0}/properties", "body" => { "key2" => "value2" } }
|
230
230
|
]
|
231
231
|
|
232
|
-
subject.connection.
|
232
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
233
233
|
subject.batch [:reset_relationship_properties, "index1", { "key1" => "value1" } ],
|
234
234
|
[:reset_relationship_properties, "{0}", { "key2" => "value2" } ]
|
235
235
|
end
|
@@ -240,7 +240,7 @@ module Neography
|
|
240
240
|
{ "id" => 1, "method" => "POST", "to" => "/ext/GremlinPlugin/graphdb/execute_script", "body" => { "script" => "script2", "params" => "params2" } }
|
241
241
|
]
|
242
242
|
|
243
|
-
subject.connection.
|
243
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
244
244
|
subject.batch [:execute_script, "script1", "params1"],
|
245
245
|
[:execute_script, "script2", "params2"]
|
246
246
|
end
|
@@ -251,7 +251,7 @@ module Neography
|
|
251
251
|
{ "id" => 1, "method" => "POST", "to" => "/cypher", "body" => { "query" => "query2" } }
|
252
252
|
]
|
253
253
|
|
254
|
-
subject.connection.
|
254
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
255
255
|
subject.batch [:execute_query, "query1", "params1"],
|
256
256
|
[:execute_query, "query2" ]
|
257
257
|
end
|
@@ -7,7 +7,7 @@ module Neography
|
|
7
7
|
subject { Neography::Rest.new }
|
8
8
|
|
9
9
|
it "cleans the database" do
|
10
|
-
subject.connection.
|
10
|
+
expect(subject.connection).to receive(:delete).with("/cleandb/secret-key")
|
11
11
|
subject.clean_database("yes_i_really_want_to_clean_the_database")
|
12
12
|
end
|
13
13
|
|
@@ -7,12 +7,12 @@ module Neography
|
|
7
7
|
subject { Neography::Rest.new }
|
8
8
|
|
9
9
|
it "list constraints" do
|
10
|
-
subject.connection.
|
10
|
+
expect(subject.connection).to receive(:get).with("/schema/constraint/")
|
11
11
|
subject.get_constraints
|
12
12
|
end
|
13
13
|
|
14
14
|
it "get constraints for a label" do
|
15
|
-
subject.connection.
|
15
|
+
expect(subject.connection).to receive(:get).with("/schema/constraint/label")
|
16
16
|
subject.get_constraints("label")
|
17
17
|
end
|
18
18
|
|
@@ -21,22 +21,22 @@ module Neography
|
|
21
21
|
:body => '{"property_keys":["property"]}',
|
22
22
|
:headers => json_content_type
|
23
23
|
}
|
24
|
-
subject.connection.
|
24
|
+
expect(subject.connection).to receive(:post).with("/schema/constraint/label/uniqueness/", options)
|
25
25
|
subject.create_unique_constraint("label", "property")
|
26
26
|
end
|
27
27
|
|
28
28
|
it "get unique constraints for a label" do
|
29
|
-
subject.connection.
|
29
|
+
expect(subject.connection).to receive(:get).with("/schema/constraint/label/uniqueness/")
|
30
30
|
subject.get_uniqueness("label")
|
31
31
|
end
|
32
32
|
|
33
33
|
it "get a specific unique constraint for a label" do
|
34
|
-
subject.connection.
|
34
|
+
expect(subject.connection).to receive(:get).with("/schema/constraint/label/uniqueness/property")
|
35
35
|
subject.get_unique_constraint("label", "property")
|
36
36
|
end
|
37
37
|
|
38
38
|
it "can delete a constraint for a label" do
|
39
|
-
subject.connection.
|
39
|
+
expect(subject.connection).to receive(:delete).with("/schema/constraint/label/uniqueness/property")
|
40
40
|
subject.drop_constraint("label","property")
|
41
41
|
end
|
42
42
|
|
@@ -11,7 +11,7 @@ module Neography
|
|
11
11
|
:body=>"{\"query\":\"SOME QUERY\",\"params\":{\"foo\":\"bar\",\"baz\":\"qux\"}}",
|
12
12
|
:headers=>{"Content-Type"=>"application/json", "Accept"=>"application/json;stream=true;charset=UTF-8"}
|
13
13
|
}
|
14
|
-
subject.connection.
|
14
|
+
expect(subject.connection).to receive(:post).with("/cypher", options)
|
15
15
|
subject.execute_query("SOME QUERY", { :foo => "bar", :baz => "qux" })
|
16
16
|
end
|
17
17
|
|
@@ -9,7 +9,7 @@ module Neography
|
|
9
9
|
it "executes an extensions get query" do
|
10
10
|
path = "/unmanaged_extension/test"
|
11
11
|
|
12
|
-
subject.connection.
|
12
|
+
expect(subject.connection).to receive(:get).with(path)
|
13
13
|
subject.get_extension("/unmanaged_extension/test")
|
14
14
|
end
|
15
15
|
|
@@ -19,7 +19,7 @@ module Neography
|
|
19
19
|
:body=>"{\"foo\":\"bar\",\"baz\":\"qux\"}",
|
20
20
|
:headers=>{"Content-Type"=>"application/json", "Accept"=>"application/json;stream=true"}
|
21
21
|
}
|
22
|
-
subject.connection.
|
22
|
+
expect(subject.connection).to receive(:post).with(path, options)
|
23
23
|
subject.post_extension("/unmanaged_extension/test", { :foo => "bar", :baz => "qux" })
|
24
24
|
end
|
25
25
|
|
@@ -11,13 +11,13 @@ module Neography
|
|
11
11
|
:body=>"{\"script\":\"SOME SCRIPT\",\"params\":{\"foo\":\"bar\",\"baz\":\"qux\"}}",
|
12
12
|
:headers=>{"Content-Type"=>"application/json"}
|
13
13
|
}
|
14
|
-
subject.connection.
|
14
|
+
expect(subject.connection).to receive(:post).with("/ext/GremlinPlugin/graphdb/execute_script", options)
|
15
15
|
subject.execute_script("SOME SCRIPT", { :foo => "bar", :baz => "qux" })
|
16
16
|
end
|
17
17
|
|
18
18
|
it "returns nil if script result is null" do
|
19
|
-
subject.connection.
|
20
|
-
subject.execute_script("", {}).
|
19
|
+
allow(subject.connection).to receive(:post).and_return("null")
|
20
|
+
expect(subject.execute_script("", {})).to be_nil
|
21
21
|
end
|
22
22
|
|
23
23
|
end
|
@@ -10,18 +10,18 @@ module Neography
|
|
10
10
|
|
11
11
|
[ :incoming, "incoming", :in, "in" ].each do |direction|
|
12
12
|
it "parses 'in' direction" do
|
13
|
-
subject.parse_direction(direction).
|
13
|
+
expect(subject.parse_direction(direction)).to eq("in")
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
[ :outgoing, "outgoing", :out, "out" ].each do |direction|
|
18
18
|
it "parses 'out' direction" do
|
19
|
-
subject.parse_direction(direction).
|
19
|
+
expect(subject.parse_direction(direction)).to eq("out")
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
it "parses 'all' direction by default" do
|
24
|
-
subject.parse_direction("foo").
|
24
|
+
expect(subject.parse_direction("foo")).to eq("all")
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
@@ -32,88 +32,88 @@ context "options" do
|
|
32
32
|
context "order" do
|
33
33
|
[ :breadth, "breadth", "breadth first", "breadthFirst", :wide, "wide" ].each do |order|
|
34
34
|
it "parses breadth first" do
|
35
|
-
subject.send(:parse_order, order).
|
35
|
+
expect(subject.send(:parse_order, order)).to eq("breadth first")
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
it "parses depth first by default" do
|
40
|
-
subject.send(:parse_order, "foo").
|
40
|
+
expect(subject.send(:parse_order, "foo")).to eq("depth first")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
context "uniqueness" do
|
45
45
|
[ :nodeglobal, "node global", "nodeglobal", "node_global" ].each do |order|
|
46
46
|
it "parses node global" do
|
47
|
-
subject.send(:parse_uniqueness, order).
|
47
|
+
expect(subject.send(:parse_uniqueness, order)).to eq("node global")
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
[ :nodepath, "node path", "nodepath", "node_path" ].each do |order|
|
52
52
|
it "parses node path" do
|
53
|
-
subject.send(:parse_uniqueness, order).
|
53
|
+
expect(subject.send(:parse_uniqueness, order)).to eq("node path")
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
[ :noderecent, "node recent", "noderecent", "node_recent" ].each do |order|
|
58
58
|
it "parses node recent" do
|
59
|
-
subject.send(:parse_uniqueness, order).
|
59
|
+
expect(subject.send(:parse_uniqueness, order)).to eq("node recent")
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
[ :relationshipglobal, "relationship global", "relationshipglobal", "relationship_global" ].each do |order|
|
64
64
|
it "parses relationship global" do
|
65
|
-
subject.send(:parse_uniqueness, order).
|
65
|
+
expect(subject.send(:parse_uniqueness, order)).to eq("relationship global")
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
[ :relationshippath, "relationship path", "relationshippath", "relationship_path" ].each do |order|
|
70
70
|
it "parses relationship path" do
|
71
|
-
subject.send(:parse_uniqueness, order).
|
71
|
+
expect(subject.send(:parse_uniqueness, order)).to eq("relationship path")
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
75
|
[ :relationshiprecent, "relationship recent", "relationshiprecent", "relationship_recent" ].each do |order|
|
76
76
|
it "parses relationship recent" do
|
77
|
-
subject.send(:parse_uniqueness, order).
|
77
|
+
expect(subject.send(:parse_uniqueness, order)).to eq("relationship recent")
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
it "parses none by default" do
|
82
|
-
subject.send(:parse_uniqueness, "foo").
|
82
|
+
expect(subject.send(:parse_uniqueness, "foo")).to eq("none")
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
86
|
context "depth" do
|
87
87
|
it "parses nil as nil" do
|
88
|
-
subject.send(:parse_depth, nil).
|
88
|
+
expect(subject.send(:parse_depth, nil)).to be_nil
|
89
89
|
end
|
90
90
|
it "parses 0 as 1" do
|
91
|
-
subject.send(:parse_depth, "0").
|
91
|
+
expect(subject.send(:parse_depth, "0")).to eq(1)
|
92
92
|
end
|
93
93
|
it "parses integers" do
|
94
|
-
subject.send(:parse_depth, "42").
|
94
|
+
expect(subject.send(:parse_depth, "42")).to eq(42)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
98
|
context "type" do
|
99
99
|
[ :relationship, "relationship", :relationships, "relationships" ].each do |type|
|
100
100
|
it "parses relationship" do
|
101
|
-
subject.send(:parse_type, type).
|
101
|
+
expect(subject.send(:parse_type, type)).to eq("relationship")
|
102
102
|
end
|
103
103
|
end
|
104
104
|
[ :path, "path", :paths, "paths" ].each do |type|
|
105
105
|
it "parses path" do
|
106
|
-
subject.send(:parse_type, type).
|
106
|
+
expect(subject.send(:parse_type, type)).to eq("path")
|
107
107
|
end
|
108
108
|
end
|
109
109
|
[ :fullpath, "fullpath", :fullpaths, "fullpaths" ].each do |type|
|
110
110
|
it "parses fullpath" do
|
111
|
-
subject.send(:parse_type, type).
|
111
|
+
expect(subject.send(:parse_type, type)).to eq("fullpath")
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
115
|
it "parses node by default" do
|
116
|
-
subject.send(:parse_type, "foo").
|
116
|
+
expect(subject.send(:parse_type, "foo")).to eq("node")
|
117
117
|
end
|
118
118
|
end
|
119
119
|
end
|
@@ -7,27 +7,27 @@ module Neography
|
|
7
7
|
subject { Neography::Rest.new }
|
8
8
|
|
9
9
|
it "list node labels" do
|
10
|
-
subject.connection.
|
10
|
+
expect(subject.connection).to receive(:get).with("/labels")
|
11
11
|
subject.list_labels
|
12
12
|
end
|
13
13
|
|
14
14
|
it "get labels for node" do
|
15
|
-
subject.connection.
|
15
|
+
expect(subject.connection).to receive(:get).with("/node/0/labels")
|
16
16
|
subject.get_node_labels(0)
|
17
17
|
end
|
18
18
|
|
19
19
|
it "get nodes for labels" do
|
20
|
-
subject.connection.
|
20
|
+
expect(subject.connection).to receive(:get).with("/label/person/nodes")
|
21
21
|
subject.get_nodes_labeled("person")
|
22
22
|
end
|
23
23
|
|
24
24
|
it "find nodes for labels and property string" do
|
25
|
-
subject.connection.
|
25
|
+
expect(subject.connection).to receive(:get).with("/label/person/nodes?name=%22max%22")
|
26
26
|
subject.find_nodes_labeled("person", {:name => "max"})
|
27
27
|
end
|
28
28
|
|
29
29
|
it "find nodes for labels and property integer" do
|
30
|
-
subject.connection.
|
30
|
+
expect(subject.connection).to receive(:get).with("/label/person/nodes?age=26")
|
31
31
|
subject.find_nodes_labeled("person", {:age => 26})
|
32
32
|
end
|
33
33
|
|
@@ -36,7 +36,7 @@ module Neography
|
|
36
36
|
:body => '["Actor"]',
|
37
37
|
:headers => json_content_type
|
38
38
|
}
|
39
|
-
subject.connection.
|
39
|
+
expect(subject.connection).to receive(:post).with("/node/0/labels", options)
|
40
40
|
subject.add_label(0, ["Actor"])
|
41
41
|
end
|
42
42
|
|
@@ -45,7 +45,7 @@ module Neography
|
|
45
45
|
:body => '["Actor","Director"]',
|
46
46
|
:headers => json_content_type
|
47
47
|
}
|
48
|
-
subject.connection.
|
48
|
+
expect(subject.connection).to receive(:post).with("/node/0/labels", options)
|
49
49
|
subject.add_label(0, ["Actor", "Director"])
|
50
50
|
end
|
51
51
|
|
@@ -54,7 +54,7 @@ module Neography
|
|
54
54
|
:body => '["Actor"]',
|
55
55
|
:headers => json_content_type
|
56
56
|
}
|
57
|
-
subject.connection.
|
57
|
+
expect(subject.connection).to receive(:put).with("/node/0/labels", options)
|
58
58
|
subject.set_label(0, ["Actor"])
|
59
59
|
end
|
60
60
|
|
@@ -63,12 +63,12 @@ module Neography
|
|
63
63
|
:body => '["Actor","Director"]',
|
64
64
|
:headers => json_content_type
|
65
65
|
}
|
66
|
-
subject.connection.
|
66
|
+
expect(subject.connection).to receive(:put).with("/node/0/labels", options)
|
67
67
|
subject.set_label(0, ["Actor", "Director"])
|
68
68
|
end
|
69
69
|
|
70
70
|
it "can delete a label from a node" do
|
71
|
-
subject.connection.
|
71
|
+
expect(subject.connection).to receive(:delete).with("/node/0/labels/Actor")
|
72
72
|
subject.delete_label(0,"Actor")
|
73
73
|
end
|
74
74
|
|