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
data/spec/unit/node_spec.rb
CHANGED
@@ -8,22 +8,22 @@ module Neography
|
|
8
8
|
|
9
9
|
before do
|
10
10
|
@db = double(Neography::Rest, :is_a? => true).as_null_object
|
11
|
-
Rest.
|
11
|
+
allow(Rest).to receive(:new) { @db }
|
12
12
|
end
|
13
13
|
|
14
14
|
it "assigns a new Rest db by default" do
|
15
15
|
node = Node.create
|
16
|
-
node.neo_server.
|
16
|
+
expect(node.neo_server).to eq(@db)
|
17
17
|
end
|
18
18
|
|
19
19
|
it "creates without arguments" do
|
20
|
-
@db.
|
20
|
+
expect(@db).to receive(:create_node).with(nil)
|
21
21
|
Node.create
|
22
22
|
end
|
23
23
|
|
24
24
|
it "creates with only a hash argument" do
|
25
25
|
properties = { :foo => "bar" }
|
26
|
-
@db.
|
26
|
+
expect(@db).to receive(:create_node).with(properties)
|
27
27
|
Node.create(properties)
|
28
28
|
end
|
29
29
|
|
@@ -34,7 +34,7 @@ module Neography
|
|
34
34
|
it "cannot pass a server as the first argument, properties as the second (deprecated)" do
|
35
35
|
@other_server = Neography::Rest.new
|
36
36
|
properties = { :foo => "bar" }
|
37
|
-
@other_server.
|
37
|
+
expect(@other_server).not_to receive(:create_node).with(properties)
|
38
38
|
expect {
|
39
39
|
Node.create(@other_server, properties)
|
40
40
|
}.to raise_error(ArgumentError)
|
@@ -43,7 +43,7 @@ module Neography
|
|
43
43
|
it "can pass properties as the first argument, a server as the second" do
|
44
44
|
@other_server = Neography::Rest.new
|
45
45
|
properties = { :foo => "bar" }
|
46
|
-
@other_server.
|
46
|
+
expect(@other_server).to receive(:create_node).with(properties)
|
47
47
|
Node.create(properties, @other_server)
|
48
48
|
end
|
49
49
|
|
@@ -56,22 +56,22 @@ module Neography
|
|
56
56
|
before do
|
57
57
|
# stub out actual connections
|
58
58
|
@db = double(Rest).as_null_object
|
59
|
-
Rest.
|
59
|
+
allow(Rest).to receive(:new) { @db }
|
60
60
|
end
|
61
61
|
|
62
62
|
it "load by id" do
|
63
|
-
@db.
|
63
|
+
expect(@db).to receive(:get_node).with(5)
|
64
64
|
Node.load(5)
|
65
65
|
end
|
66
66
|
|
67
67
|
it "loads by node" do
|
68
68
|
node = Node.new
|
69
|
-
@db.
|
69
|
+
expect(@db).not_to receive(:get_node).with(node)
|
70
70
|
Node.load(node)
|
71
71
|
end
|
72
72
|
|
73
73
|
it "loads by full server string" do
|
74
|
-
@db.
|
74
|
+
expect(@db).to receive(:get_node).with("http://localhost:7474/db/data/node/2")
|
75
75
|
Node.load("http://localhost:7474/db/data/node/2")
|
76
76
|
end
|
77
77
|
|
@@ -81,7 +81,7 @@ module Neography
|
|
81
81
|
|
82
82
|
it "cannot pass a server as the first argument, node as the second (depracted)" do
|
83
83
|
@other_server = Neography::Rest.new
|
84
|
-
@other_server.
|
84
|
+
expect(@other_server).not_to receive(:get_node).with(42)
|
85
85
|
expect {
|
86
86
|
node = Node.load(@other_server, 42)
|
87
87
|
}.to raise_error(ArgumentError)
|
@@ -89,7 +89,7 @@ module Neography
|
|
89
89
|
|
90
90
|
it "can pass a node as the first argument, server as the second" do
|
91
91
|
@other_server = Neography::Rest.new
|
92
|
-
@other_server.
|
92
|
+
expect(@other_server).to receive(:get_node).with(42)
|
93
93
|
node = Node.load(42, @other_server)
|
94
94
|
end
|
95
95
|
|
@@ -5,68 +5,213 @@ module Neography
|
|
5
5
|
|
6
6
|
before do
|
7
7
|
@db = double(Neography::Rest, :is_a? => true).as_null_object
|
8
|
-
Rest.
|
8
|
+
allow(Rest).to receive(:new) { @db }
|
9
9
|
end
|
10
10
|
|
11
11
|
context "Node" do
|
12
12
|
|
13
13
|
subject(:node) do
|
14
14
|
node = Node.create
|
15
|
-
node.
|
15
|
+
allow(node).to receive(:neo_id).and_return(42)
|
16
16
|
node
|
17
17
|
end
|
18
18
|
|
19
19
|
it "sets properties as accessor" do
|
20
|
-
@db.
|
20
|
+
expect(@db).to receive(:"set_node_properties").with(42, { "key" => "value" })
|
21
21
|
node.key = "value"
|
22
22
|
end
|
23
23
|
|
24
24
|
it "sets properties as array entry" do
|
25
|
-
@db.
|
25
|
+
expect(@db).to receive(:"set_node_properties").with(42, { "key" => "value" })
|
26
26
|
node["key"] = "value"
|
27
27
|
end
|
28
28
|
|
29
29
|
it "gets properties as accessor" do
|
30
|
-
@db.
|
30
|
+
allow(@db).to receive(:"set_node_properties")
|
31
31
|
node.key = "value"
|
32
|
-
node.key.
|
32
|
+
expect(node.key).to eq("value")
|
33
33
|
end
|
34
34
|
|
35
35
|
it "gets properties as array entry" do
|
36
|
-
@db.
|
36
|
+
allow(@db).to receive(:"set_node_properties")
|
37
37
|
node["key"] = "value"
|
38
|
-
node["key"].
|
38
|
+
expect(node["key"]).to eq("value")
|
39
39
|
end
|
40
40
|
|
41
41
|
it "resets properties as accessor" do
|
42
|
-
@db.
|
42
|
+
expect(@db).to receive(:"remove_node_properties").with(42, ["key"])
|
43
43
|
node.key = "value"
|
44
44
|
node.key = nil
|
45
45
|
end
|
46
46
|
|
47
47
|
it "resets properties as array entry" do
|
48
|
-
@db.
|
48
|
+
expect(@db).to receive(:"remove_node_properties").with(42, ["key"])
|
49
49
|
node["key"] = "value"
|
50
50
|
node["key"] = nil
|
51
51
|
end
|
52
52
|
|
53
53
|
it "gets unknown properties as nil" do
|
54
|
-
node.unknown.
|
54
|
+
expect(node.unknown).to eq(nil)
|
55
55
|
end
|
56
56
|
|
57
57
|
it "overwrites existing properties" do
|
58
|
-
@db.
|
58
|
+
expect(@db).to receive(:"set_node_properties").with(42, { "key" => "value1" })
|
59
59
|
node.key = "value1"
|
60
60
|
|
61
|
-
@db.
|
61
|
+
expect(@db).to receive(:"set_node_properties").with(42, { "key" => "value2" })
|
62
62
|
node.key = "value2"
|
63
63
|
end
|
64
64
|
|
65
65
|
it "knows its attributes" do
|
66
|
-
@db.
|
66
|
+
allow(@db).to receive(:"set_node_properties")
|
67
67
|
node.key = "value"
|
68
68
|
node["key2"] = "value"
|
69
|
-
node.attributes.
|
69
|
+
expect(node.attributes).to match_array([ :key, :key2 ])
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "resets all node properties with one http request" do
|
73
|
+
before(:each) do
|
74
|
+
@change_node = Node.create
|
75
|
+
|
76
|
+
# A property that we will overwrite
|
77
|
+
@change_node[:old_key] = 'value'
|
78
|
+
|
79
|
+
# Stub neo id
|
80
|
+
allow(@change_node).to receive(:neo_id).and_return(22)
|
81
|
+
|
82
|
+
# What we call set_properties with
|
83
|
+
@new_data = { new_key: "new value"}
|
84
|
+
|
85
|
+
# Make sure the request is dispatched to the rest layer
|
86
|
+
expect(@db).to receive(:reset_node_properties).with(22, @new_data)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "removes the old property getter" do
|
90
|
+
expect{
|
91
|
+
@change_node.reset_properties(@new_data)
|
92
|
+
}.to change{@change_node.respond_to?(:old_key)}.from(true).to(false)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "removes the old property setter" do
|
96
|
+
expect{
|
97
|
+
@change_node.reset_properties(@new_data)
|
98
|
+
}.to change{@change_node.respond_to?('old_key=')}.from(true).to(false)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "removes the property from the underlying openstruct" do
|
102
|
+
expect{
|
103
|
+
@change_node.reset_properties(@new_data)
|
104
|
+
}.to change{@change_node['old_key']}.from('value').to(nil)
|
105
|
+
end
|
106
|
+
|
107
|
+
it "adds the new property getter" do
|
108
|
+
expect{
|
109
|
+
@change_node.reset_properties(@new_data)
|
110
|
+
}.to change{@change_node.respond_to?(:new_key)}.from(false).to(true)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "adds the new property setter" do
|
114
|
+
expect{
|
115
|
+
@change_node.reset_properties(@new_data)
|
116
|
+
}.to change{@change_node.respond_to?('new_key=')}.from(false).to(true)
|
117
|
+
end
|
118
|
+
|
119
|
+
it "adds the new property to the underlying openstruct" do
|
120
|
+
expect{
|
121
|
+
@change_node.reset_properties(@new_data)
|
122
|
+
}.to change{@change_node['new_key']}.from(nil).to('new value')
|
123
|
+
end
|
124
|
+
|
125
|
+
it "updates its attributes" do
|
126
|
+
expect{
|
127
|
+
@change_node.reset_properties(@new_data)
|
128
|
+
}.to change{@change_node.attributes}.from([:old_key]).to([:new_key])
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
describe "sets all node properties with one http request" do
|
134
|
+
before(:each) do
|
135
|
+
@change_node = Node.create
|
136
|
+
|
137
|
+
# A property that we will overwrite
|
138
|
+
@change_node[:old_key] = 'value'
|
139
|
+
|
140
|
+
# A property that we will not overwrite and that must stay
|
141
|
+
@change_node[:old_remaining_key] = 'remaining value'
|
142
|
+
|
143
|
+
# Stub neo id
|
144
|
+
allow(@change_node).to receive(:neo_id).and_return(22)
|
145
|
+
|
146
|
+
# What we call set_properties with
|
147
|
+
@new_data = { "new_key" => "new value", 'old_key' => nil }
|
148
|
+
|
149
|
+
# What we expect neography to send as the new properties
|
150
|
+
update_data = { new_key: 'new value', old_remaining_key: 'remaining value'}
|
151
|
+
|
152
|
+
# Make sure the request is dispatched to the rest layer
|
153
|
+
expect(@db).to receive(:reset_node_properties).with(22, update_data)
|
154
|
+
end
|
155
|
+
|
156
|
+
it "removes the old property getter" do
|
157
|
+
expect{
|
158
|
+
@change_node.set_properties(@new_data)
|
159
|
+
}.to change{@change_node.respond_to?(:old_key)}.from(true).to(false)
|
160
|
+
end
|
161
|
+
|
162
|
+
it "removes the old property setter" do
|
163
|
+
expect{
|
164
|
+
@change_node.set_properties(@new_data)
|
165
|
+
}.to change{@change_node.respond_to?('old_key=')}.from(true).to(false)
|
166
|
+
end
|
167
|
+
|
168
|
+
it "removes the property from the underlying openstruct" do
|
169
|
+
expect{
|
170
|
+
@change_node.set_properties(@new_data)
|
171
|
+
}.to change{@change_node['old_key']}.from('value').to(nil)
|
172
|
+
end
|
173
|
+
|
174
|
+
it "doesn't touch the remaining property in the openstruct" do
|
175
|
+
expect{
|
176
|
+
@change_node.set_properties(@new_data)
|
177
|
+
}.to_not change{@change_node['old_remaining_key']}
|
178
|
+
end
|
179
|
+
|
180
|
+
it "doesn't touch the remaining property getter" do
|
181
|
+
expect{
|
182
|
+
@change_node.set_properties(@new_data)
|
183
|
+
}.to_not change{@change_node.respond_to?(:old_remaining_key)}
|
184
|
+
end
|
185
|
+
|
186
|
+
it "doesn't touch the remaining property setter" do
|
187
|
+
expect{
|
188
|
+
@change_node.set_properties(@new_data)
|
189
|
+
}.to_not change{@change_node.respond_to?('old_remaining_key=')}
|
190
|
+
end
|
191
|
+
|
192
|
+
it "adds the new property getter" do
|
193
|
+
expect{
|
194
|
+
@change_node.set_properties(@new_data)
|
195
|
+
}.to change{@change_node.respond_to?(:new_key)}.from(false).to(true)
|
196
|
+
end
|
197
|
+
|
198
|
+
it "adds the new property setter" do
|
199
|
+
expect{
|
200
|
+
@change_node.set_properties(@new_data)
|
201
|
+
}.to change{@change_node.respond_to?('new_key=')}.from(false).to(true)
|
202
|
+
end
|
203
|
+
|
204
|
+
it "adds the new property to the underlying openstruct" do
|
205
|
+
expect{
|
206
|
+
@change_node.set_properties(@new_data)
|
207
|
+
}.to change{@change_node['new_key']}.from(nil).to('new value')
|
208
|
+
end
|
209
|
+
|
210
|
+
it "updates its attributes" do
|
211
|
+
expect{
|
212
|
+
@change_node.set_properties(@new_data)
|
213
|
+
}.to change{@change_node.attributes}.from([:old_key, :old_remaining_key]).to([:old_remaining_key, :new_key])
|
214
|
+
end
|
70
215
|
end
|
71
216
|
|
72
217
|
end
|
@@ -78,61 +223,61 @@ module Neography
|
|
78
223
|
to = Node.create
|
79
224
|
|
80
225
|
rel = Relationship.create(:type, from, to)
|
81
|
-
rel.
|
226
|
+
allow(rel).to receive(:neo_id).and_return(42)
|
82
227
|
rel
|
83
228
|
end
|
84
229
|
|
85
230
|
it "sets properties as accessor" do
|
86
|
-
@db.
|
231
|
+
expect(@db).to receive(:"set_relationship_properties").with(42, { "key" => "value" })
|
87
232
|
relationship.key = "value"
|
88
233
|
end
|
89
234
|
|
90
235
|
it "sets properties as array entry" do
|
91
|
-
@db.
|
236
|
+
expect(@db).to receive(:"set_relationship_properties").with(42, { "key" => "value" })
|
92
237
|
relationship["key"] = "value"
|
93
238
|
end
|
94
239
|
|
95
240
|
it "gets properties as accessor" do
|
96
|
-
@db.
|
241
|
+
allow(@db).to receive(:"set_relationship_properties")
|
97
242
|
relationship.key = "value"
|
98
|
-
relationship.key.
|
243
|
+
expect(relationship.key).to eq("value")
|
99
244
|
end
|
100
245
|
|
101
246
|
it "gets properties as array entry" do
|
102
|
-
@db.
|
247
|
+
allow(@db).to receive(:"set_relationship_properties")
|
103
248
|
relationship["key"] = "value"
|
104
|
-
relationship["key"].
|
249
|
+
expect(relationship["key"]).to eq("value")
|
105
250
|
end
|
106
251
|
|
107
252
|
it "resets properties as accessor" do
|
108
|
-
@db.
|
253
|
+
expect(@db).to receive(:"remove_relationship_properties").with(42, ["key"])
|
109
254
|
relationship.key = "value"
|
110
255
|
relationship.key = nil
|
111
256
|
end
|
112
257
|
|
113
258
|
it "resets properties as array entry" do
|
114
|
-
@db.
|
259
|
+
expect(@db).to receive(:"remove_relationship_properties").with(42, ["key"])
|
115
260
|
relationship["key"] = "value"
|
116
261
|
relationship["key"] = nil
|
117
262
|
end
|
118
263
|
|
119
264
|
it "gets unknown properties as nil" do
|
120
|
-
relationship.unknown.
|
265
|
+
expect(relationship.unknown).to eq(nil)
|
121
266
|
end
|
122
267
|
|
123
268
|
it "overwrites existing properties" do
|
124
|
-
@db.
|
269
|
+
expect(@db).to receive(:"set_relationship_properties").with(42, { "key" => "value1" })
|
125
270
|
relationship.key = "value1"
|
126
271
|
|
127
|
-
@db.
|
272
|
+
expect(@db).to receive(:"set_relationship_properties").with(42, { "key" => "value2" })
|
128
273
|
relationship.key = "value2"
|
129
274
|
end
|
130
275
|
|
131
276
|
it "knows its attributes" do
|
132
|
-
@db.
|
277
|
+
allow(@db).to receive(:"set_relationship_properties")
|
133
278
|
relationship.key = "value"
|
134
279
|
relationship["key2"] = "value"
|
135
|
-
relationship.attributes.
|
280
|
+
expect(relationship.attributes).to match_array([ :key, :key2 ])
|
136
281
|
end
|
137
282
|
|
138
283
|
end
|
@@ -19,19 +19,19 @@ module Neography
|
|
19
19
|
|
20
20
|
describe "::create" do
|
21
21
|
it "creates a new node through Rest" do
|
22
|
-
db.
|
22
|
+
expect(db).to receive(:create_relationship).with("type", from, to, props)
|
23
23
|
|
24
24
|
Relationship.create("type", from, to, props)
|
25
25
|
end
|
26
26
|
|
27
27
|
it "assigns fields" do
|
28
|
-
db.
|
28
|
+
allow(db).to receive(:create_relationship).and_return(relationship_hash)
|
29
29
|
|
30
30
|
rel = Relationship.create("type", from, to, props)
|
31
31
|
|
32
|
-
rel.start_node.
|
33
|
-
rel.end_node.
|
34
|
-
rel.rel_type.
|
32
|
+
expect(rel.start_node).to eq(from)
|
33
|
+
expect(rel.end_node).to eq(to)
|
34
|
+
expect(rel.rel_type).to eq("type")
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -41,22 +41,22 @@ module Neography
|
|
41
41
|
before do
|
42
42
|
# stub out actual connections
|
43
43
|
@db = double(Rest).as_null_object
|
44
|
-
Rest.
|
44
|
+
allow(Rest).to receive(:new) { @db }
|
45
45
|
end
|
46
46
|
|
47
47
|
it "load by id" do
|
48
|
-
@db.
|
48
|
+
expect(@db).to receive(:get_relationship).with(5)
|
49
49
|
Relationship.load(5)
|
50
50
|
end
|
51
51
|
|
52
52
|
it "loads by relationship" do
|
53
53
|
relationship = Relationship.new(relationship_hash)
|
54
|
-
@db.
|
54
|
+
expect(@db).to receive(:get_relationship).with(relationship)
|
55
55
|
Relationship.load(relationship)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "loads by full server string" do
|
59
|
-
@db.
|
59
|
+
expect(@db).to receive(:get_relationship).with("http://localhost:7474/db/data/relationship/2")
|
60
60
|
Relationship.load("http://localhost:7474/db/data/relationship/2")
|
61
61
|
end
|
62
62
|
|
@@ -66,7 +66,7 @@ module Neography
|
|
66
66
|
|
67
67
|
it "cannot pass a server as the first argument, relationship as the second" do
|
68
68
|
@other_server = Neography::Rest.new
|
69
|
-
@other_server.
|
69
|
+
expect(@other_server).not_to receive(:get_relationship).with(42)
|
70
70
|
expect {
|
71
71
|
relationship = Relationship.load(@other_server, 42)
|
72
72
|
}.to raise_error(ArgumentError)
|
@@ -74,7 +74,7 @@ module Neography
|
|
74
74
|
|
75
75
|
it "can pass a relationship as the first argument, server as the second" do
|
76
76
|
@other_server = Neography::Rest.new
|
77
|
-
@other_server.
|
77
|
+
expect(@other_server).to receive(:get_relationship).with(42)
|
78
78
|
relationship = Relationship.load(42, @other_server)
|
79
79
|
end
|
80
80
|
|
@@ -84,13 +84,13 @@ module Neography
|
|
84
84
|
describe "#del" do
|
85
85
|
|
86
86
|
before do
|
87
|
-
db.
|
87
|
+
allow(db).to receive(:create_relationship) { relationship_hash }
|
88
88
|
end
|
89
89
|
|
90
90
|
subject(:relationship) { Relationship.create("type", from, to, props) }
|
91
91
|
|
92
92
|
it "deletes a node" do
|
93
|
-
db.
|
93
|
+
expect(db).to receive(:delete_relationship).with("0")
|
94
94
|
relationship.del
|
95
95
|
end
|
96
96
|
|
@@ -99,17 +99,17 @@ module Neography
|
|
99
99
|
describe "#other_node" do
|
100
100
|
|
101
101
|
before do
|
102
|
-
db.
|
102
|
+
allow(db).to receive(:create_relationship) { relationship_hash }
|
103
103
|
end
|
104
104
|
|
105
105
|
subject(:relationship) { Relationship.create("type", from, to, props) }
|
106
106
|
|
107
107
|
it "knows the other node based on from" do
|
108
|
-
relationship.other_node(from).
|
108
|
+
expect(relationship.other_node(from)).to eq(to)
|
109
109
|
end
|
110
110
|
|
111
111
|
it "knows the other node based on to" do
|
112
|
-
relationship.other_node(to).
|
112
|
+
expect(relationship.other_node(to)).to eq(from)
|
113
113
|
end
|
114
114
|
|
115
115
|
end
|