neography-down 1.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.project +12 -0
- data/.rspec +1 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +939 -0
- data/CONTRIBUTORS +18 -0
- data/Gemfile +4 -0
- data/Guardfile +14 -0
- data/LICENSE +19 -0
- data/README.md +281 -0
- data/Rakefile +14 -0
- data/examples/facebook.rb +40 -0
- data/examples/facebook_v2.rb +25 -0
- data/examples/greatest.rb +43 -0
- data/examples/linkedin.rb +39 -0
- data/examples/linkedin_v2.rb +22 -0
- data/examples/traversal_example1.rb +65 -0
- data/examples/traversal_example2.rb +54 -0
- data/lib/neography.rb +45 -0
- data/lib/neography/config.rb +64 -0
- data/lib/neography/connection.rb +263 -0
- data/lib/neography/equal.rb +21 -0
- data/lib/neography/errors.rb +60 -0
- data/lib/neography/index.rb +52 -0
- data/lib/neography/multi_json_parser.rb +28 -0
- data/lib/neography/neography.rb +10 -0
- data/lib/neography/node.rb +63 -0
- data/lib/neography/node_path.rb +29 -0
- data/lib/neography/node_relationship.rb +37 -0
- data/lib/neography/node_traverser.rb +146 -0
- data/lib/neography/path_traverser.rb +100 -0
- data/lib/neography/property.rb +110 -0
- data/lib/neography/property_container.rb +28 -0
- data/lib/neography/railtie.rb +19 -0
- data/lib/neography/relationship.rb +78 -0
- data/lib/neography/relationship_traverser.rb +80 -0
- data/lib/neography/rest.rb +99 -0
- data/lib/neography/rest/batch.rb +414 -0
- data/lib/neography/rest/clean.rb +17 -0
- data/lib/neography/rest/constraints.rb +38 -0
- data/lib/neography/rest/cypher.rb +29 -0
- data/lib/neography/rest/extensions.rb +21 -0
- data/lib/neography/rest/gremlin.rb +20 -0
- data/lib/neography/rest/helpers.rb +96 -0
- data/lib/neography/rest/node_auto_indexes.rb +60 -0
- data/lib/neography/rest/node_indexes.rb +139 -0
- data/lib/neography/rest/node_labels.rb +49 -0
- data/lib/neography/rest/node_paths.rb +49 -0
- data/lib/neography/rest/node_properties.rb +52 -0
- data/lib/neography/rest/node_relationships.rb +33 -0
- data/lib/neography/rest/node_traversal.rb +25 -0
- data/lib/neography/rest/nodes.rb +94 -0
- data/lib/neography/rest/other_node_relationships.rb +38 -0
- data/lib/neography/rest/relationship_auto_indexes.rb +60 -0
- data/lib/neography/rest/relationship_indexes.rb +142 -0
- data/lib/neography/rest/relationship_properties.rb +52 -0
- data/lib/neography/rest/relationship_types.rb +11 -0
- data/lib/neography/rest/relationships.rb +16 -0
- data/lib/neography/rest/schema_indexes.rb +26 -0
- data/lib/neography/rest/spatial.rb +137 -0
- data/lib/neography/rest/transactions.rb +101 -0
- data/lib/neography/tasks.rb +207 -0
- data/lib/neography/version.rb +3 -0
- data/neography.gemspec +39 -0
- data/spec/integration/authorization_spec.rb +40 -0
- data/spec/integration/broken_spatial_spec.rb +28 -0
- data/spec/integration/index_spec.rb +71 -0
- data/spec/integration/neography_spec.rb +10 -0
- data/spec/integration/node_encoding_spec.rb +71 -0
- data/spec/integration/node_path_spec.rb +222 -0
- data/spec/integration/node_relationship_spec.rb +381 -0
- data/spec/integration/node_spec.rb +260 -0
- data/spec/integration/parsing_spec.rb +13 -0
- data/spec/integration/performance_spec.rb +17 -0
- data/spec/integration/relationship_spec.rb +37 -0
- data/spec/integration/rest_batch_no_streaming_spec.rb +41 -0
- data/spec/integration/rest_batch_spec.rb +604 -0
- data/spec/integration/rest_batch_streaming_spec.rb +51 -0
- data/spec/integration/rest_bulk_spec.rb +106 -0
- data/spec/integration/rest_constraints_spec.rb +72 -0
- data/spec/integration/rest_experimental_spec.rb +22 -0
- data/spec/integration/rest_gremlin_fail_spec.rb +46 -0
- data/spec/integration/rest_header_spec.rb +15 -0
- data/spec/integration/rest_index_spec.rb +481 -0
- data/spec/integration/rest_labels_spec.rb +128 -0
- data/spec/integration/rest_node_spec.rb +274 -0
- data/spec/integration/rest_other_node_relationship_spec.rb +137 -0
- data/spec/integration/rest_path_spec.rb +231 -0
- data/spec/integration/rest_plugin_spec.rb +177 -0
- data/spec/integration/rest_relationship_spec.rb +354 -0
- data/spec/integration/rest_relationship_types_spec.rb +18 -0
- data/spec/integration/rest_schema_index_spec.rb +32 -0
- data/spec/integration/rest_spatial_spec.rb +166 -0
- data/spec/integration/rest_transaction_spec.rb +166 -0
- data/spec/integration/rest_traverse_spec.rb +149 -0
- data/spec/integration/unmanaged_spec.rb +27 -0
- data/spec/matchers.rb +33 -0
- data/spec/neography_spec.rb +23 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/unit/config_spec.rb +135 -0
- data/spec/unit/connection_spec.rb +284 -0
- data/spec/unit/node_spec.rb +100 -0
- data/spec/unit/properties_spec.rb +285 -0
- data/spec/unit/relationship_spec.rb +118 -0
- data/spec/unit/rest/batch_spec.rb +262 -0
- data/spec/unit/rest/clean_spec.rb +16 -0
- data/spec/unit/rest/constraints_spec.rb +45 -0
- data/spec/unit/rest/cypher_spec.rb +20 -0
- data/spec/unit/rest/extensions_spec.rb +28 -0
- data/spec/unit/rest/gremlin_spec.rb +25 -0
- data/spec/unit/rest/helpers_spec.rb +124 -0
- data/spec/unit/rest/labels_spec.rb +77 -0
- data/spec/unit/rest/node_auto_indexes_spec.rb +70 -0
- data/spec/unit/rest/node_indexes_spec.rb +140 -0
- data/spec/unit/rest/node_paths_spec.rb +77 -0
- data/spec/unit/rest/node_properties_spec.rb +79 -0
- data/spec/unit/rest/node_relationships_spec.rb +57 -0
- data/spec/unit/rest/node_traversal_spec.rb +35 -0
- data/spec/unit/rest/nodes_spec.rb +187 -0
- data/spec/unit/rest/relationship_auto_indexes_spec.rb +66 -0
- data/spec/unit/rest/relationship_indexes_spec.rb +132 -0
- data/spec/unit/rest/relationship_properties_spec.rb +79 -0
- data/spec/unit/rest/relationship_types_spec.rb +15 -0
- data/spec/unit/rest/relationships_spec.rb +21 -0
- data/spec/unit/rest/schema_index_spec.rb +30 -0
- data/spec/unit/rest/transactions_spec.rb +43 -0
- metadata +372 -0
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Neography
|
4
|
+
class Rest
|
5
|
+
describe NodeLabels do
|
6
|
+
|
7
|
+
subject { Neography::Rest.new }
|
8
|
+
|
9
|
+
it "list node labels" do
|
10
|
+
expect(subject.connection).to receive(:get).with("/labels")
|
11
|
+
subject.list_labels
|
12
|
+
end
|
13
|
+
|
14
|
+
it "get labels for node" do
|
15
|
+
expect(subject.connection).to receive(:get).with("/node/0/labels")
|
16
|
+
subject.get_node_labels(0)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "get nodes for labels" do
|
20
|
+
expect(subject.connection).to receive(:get).with("/label/person/nodes")
|
21
|
+
subject.get_nodes_labeled("person")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "find nodes for labels and property string" do
|
25
|
+
expect(subject.connection).to receive(:get).with("/label/person/nodes?name=%22max%22")
|
26
|
+
subject.find_nodes_labeled("person", {:name => "max"})
|
27
|
+
end
|
28
|
+
|
29
|
+
it "find nodes for labels and property integer" do
|
30
|
+
expect(subject.connection).to receive(:get).with("/label/person/nodes?age=26")
|
31
|
+
subject.find_nodes_labeled("person", {:age => 26})
|
32
|
+
end
|
33
|
+
|
34
|
+
it "can add a label to a node" do
|
35
|
+
options = {
|
36
|
+
:body => '["Actor"]',
|
37
|
+
:headers => json_content_type
|
38
|
+
}
|
39
|
+
expect(subject.connection).to receive(:post).with("/node/0/labels", options)
|
40
|
+
subject.add_label(0, ["Actor"])
|
41
|
+
end
|
42
|
+
|
43
|
+
it "can add labels to a node" do
|
44
|
+
options = {
|
45
|
+
:body => '["Actor","Director"]',
|
46
|
+
:headers => json_content_type
|
47
|
+
}
|
48
|
+
expect(subject.connection).to receive(:post).with("/node/0/labels", options)
|
49
|
+
subject.add_label(0, ["Actor", "Director"])
|
50
|
+
end
|
51
|
+
|
52
|
+
it "can set a label to a node" do
|
53
|
+
options = {
|
54
|
+
:body => '["Actor"]',
|
55
|
+
:headers => json_content_type
|
56
|
+
}
|
57
|
+
expect(subject.connection).to receive(:put).with("/node/0/labels", options)
|
58
|
+
subject.set_label(0, ["Actor"])
|
59
|
+
end
|
60
|
+
|
61
|
+
it "can add labels to a node" do
|
62
|
+
options = {
|
63
|
+
:body => '["Actor","Director"]',
|
64
|
+
:headers => json_content_type
|
65
|
+
}
|
66
|
+
expect(subject.connection).to receive(:put).with("/node/0/labels", options)
|
67
|
+
subject.set_label(0, ["Actor", "Director"])
|
68
|
+
end
|
69
|
+
|
70
|
+
it "can delete a label from a node" do
|
71
|
+
expect(subject.connection).to receive(:delete).with("/node/0/labels/Actor")
|
72
|
+
subject.delete_label(0,"Actor")
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Neography
|
4
|
+
class Rest
|
5
|
+
describe NodeAutoIndexes do
|
6
|
+
|
7
|
+
subject { Neography::Rest.new }
|
8
|
+
|
9
|
+
it "gets a node from an auto index" do
|
10
|
+
expect(subject.connection).to receive(:get).with("/index/auto/node/some_key/some_value")
|
11
|
+
subject.get_node_auto_index("some_key", "some_value")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns nil if nothing was found in the auto index" do
|
15
|
+
allow(subject.connection).to receive(:get).and_return(nil)
|
16
|
+
expect(subject.get_node_auto_index("some_key", "some_value")).to be_nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it "finds by key and value if value passed to #find_or_query" do
|
20
|
+
expect(subject.connection).to receive(:get).with("/index/auto/node/some_key/some_value")
|
21
|
+
subject.find_node_auto_index("some_key", "some_value")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "finds by query if no value passed to #find_or_query" do
|
25
|
+
expect(subject.connection).to receive(:get).with("/index/auto/node/?query=some_query")
|
26
|
+
subject.find_node_auto_index("some_query")
|
27
|
+
|
28
|
+
query = "some_query AND another_one"
|
29
|
+
expect(subject.connection).to receive(:get).with("/index/auto/node/?query=#{URI.encode(query)}")
|
30
|
+
subject.find_node_auto_index(query)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "finds by key and value" do
|
34
|
+
expect(subject.connection).to receive(:get).with("/index/auto/node/some_key/some_value")
|
35
|
+
subject.find_node_auto_index("some_key", "some_value")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "finds by query" do
|
39
|
+
expect(subject.connection).to receive(:get).with("/index/auto/node/?query=some_query")
|
40
|
+
subject.find_node_auto_index("some_query")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "gets the status" do
|
44
|
+
expect(subject.connection).to receive(:get).with("/index/auto/node/status")
|
45
|
+
subject.get_node_auto_index_status
|
46
|
+
end
|
47
|
+
|
48
|
+
it "sets the status" do
|
49
|
+
expect(subject.connection).to receive(:put).with("/index/auto/node/status", hash_match(:body, '"foo"'))
|
50
|
+
subject.set_node_auto_index_status("foo")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "gets auto index properties" do
|
54
|
+
expect(subject.connection).to receive(:get).with("/index/auto/node/properties")
|
55
|
+
subject.get_node_auto_index_properties
|
56
|
+
end
|
57
|
+
|
58
|
+
it "adds a property to an auto index" do
|
59
|
+
expect(subject.connection).to receive(:post).with("/index/auto/node/properties", hash_match(:body, "foo"))
|
60
|
+
subject.add_node_auto_index_property("foo")
|
61
|
+
end
|
62
|
+
|
63
|
+
it "removes a property from an auto index" do
|
64
|
+
expect(subject.connection).to receive(:delete).with("/index/auto/node/properties/foo")
|
65
|
+
subject.remove_node_auto_index_property("foo")
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Neography
|
4
|
+
class Rest
|
5
|
+
describe NodeIndexes do
|
6
|
+
|
7
|
+
subject { Neography::Rest.new }
|
8
|
+
|
9
|
+
it "lists all indexes" do
|
10
|
+
expect(subject.connection).to receive(:get).with("/index/node")
|
11
|
+
subject.list_node_indexes
|
12
|
+
end
|
13
|
+
|
14
|
+
it "creates a node index" do
|
15
|
+
expected_body = {
|
16
|
+
"config" => {
|
17
|
+
"type" => "some_type",
|
18
|
+
"provider" => "some_provider"
|
19
|
+
},
|
20
|
+
"name" => "some_index"
|
21
|
+
}
|
22
|
+
expect(subject.connection).to receive(:post).with("/index/node", json_match(:body, expected_body))
|
23
|
+
subject.create_node_index("some_index", "some_type", "some_provider")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns the post result after creation" do
|
27
|
+
allow(subject.connection).to receive(:post).and_return("foo")
|
28
|
+
expect(subject.create_node_index("some_index", "some_type", "some_provider")).to eq("foo")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "creates an auto-index" do
|
32
|
+
expected_body = {
|
33
|
+
"config" => {
|
34
|
+
"type" => "some_type",
|
35
|
+
"provider" => "some_provider"
|
36
|
+
},
|
37
|
+
"name" => "node_auto_index"
|
38
|
+
}
|
39
|
+
expect(subject.connection).to receive(:post).with("/index/node", json_match(:body, expected_body))
|
40
|
+
subject.create_node_auto_index("some_type", "some_provider")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "creates a unique node in an index" do
|
44
|
+
expected_body = {
|
45
|
+
"properties" => "properties",
|
46
|
+
"key" => "key",
|
47
|
+
"value" => "value"
|
48
|
+
}
|
49
|
+
expect(subject.connection).to receive(:post).with("/index/node/some_index?unique", json_match(:body, expected_body))
|
50
|
+
subject.create_unique_node("some_index", "key", "value", "properties")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "gets or creates a unique node in an index" do
|
54
|
+
expected_body = {
|
55
|
+
"properties" => "properties",
|
56
|
+
"key" => "key",
|
57
|
+
"value" => "value"
|
58
|
+
}
|
59
|
+
expect(subject.connection).to receive(:post).with("/index/node/some_index?uniqueness=get_or_create", json_match(:body, expected_body))
|
60
|
+
subject.get_or_create_unique_node("some_index", "key", "value", "properties")
|
61
|
+
end
|
62
|
+
|
63
|
+
it "adds a node to an index" do
|
64
|
+
expected_body = {
|
65
|
+
"uri" => "http://localhost:7474/node/42",
|
66
|
+
"key" => "key",
|
67
|
+
"value" => "value"
|
68
|
+
}
|
69
|
+
expect(subject.connection).to receive(:post).with("/index/node/some_index", json_match(:body, expected_body))
|
70
|
+
subject.add_node_to_index("some_index", "key", "value", "42")
|
71
|
+
end
|
72
|
+
|
73
|
+
it "gets a node from an index" do
|
74
|
+
expect(subject.connection).to receive(:get).with("/index/node/some_index/some_key/some_value")
|
75
|
+
subject.get_node_index("some_index", "some_key", "some_value")
|
76
|
+
end
|
77
|
+
|
78
|
+
it "returns nil if nothing was found in the index" do
|
79
|
+
allow(subject.connection).to receive(:get).and_return(nil)
|
80
|
+
expect(subject.get_node_index("some_index", "some_key", "some_value")).to be_nil
|
81
|
+
end
|
82
|
+
|
83
|
+
it "finds by key and value if both passed to #find" do
|
84
|
+
expect(subject.connection).to receive(:get).with("/index/node/some_index/some_key/some_value")
|
85
|
+
subject.find_node_index("some_index", "some_key", "some_value")
|
86
|
+
end
|
87
|
+
|
88
|
+
it "finds by query if no value passed to #find" do
|
89
|
+
expect(subject.connection).to receive(:get).with("/index/node/some_index?query=some_query")
|
90
|
+
subject.find_node_index("some_index", "some_query")
|
91
|
+
end
|
92
|
+
|
93
|
+
it "finds by key and value" do
|
94
|
+
expect(subject.connection).to receive(:get).with("/index/node/some_index/some_key/some_value")
|
95
|
+
subject.find_node_index_by_key_value("some_index", "some_key", "some_value")
|
96
|
+
end
|
97
|
+
|
98
|
+
it "finds by query" do
|
99
|
+
expect(subject.connection).to receive(:get).with("/index/node/some_index?query=some_query")
|
100
|
+
subject.find_node_index_by_query("some_index", "some_query")
|
101
|
+
end
|
102
|
+
|
103
|
+
it "removes a node from an index by id for #remove with two arguments" do
|
104
|
+
expect(subject.connection).to receive(:delete).with("/index/node/some_index/42")
|
105
|
+
subject.remove_node_from_index("some_index", "42")
|
106
|
+
end
|
107
|
+
|
108
|
+
it "removes a node from an index by key for #remove with three arguments" do
|
109
|
+
expect(subject.connection).to receive(:delete).with("/index/node/some_index/some_key/42")
|
110
|
+
subject.remove_node_from_index("some_index", "some_key", "42")
|
111
|
+
end
|
112
|
+
|
113
|
+
it "removes a node from an index by key and value for #remove with four arguments" do
|
114
|
+
expect(subject.connection).to receive(:delete).with("/index/node/some_index/some_key/some_value/42")
|
115
|
+
subject.remove_node_from_index("some_index", "some_key", "some_value", "42")
|
116
|
+
end
|
117
|
+
|
118
|
+
it "removes a node from an index" do
|
119
|
+
expect(subject.connection).to receive(:delete).with("/index/node/some_index/42")
|
120
|
+
subject.remove_node_index_by_id("some_index", "42")
|
121
|
+
end
|
122
|
+
|
123
|
+
it "removes a node from an index by key" do
|
124
|
+
expect(subject.connection).to receive(:delete).with("/index/node/some_index/some_key/42")
|
125
|
+
subject.remove_node_index_by_key("some_index", "42", "some_key")
|
126
|
+
end
|
127
|
+
|
128
|
+
it "removes a node from an index by key and value" do
|
129
|
+
expect(subject.connection).to receive(:delete).with("/index/node/some_index/some_key/some_value/42")
|
130
|
+
subject.remove_node_index_by_value("some_index", "42", "some_key", "some_value")
|
131
|
+
end
|
132
|
+
|
133
|
+
it "drops an index" do
|
134
|
+
expect(subject.connection).to receive(:delete).with("/index/node/some_index")
|
135
|
+
subject.drop_node_index("some_index")
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Neography
|
4
|
+
class Rest
|
5
|
+
describe NodePaths do
|
6
|
+
|
7
|
+
subject { Neography::Rest.new }
|
8
|
+
|
9
|
+
it "gets a shortest path between two nodes" do
|
10
|
+
expected_body = {
|
11
|
+
"to" => "http://localhost:7474/node/43",
|
12
|
+
"relationships" => "relationships",
|
13
|
+
"max_depth" => 3,
|
14
|
+
"algorithm" => "shortestPath"
|
15
|
+
}
|
16
|
+
|
17
|
+
expect(subject.connection).to receive(:post).with("/node/42/path", json_match(:body, expected_body))
|
18
|
+
|
19
|
+
subject.get_path("42", "43", "relationships", 3, "shortestPath")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "gets all shortest paths between two nodes" do
|
23
|
+
expected_body = {
|
24
|
+
"to" => "http://localhost:7474/node/43",
|
25
|
+
"relationships" => "relationships",
|
26
|
+
"max_depth" => 3,
|
27
|
+
"algorithm" => "shortestPath"
|
28
|
+
}
|
29
|
+
|
30
|
+
expect(subject.connection).to receive(:post).with("/node/42/paths", json_match(:body, expected_body))
|
31
|
+
|
32
|
+
subject.get_paths("42", "43", "relationships", 3, "shortestPath")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "gets all shortest weighted paths between two nodes" do
|
36
|
+
expected_body = {
|
37
|
+
"to" => "http://localhost:7474/node/43",
|
38
|
+
"relationships" => "relationships",
|
39
|
+
"cost_property" => "cost",
|
40
|
+
"max_depth" => 3,
|
41
|
+
"algorithm" => "shortestPath"
|
42
|
+
}
|
43
|
+
|
44
|
+
expect(subject.connection).to receive(:post).with("/node/42/paths", json_match(:body, expected_body))
|
45
|
+
|
46
|
+
subject.get_shortest_weighted_path("42", "43", "relationships", "cost", 3, "shortestPath")
|
47
|
+
end
|
48
|
+
|
49
|
+
context "algorithm" do
|
50
|
+
|
51
|
+
[ :shortest, "shortest", :shortestPath, "shortestPath", :short, "short" ].each do |algorithm|
|
52
|
+
it "parses shortestPath" do
|
53
|
+
expect(subject.send(:get_algorithm, algorithm)).to eq("shortestPath")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
[ :allSimplePaths, "allSimplePaths", :simple, "simple" ].each do |algorithm|
|
58
|
+
it "parses allSimplePaths" do
|
59
|
+
expect(subject.send(:get_algorithm, algorithm)).to eq("allSimplePaths")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
[ :dijkstra, "dijkstra" ].each do |algorithm|
|
64
|
+
it "parses dijkstra" do
|
65
|
+
expect(subject.send(:get_algorithm, algorithm)).to eq("dijkstra")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
it "parses allPaths by default" do
|
70
|
+
expect(subject.send(:get_algorithm, "foo")).to eq("allPaths")
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Neography
|
4
|
+
class Rest
|
5
|
+
describe NodeProperties do
|
6
|
+
|
7
|
+
subject { Neography::Rest.new }
|
8
|
+
|
9
|
+
it "sets properties" do
|
10
|
+
options1 = {
|
11
|
+
:body => '"bar"',
|
12
|
+
:headers => json_content_type
|
13
|
+
}
|
14
|
+
options2 = {
|
15
|
+
:body => '"qux"',
|
16
|
+
:headers => json_content_type
|
17
|
+
}
|
18
|
+
expect(subject.connection).to receive(:put).with("/node/42/properties/foo", options1)
|
19
|
+
expect(subject.connection).to receive(:put).with("/node/42/properties/baz", options2)
|
20
|
+
subject.set_node_properties("42", {:foo => "bar", :baz => "qux"})
|
21
|
+
end
|
22
|
+
|
23
|
+
it "resets properties" do
|
24
|
+
options = {
|
25
|
+
:body => '{"foo":"bar"}',
|
26
|
+
:headers => json_content_type
|
27
|
+
}
|
28
|
+
expect(subject.connection).to receive(:put).with("/node/42/properties", options)
|
29
|
+
subject.reset_node_properties("42", {:foo => "bar"})
|
30
|
+
end
|
31
|
+
|
32
|
+
context "getting properties" do
|
33
|
+
|
34
|
+
it "gets all properties" do
|
35
|
+
expect(subject.connection).to receive(:get).with("/node/42/properties")
|
36
|
+
subject.get_node_properties("42")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "gets multiple properties" do
|
40
|
+
expect(subject.connection).to receive(:get).with("/node/42/properties/foo")
|
41
|
+
expect(subject.connection).to receive(:get).with("/node/42/properties/bar")
|
42
|
+
subject.get_node_properties("42", "foo", "bar")
|
43
|
+
end
|
44
|
+
|
45
|
+
it "returns multiple properties as a hash" do
|
46
|
+
allow(subject.connection).to receive(:get).and_return("baz", "qux")
|
47
|
+
expect(subject.get_node_properties("42", "foo", "bar")).to eq({ "foo" => "baz", "bar" => "qux" })
|
48
|
+
end
|
49
|
+
|
50
|
+
it "returns nil if no properties were found" do
|
51
|
+
allow(subject.connection).to receive(:get).and_return(nil, nil)
|
52
|
+
expect(subject.get_node_properties("42", "foo", "bar")).to be_nil
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns hash without nil return values" do
|
56
|
+
allow(subject.connection).to receive(:get).and_return("baz", nil)
|
57
|
+
expect(subject.get_node_properties("42", "foo", "bar")).to eq({ "foo" => "baz" })
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
context "removing properties" do
|
63
|
+
|
64
|
+
it "removes all properties" do
|
65
|
+
expect(subject.connection).to receive(:delete).with("/node/42/properties")
|
66
|
+
subject.remove_node_properties("42")
|
67
|
+
end
|
68
|
+
|
69
|
+
it "removes multiple properties" do
|
70
|
+
expect(subject.connection).to receive(:delete).with("/node/42/properties/foo")
|
71
|
+
expect(subject.connection).to receive(:delete).with("/node/42/properties/bar")
|
72
|
+
subject.remove_node_properties("42", "foo", "bar")
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|