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
@@ -18,11 +18,11 @@ describe Neography::Rest do
|
|
18
18
|
@neo.create_relationship("friends", @new_node4, @new_node5)
|
19
19
|
@neo.create_relationship("friends", @new_node3, @new_node5)
|
20
20
|
nodes = @neo.traverse(@new_node1, "nodes", {"relationships" => {"type"=> "friends", "direction" => "out"}, "depth" => 4} )
|
21
|
-
nodes.
|
22
|
-
nodes[0]["self"].
|
23
|
-
nodes[1]["self"].
|
24
|
-
nodes[2]["self"].
|
25
|
-
nodes[3]["self"].
|
21
|
+
expect(nodes).not_to be_nil
|
22
|
+
expect(nodes[0]["self"]).to eq(@new_node2["self"])
|
23
|
+
expect(nodes[1]["self"]).to eq(@new_node3["self"])
|
24
|
+
expect(nodes[2]["self"]).to eq(@new_node4["self"])
|
25
|
+
expect(nodes[3]["self"]).to eq(@new_node5["self"])
|
26
26
|
end
|
27
27
|
it "can traverse the graph and return relationships" do
|
28
28
|
new_relationship1= @neo.create_relationship("friends", @new_node1, @new_node2)
|
@@ -32,12 +32,12 @@ describe Neography::Rest do
|
|
32
32
|
new_relationship5= @neo.create_relationship("friends", @new_node3, @new_node5)
|
33
33
|
|
34
34
|
relationships = @neo.traverse(@new_node1, "relationships", {"relationships" => {"type"=> "friends", "direction" => "out"}, "depth" => 4} )
|
35
|
-
relationships.
|
35
|
+
expect(relationships).not_to be_nil
|
36
36
|
|
37
|
-
relationships[0]["self"].
|
38
|
-
relationships[1]["self"].
|
39
|
-
relationships[2]["self"].
|
40
|
-
relationships[3]["self"].
|
37
|
+
expect(relationships[0]["self"]).to eq(new_relationship1["self"])
|
38
|
+
expect(relationships[1]["self"]).to eq(new_relationship2["self"])
|
39
|
+
expect(relationships[2]["self"]).to eq(new_relationship3["self"])
|
40
|
+
expect(relationships[3]["self"]).to eq(new_relationship4["self"])
|
41
41
|
end
|
42
42
|
|
43
43
|
it "can traverse the graph and return paths" do
|
@@ -48,12 +48,12 @@ describe Neography::Rest do
|
|
48
48
|
new_relationship5= @neo.create_relationship("friends", @new_node3, @new_node5)
|
49
49
|
|
50
50
|
paths = @neo.traverse(@new_node1, "paths", {"relationships" => {"type"=> "friends", "direction" => "out"}, "depth" => 4} )
|
51
|
-
paths.
|
51
|
+
expect(paths).not_to be_nil
|
52
52
|
|
53
|
-
paths[0]["nodes"].
|
54
|
-
paths[1]["nodes"].
|
55
|
-
paths[2]["nodes"].
|
56
|
-
paths[3]["nodes"].
|
53
|
+
expect(paths[0]["nodes"]).to eq([@new_node1["self"], @new_node2["self"]])
|
54
|
+
expect(paths[1]["nodes"]).to eq([@new_node1["self"], @new_node2["self"], @new_node3["self"]])
|
55
|
+
expect(paths[2]["nodes"]).to eq([@new_node1["self"], @new_node2["self"], @new_node3["self"], @new_node4["self"]])
|
56
|
+
expect(paths[3]["nodes"]).to eq([@new_node1["self"], @new_node2["self"], @new_node3["self"], @new_node4["self"], @new_node5["self"]])
|
57
57
|
end
|
58
58
|
|
59
59
|
it "can traverse the graph up to a certain depth" do
|
@@ -64,12 +64,12 @@ describe Neography::Rest do
|
|
64
64
|
new_relationship5= @neo.create_relationship("friends", @new_node3, @new_node5)
|
65
65
|
|
66
66
|
paths = @neo.traverse(@new_node1, "paths", {"relationships" => {"type"=> "friends", "direction" => "out"}, "depth" => 3} )
|
67
|
-
paths.
|
67
|
+
expect(paths).not_to be_nil
|
68
68
|
|
69
|
-
paths[0]["nodes"].
|
70
|
-
paths[1]["nodes"].
|
71
|
-
paths[2]["nodes"].
|
72
|
-
paths[3]["nodes"].
|
69
|
+
expect(paths[0]["nodes"]).to eq([@new_node1["self"], @new_node2["self"]])
|
70
|
+
expect(paths[1]["nodes"]).to eq([@new_node1["self"], @new_node2["self"], @new_node3["self"]])
|
71
|
+
expect(paths[2]["nodes"]).to eq([@new_node1["self"], @new_node2["self"], @new_node3["self"], @new_node4["self"]])
|
72
|
+
expect(paths[3]["nodes"]).to eq([@new_node1["self"], @new_node2["self"], @new_node3["self"], @new_node5["self"]])
|
73
73
|
end
|
74
74
|
|
75
75
|
it "can traverse the graph in a certain order" do
|
@@ -80,12 +80,12 @@ describe Neography::Rest do
|
|
80
80
|
new_relationship5= @neo.create_relationship("friends", @new_node3, @new_node5)
|
81
81
|
|
82
82
|
paths = @neo.traverse(@new_node1, "paths", {"order" => "breadth first", "relationships" => {"type"=> "friends", "direction" => "out"}, "depth" => 4} )
|
83
|
-
paths.
|
83
|
+
expect(paths).not_to be_nil
|
84
84
|
|
85
|
-
paths[0]["nodes"].
|
86
|
-
paths[1]["nodes"].
|
87
|
-
paths[2]["nodes"].
|
88
|
-
paths[3]["nodes"].
|
85
|
+
expect(paths[0]["nodes"]).to eq([@new_node1["self"], @new_node2["self"]])
|
86
|
+
expect(paths[1]["nodes"]).to eq([@new_node1["self"], @new_node2["self"], @new_node3["self"]])
|
87
|
+
expect(paths[2]["nodes"]).to eq([@new_node1["self"], @new_node2["self"], @new_node3["self"], @new_node4["self"]])
|
88
|
+
expect(paths[3]["nodes"]).to eq([@new_node1["self"], @new_node2["self"], @new_node3["self"], @new_node5["self"]])
|
89
89
|
end
|
90
90
|
|
91
91
|
it "can traverse the graph with a specific uniqueness" do
|
@@ -98,12 +98,12 @@ describe Neography::Rest do
|
|
98
98
|
new_relationship5= @neo.create_relationship("friends", @new_node3, @new_node5)
|
99
99
|
|
100
100
|
paths = @neo.traverse(@new_node1, "paths", {"order" => "breadth first", "uniqueness" => "node global", "relationships" => [{"type"=> "roommates", "direction" => "all"},{"type"=> "friends", "direction" => "out"}], "depth" => 4} )
|
101
|
-
paths.
|
101
|
+
expect(paths).not_to be_nil
|
102
102
|
|
103
|
-
paths[0]["nodes"].
|
104
|
-
paths[1]["nodes"].
|
105
|
-
paths[2]["nodes"].
|
106
|
-
paths[3]["nodes"].
|
103
|
+
expect(paths[0]["nodes"]).to eq([@new_node1["self"], @new_node2["self"]])
|
104
|
+
expect(paths[1]["nodes"]).to eq([@new_node1["self"], @new_node2["self"], @new_node5["self"]])
|
105
|
+
expect(paths[2]["nodes"]).to eq([@new_node1["self"], @new_node2["self"], @new_node3["self"]])
|
106
|
+
expect(paths[3]["nodes"]).to eq([@new_node1["self"], @new_node2["self"], @new_node3["self"], @new_node4["self"]])
|
107
107
|
end
|
108
108
|
|
109
109
|
it "can traverse the graph with a prune evaluator" do
|
@@ -119,10 +119,10 @@ describe Neography::Rest do
|
|
119
119
|
"depth" => 3,
|
120
120
|
"prune evaluator" => {"language" => "javascript", "body" => "position.endNode().getProperty('age') < 21;"
|
121
121
|
}} )
|
122
|
-
paths.
|
123
|
-
paths[0]["nodes"].
|
124
|
-
paths[1]["nodes"].
|
125
|
-
paths[2].
|
122
|
+
expect(paths).not_to be_nil
|
123
|
+
expect(paths[0]["nodes"]).to eq([@new_node1["self"], @new_node2["self"]])
|
124
|
+
expect(paths[1]["nodes"]).to eq([@new_node1["self"], @new_node2["self"], @new_node3["self"]])
|
125
|
+
expect(paths[2]).to be_nil
|
126
126
|
end
|
127
127
|
|
128
128
|
it "can traverse the graph with a return filter" do
|
@@ -134,12 +134,12 @@ describe Neography::Rest do
|
|
134
134
|
nodes = @neo.traverse(@new_node1, "node", {"relationships" => {"type"=> "friends", "direction" => "out"},
|
135
135
|
"return filter" => {"language" => "builtin", "name" => "all"},
|
136
136
|
"depth" => 4} )
|
137
|
-
nodes.
|
138
|
-
nodes[0]["self"].
|
139
|
-
nodes[1]["self"].
|
140
|
-
nodes[2]["self"].
|
141
|
-
nodes[3]["self"].
|
142
|
-
nodes[4]["self"].
|
137
|
+
expect(nodes).not_to be_nil
|
138
|
+
expect(nodes[0]["self"]).to eq(@new_node1["self"])
|
139
|
+
expect(nodes[1]["self"]).to eq(@new_node2["self"])
|
140
|
+
expect(nodes[2]["self"]).to eq(@new_node3["self"])
|
141
|
+
expect(nodes[3]["self"]).to eq(@new_node4["self"])
|
142
|
+
expect(nodes[4]["self"]).to eq(@new_node5["self"])
|
143
143
|
end
|
144
144
|
|
145
145
|
|
@@ -8,18 +8,18 @@ describe Neography::Rest do
|
|
8
8
|
describe "call unmanaged extensions", :unmanaged_extensions => true do
|
9
9
|
it "can call a get based unmanaged extension" do
|
10
10
|
results = @neo.get_extension('/example/service/queries/fofof/13343')
|
11
|
-
results.
|
11
|
+
expect(results).not_to be_null
|
12
12
|
end
|
13
13
|
|
14
14
|
it "can call a POST based unmanaged extension" do
|
15
15
|
results = @neo.post_extention('/movie/recommend', {"title" => "Rambo"})
|
16
|
-
results.
|
16
|
+
expect(results).not_to be_null
|
17
17
|
end
|
18
18
|
|
19
19
|
it "can call a POST based unmanaged extension that uses form-urlencoded" do
|
20
20
|
headers = {'Content-Type' =>'application/x-www-form-urlencoded'}
|
21
21
|
results = @neo.post_extention('/music/recommend', {"artist" => "Ministry", "song" => "Just one Fix"}, headers)
|
22
|
-
results.
|
22
|
+
expect(results).not_to be_null
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
data/spec/matchers.rb
CHANGED
@@ -5,7 +5,7 @@ RSpec::Matchers.define :json_match do |field, expected|
|
|
5
5
|
expected == JSON.parse(actual[field])
|
6
6
|
end
|
7
7
|
|
8
|
-
|
8
|
+
failure_message do
|
9
9
|
"expected JSON in field '#{field}' to match '#{expected}'"
|
10
10
|
end
|
11
11
|
|
@@ -22,7 +22,7 @@ RSpec::Matchers.define :hash_match do |field, expected|
|
|
22
22
|
expected == actual[field]
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
failure_message do
|
26
26
|
"expected field '#{field}' to match '#{expected}'"
|
27
27
|
end
|
28
28
|
|
data/spec/neography_spec.rb
CHANGED
@@ -5,16 +5,16 @@ describe Neography do
|
|
5
5
|
describe "::configure" do
|
6
6
|
|
7
7
|
it "returns the same configuration" do
|
8
|
-
Neography.configuration.
|
8
|
+
expect(Neography.configuration).to eq(Neography.configuration)
|
9
9
|
end
|
10
10
|
|
11
11
|
it "returns the Config" do
|
12
|
-
Neography.configuration.
|
12
|
+
expect(Neography.configuration).to be_a Neography::Config
|
13
13
|
end
|
14
14
|
|
15
15
|
it "yields the configuration" do
|
16
16
|
Neography.configure do |config|
|
17
|
-
config.
|
17
|
+
expect(config).to eq(Neography.configuration)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
data/spec/spec_helper.rb
CHANGED
@@ -27,10 +27,10 @@ end
|
|
27
27
|
|
28
28
|
def error_response(attributes)
|
29
29
|
request_uri = double()
|
30
|
-
request_uri.
|
30
|
+
allow(request_uri).to receive(:request_uri).and_return("")
|
31
31
|
|
32
32
|
http_header = double()
|
33
|
-
http_header.
|
33
|
+
allow(http_header).to receive(:request_uri).and_return(request_uri)
|
34
34
|
|
35
35
|
double(
|
36
36
|
http_header: http_header,
|
data/spec/unit/config_spec.rb
CHANGED
@@ -7,25 +7,100 @@ module Neography
|
|
7
7
|
|
8
8
|
context "defaults" do
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
10
|
+
describe '#protocol' do
|
11
|
+
subject { super().protocol }
|
12
|
+
it { should == 'http://' }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#server' do
|
16
|
+
subject { super().server }
|
17
|
+
it { should == 'localhost' }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#port' do
|
21
|
+
subject { super().port }
|
22
|
+
it { should == 7474 }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#directory' do
|
26
|
+
subject { super().directory }
|
27
|
+
it { should == '' }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#cypher_path' do
|
31
|
+
subject { super().cypher_path }
|
32
|
+
it { should == '/cypher' }
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#gremlin_path' do
|
36
|
+
subject { super().gremlin_path }
|
37
|
+
it { should == '/ext/GremlinPlugin/graphdb/execute_script' }
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#log_file' do
|
41
|
+
subject { super().log_file }
|
42
|
+
it { should == 'neography.log' }
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#log_enabled' do
|
46
|
+
subject { super().log_enabled }
|
47
|
+
it { should == false }
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#logger' do
|
51
|
+
subject { super().logger }
|
52
|
+
it { should == nil }
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#slow_log_threshold' do
|
56
|
+
subject { super().slow_log_threshold }
|
57
|
+
it { should == 0 }
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#max_threads' do
|
61
|
+
subject { super().max_threads }
|
62
|
+
it { should == 20 }
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#authentication' do
|
66
|
+
subject { super().authentication }
|
67
|
+
it { should == nil }
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#username' do
|
71
|
+
subject { super().username }
|
72
|
+
it { should == nil }
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#password' do
|
76
|
+
subject { super().password }
|
77
|
+
it { should == nil }
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#parser' do
|
81
|
+
subject { super().parser }
|
82
|
+
it { should == MultiJsonParser}
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#max_execution_time' do
|
86
|
+
subject { super().max_execution_time }
|
87
|
+
it { should == 6000 }
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#proxy' do
|
91
|
+
subject { super().proxy }
|
92
|
+
it { should == nil }
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '#http_send_timeout' do
|
96
|
+
subject { super().http_send_timeout }
|
97
|
+
it { should == 1200 }
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#http_receive_timeout' do
|
101
|
+
subject { super().http_receive_timeout }
|
102
|
+
it { should == 1200 }
|
103
|
+
end
|
29
104
|
|
30
105
|
|
31
106
|
it "has a hash representation" do
|
@@ -51,7 +126,7 @@ module Neography
|
|
51
126
|
:http_receive_timeout => 1200
|
52
127
|
|
53
128
|
}
|
54
|
-
config.to_hash.
|
129
|
+
expect(config.to_hash).to eq(expected_hash)
|
55
130
|
end
|
56
131
|
|
57
132
|
end
|
@@ -8,7 +8,7 @@ module Neography
|
|
8
8
|
context "defaults" do
|
9
9
|
|
10
10
|
it "intializes with defaults" do
|
11
|
-
connection.configuration.
|
11
|
+
expect(connection.configuration).to eq("http://localhost:7474")
|
12
12
|
end
|
13
13
|
|
14
14
|
end
|
@@ -38,26 +38,26 @@ module Neography
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it "accepts all options in a hash" do
|
41
|
-
connection.configuration.
|
42
|
-
|
43
|
-
connection.protocol.
|
44
|
-
connection.server.
|
45
|
-
connection.port.
|
46
|
-
connection.directory.
|
47
|
-
connection.cypher_path.
|
48
|
-
connection.gremlin_path.
|
49
|
-
connection.log_file.
|
50
|
-
connection.log_enabled.
|
51
|
-
connection.slow_log_threshold.
|
52
|
-
connection.max_threads.
|
53
|
-
connection.parser.
|
54
|
-
|
55
|
-
connection.authentication.
|
41
|
+
expect(connection.configuration).to eq("https://foobar:4242/dir")
|
42
|
+
|
43
|
+
expect(connection.protocol).to eq("https://")
|
44
|
+
expect(connection.server).to eq("foobar")
|
45
|
+
expect(connection.port).to eq(4242)
|
46
|
+
expect(connection.directory).to eq("/dir")
|
47
|
+
expect(connection.cypher_path).to eq("/cyph")
|
48
|
+
expect(connection.gremlin_path).to eq("/grem")
|
49
|
+
expect(connection.log_file).to eq("neo.log")
|
50
|
+
expect(connection.log_enabled).to eq(false)
|
51
|
+
expect(connection.slow_log_threshold).to eq(0)
|
52
|
+
expect(connection.max_threads).to eq(10)
|
53
|
+
expect(connection.parser).to eq(Foo)
|
54
|
+
|
55
|
+
expect(connection.authentication).to eq({
|
56
56
|
:foo_auth => {
|
57
57
|
:username => "bar",
|
58
58
|
:password => "baz"
|
59
59
|
}
|
60
|
-
}
|
60
|
+
})
|
61
61
|
end
|
62
62
|
|
63
63
|
context "httpclient" do
|
@@ -70,7 +70,7 @@ module Neography
|
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'configures send/receive timeout' do
|
73
|
-
Excon.
|
73
|
+
expect(Excon).to receive(:new).with("http://localhost:7474",
|
74
74
|
:read_timeout => 100,
|
75
75
|
:write_timeout => 120,
|
76
76
|
:persistent=>true,
|
@@ -87,13 +87,13 @@ module Neography
|
|
87
87
|
let(:options) { "https://user:pass@somehost:8585/path" }
|
88
88
|
|
89
89
|
it "accepts a string as configuration" do
|
90
|
-
connection.configuration.
|
91
|
-
connection.authentication.
|
90
|
+
expect(connection.configuration).to eq("https://somehost:8585/path")
|
91
|
+
expect(connection.authentication).to eq({
|
92
92
|
:basic_auth => {
|
93
93
|
:username => "user",
|
94
94
|
:password => "pass"
|
95
95
|
}
|
96
|
-
}
|
96
|
+
})
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
@@ -102,22 +102,22 @@ module Neography
|
|
102
102
|
context "requests" do
|
103
103
|
|
104
104
|
it "does a GET request" do
|
105
|
-
connection.client.
|
105
|
+
expect(connection.client).to receive(:request).with(:method => :get, :path => "/db/data/node/bar", :body => nil, :headers => nil) { double.as_null_object }
|
106
106
|
connection.get("/node/bar")
|
107
107
|
end
|
108
108
|
|
109
109
|
it "does a POST request" do
|
110
|
-
connection.client.
|
110
|
+
expect(connection.client).to receive(:request).with(:method => :post, :path => "/db/data/node/bar", :body => nil, :headers => nil) { double.as_null_object }
|
111
111
|
connection.post("/node/bar")
|
112
112
|
end
|
113
113
|
|
114
114
|
it "does a PUT request" do
|
115
|
-
connection.client.
|
115
|
+
expect(connection.client).to receive(:request).with(:method => :put, :path => "/db/data/node/bar", :body => nil, :headers => nil) { double.as_null_object }
|
116
116
|
connection.put("/node/bar")
|
117
117
|
end
|
118
118
|
|
119
119
|
it "does a DELETE request" do
|
120
|
-
connection.client.
|
120
|
+
expect(connection.client).to receive(:request).with(:method => :delete, :path => "/db/data/node/bar", :body => nil, :headers => nil) { double.as_null_object }
|
121
121
|
connection.delete("/node/bar")
|
122
122
|
end
|
123
123
|
|
@@ -131,12 +131,12 @@ module Neography
|
|
131
131
|
end
|
132
132
|
|
133
133
|
it "does requests with authentication" do
|
134
|
-
connection.client.
|
134
|
+
expect(connection.client).not_to receive(:set_auth).with(
|
135
135
|
"http://localhost:7474/db/data/node/bar",
|
136
136
|
"foo",
|
137
137
|
"bar") { double.as_null_object }
|
138
138
|
|
139
|
-
connection.client.
|
139
|
+
expect(connection.client).to receive(:request).with(
|
140
140
|
:method => :get, :path => "/db/data/node/bar", :body => nil, :headers => nil) { double.as_null_object }
|
141
141
|
|
142
142
|
connection.get("/node/bar")
|
@@ -144,7 +144,7 @@ module Neography
|
|
144
144
|
end
|
145
145
|
|
146
146
|
it "adds the User-Agent to the headers" do
|
147
|
-
connection.client.
|
147
|
+
expect(connection.client).to receive(:request).with(
|
148
148
|
hash_including(
|
149
149
|
{:method => :get, :path => "/db/data/node/bar", :body => nil,
|
150
150
|
:headers => {"User-Agent" => "Neography/#{Neography::VERSION}", "X-Stream"=>true, "max-execution-time" => 6000}}
|
@@ -158,7 +158,7 @@ module Neography
|
|
158
158
|
|
159
159
|
it "raises NodeNotFoundException" do
|
160
160
|
response = error_response(code: 404, message: "a message", exception: "NodeNotFoundException")
|
161
|
-
connection.client.
|
161
|
+
allow(connection.client).to receive(:request).and_return(response)
|
162
162
|
expect {
|
163
163
|
connection.get("/node/bar")
|
164
164
|
}.to raise_error NodeNotFoundException
|
@@ -166,7 +166,7 @@ module Neography
|
|
166
166
|
|
167
167
|
it "raises OperationFailureException" do
|
168
168
|
response = error_response(code: 409, message: "a message", exception: "OperationFailureException")
|
169
|
-
connection.client.
|
169
|
+
allow(connection.client).to receive(:request).and_return(response)
|
170
170
|
expect {
|
171
171
|
connection.get("/node/bar")
|
172
172
|
}.to raise_error OperationFailureException
|
@@ -174,7 +174,7 @@ module Neography
|
|
174
174
|
|
175
175
|
it "raises PropertyValueException" do
|
176
176
|
response = error_response(code: 400, message: "a message", exception: "PropertyValueException")
|
177
|
-
connection.client.
|
177
|
+
allow(connection.client).to receive(:request).and_return(response)
|
178
178
|
expect {
|
179
179
|
connection.get("/node/bar")
|
180
180
|
}.to raise_error PropertyValueException
|
@@ -182,7 +182,7 @@ module Neography
|
|
182
182
|
|
183
183
|
it "raises NoSuchPropertyException" do
|
184
184
|
response = error_response(code: 404, message: "a message", exception: "NoSuchPropertyException")
|
185
|
-
connection.client.
|
185
|
+
allow(connection.client).to receive(:request).and_return(response)
|
186
186
|
expect {
|
187
187
|
connection.get("/node/bar")
|
188
188
|
}.to raise_error NoSuchPropertyException
|
@@ -190,7 +190,7 @@ module Neography
|
|
190
190
|
|
191
191
|
it "raises RelationshipNotFoundException" do
|
192
192
|
response = error_response(code: 404, message: "a message", exception: "RelationshipNotFoundException")
|
193
|
-
connection.client.
|
193
|
+
allow(connection.client).to receive(:request).and_return(response)
|
194
194
|
expect {
|
195
195
|
connection.get("/node/bar")
|
196
196
|
}.to raise_error RelationshipNotFoundException
|
@@ -198,7 +198,7 @@ module Neography
|
|
198
198
|
|
199
199
|
it "raises BadInputException" do
|
200
200
|
response = error_response(code: 400, message: "a message", exception: "BadInputException")
|
201
|
-
connection.client.
|
201
|
+
allow(connection.client).to receive(:request).and_return(response)
|
202
202
|
expect {
|
203
203
|
connection.get("/node/bar")
|
204
204
|
}.to raise_error BadInputException
|
@@ -206,7 +206,7 @@ module Neography
|
|
206
206
|
|
207
207
|
it "raises UnauthorizedError" do
|
208
208
|
response = error_response(code: 401)
|
209
|
-
connection.client.
|
209
|
+
allow(connection.client).to receive(:request).and_return(response)
|
210
210
|
expect {
|
211
211
|
connection.get("/node/bar")
|
212
212
|
}.to raise_error UnauthorizedError
|
@@ -214,7 +214,7 @@ module Neography
|
|
214
214
|
|
215
215
|
it "raises NeographyError in all other cases" do
|
216
216
|
response = error_response(code: 418, message: "I'm a teapot.")
|
217
|
-
connection.client.
|
217
|
+
allow(connection.client).to receive(:request).and_return(response)
|
218
218
|
expect {
|
219
219
|
connection.get("/node/bar")
|
220
220
|
}.to raise_error NeographyError
|
@@ -222,7 +222,7 @@ module Neography
|
|
222
222
|
|
223
223
|
it "raises BadInputException" do
|
224
224
|
response = error_response(code: 500, message: "a message", exception: "JsonParseException")
|
225
|
-
connection.client.
|
225
|
+
allow(connection.client).to receive(:request).and_return(response)
|
226
226
|
expect {
|
227
227
|
connection.get("/node/bar")
|
228
228
|
}.to raise_error NeographyError
|
@@ -255,19 +255,19 @@ module Neography
|
|
255
255
|
|
256
256
|
describe "slow_log_threshold" do
|
257
257
|
before do
|
258
|
-
connection.
|
258
|
+
allow(connection).to receive(:evaluate_response).and_return expected_response
|
259
259
|
end
|
260
260
|
|
261
261
|
context "default value" do
|
262
262
|
it "should have output" do
|
263
|
-
@logger.
|
263
|
+
expect(@logger).to receive(:info).once
|
264
264
|
end
|
265
265
|
end
|
266
266
|
|
267
267
|
context "high value" do
|
268
268
|
before { connection.slow_log_threshold = 100_000 }
|
269
269
|
it "should not have output" do
|
270
|
-
@logger.
|
270
|
+
expect(@logger).not_to receive(:info)
|
271
271
|
end
|
272
272
|
end
|
273
273
|
|