neography 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/CHANGELOG.md +939 -0
  4. data/Guardfile +14 -0
  5. data/README.md +16 -14
  6. data/lib/neography/connection.rb +1 -0
  7. data/lib/neography/errors.rb +3 -0
  8. data/lib/neography/node.rb +21 -25
  9. data/lib/neography/property.rb +60 -11
  10. data/lib/neography/property_container.rb +5 -6
  11. data/lib/neography/rest/batch.rb +10 -0
  12. data/lib/neography/rest/node_properties.rb +1 -1
  13. data/lib/neography/version.rb +1 -1
  14. data/neography.gemspec +4 -2
  15. data/spec/integration/authorization_spec.rb +4 -4
  16. data/spec/integration/broken_spatial_spec.rb +6 -6
  17. data/spec/integration/index_spec.rb +6 -6
  18. data/spec/integration/neography_spec.rb +1 -1
  19. data/spec/integration/node_encoding_spec.rb +19 -19
  20. data/spec/integration/node_path_spec.rb +36 -36
  21. data/spec/integration/node_relationship_spec.rb +84 -84
  22. data/spec/integration/node_spec.rb +50 -50
  23. data/spec/integration/parsing_spec.rb +2 -2
  24. data/spec/integration/relationship_spec.rb +10 -10
  25. data/spec/integration/rest_batch_no_streaming_spec.rb +6 -6
  26. data/spec/integration/rest_batch_spec.rb +209 -188
  27. data/spec/integration/rest_batch_streaming_spec.rb +8 -8
  28. data/spec/integration/rest_bulk_spec.rb +23 -23
  29. data/spec/integration/rest_constraints_spec.rb +17 -17
  30. data/spec/integration/rest_experimental_spec.rb +2 -2
  31. data/spec/integration/rest_gremlin_fail_spec.rb +4 -4
  32. data/spec/integration/rest_header_spec.rb +3 -2
  33. data/spec/integration/rest_index_spec.rb +76 -76
  34. data/spec/integration/rest_labels_spec.rb +13 -13
  35. data/spec/integration/rest_node_spec.rb +50 -50
  36. data/spec/integration/rest_other_node_relationship_spec.rb +50 -50
  37. data/spec/integration/rest_path_spec.rb +55 -55
  38. data/spec/integration/rest_plugin_spec.rb +59 -59
  39. data/spec/integration/rest_relationship_spec.rb +77 -77
  40. data/spec/integration/rest_relationship_types_spec.rb +2 -2
  41. data/spec/integration/rest_schema_index_spec.rb +6 -6
  42. data/spec/integration/rest_spatial_spec.rb +50 -50
  43. data/spec/integration/rest_transaction_spec.rb +67 -67
  44. data/spec/integration/rest_traverse_spec.rb +40 -40
  45. data/spec/integration/unmanaged_spec.rb +3 -3
  46. data/spec/matchers.rb +2 -2
  47. data/spec/neography_spec.rb +3 -3
  48. data/spec/spec_helper.rb +2 -2
  49. data/spec/unit/config_spec.rb +95 -20
  50. data/spec/unit/connection_spec.rb +40 -40
  51. data/spec/unit/node_spec.rb +12 -12
  52. data/spec/unit/properties_spec.rb +174 -29
  53. data/spec/unit/relationship_spec.rb +16 -16
  54. data/spec/unit/rest/batch_spec.rb +23 -23
  55. data/spec/unit/rest/clean_spec.rb +1 -1
  56. data/spec/unit/rest/constraints_spec.rb +6 -6
  57. data/spec/unit/rest/cypher_spec.rb +1 -1
  58. data/spec/unit/rest/extensions_spec.rb +2 -2
  59. data/spec/unit/rest/gremlin_spec.rb +3 -3
  60. data/spec/unit/rest/helpers_spec.rb +19 -19
  61. data/spec/unit/rest/labels_spec.rb +10 -10
  62. data/spec/unit/rest/node_auto_indexes_spec.rb +13 -13
  63. data/spec/unit/rest/node_indexes_spec.rb +22 -22
  64. data/spec/unit/rest/node_paths_spec.rb +7 -7
  65. data/spec/unit/rest/node_properties_spec.rb +15 -15
  66. data/spec/unit/rest/node_relationships_spec.rb +10 -10
  67. data/spec/unit/rest/node_traversal_spec.rb +1 -1
  68. data/spec/unit/rest/nodes_spec.rb +32 -32
  69. data/spec/unit/rest/relationship_auto_indexes_spec.rb +12 -12
  70. data/spec/unit/rest/relationship_indexes_spec.rb +21 -21
  71. data/spec/unit/rest/relationship_properties_spec.rb +15 -15
  72. data/spec/unit/rest/relationship_types_spec.rb +1 -1
  73. data/spec/unit/rest/relationships_spec.rb +2 -2
  74. data/spec/unit/rest/schema_index_spec.rb +3 -3
  75. data/spec/unit/rest/transactions_spec.rb +4 -4
  76. metadata +32 -3
  77. data/ChangeLog +0 -658
@@ -5,25 +5,25 @@ describe Neography::Node do
5
5
  describe "create and new" do
6
6
  it "can create an empty node" do
7
7
  new_node = Neography::Node.create
8
- new_node.should_not be_nil
8
+ expect(new_node).not_to be_nil
9
9
  end
10
10
 
11
11
  it "can create a node with one property" do
12
12
  new_node = Neography::Node.create("name" => "Max")
13
- new_node.name.should == "Max"
13
+ expect(new_node.name).to eq("Max")
14
14
  end
15
15
 
16
16
  it "can create a node with more than one property" do
17
17
  new_node = Neography::Node.create("age" => 31, "name" => "Max")
18
- new_node.name.should == "Max"
19
- new_node.age.should == 31
18
+ expect(new_node.name).to eq("Max")
19
+ expect(new_node.age).to eq(31)
20
20
  end
21
21
 
22
22
  it "can create a node with more than one property not on the default rest server" do
23
23
  @neo = Neography::Rest.new
24
24
  new_node = Neography::Node.create({"age" => 31, "name" => "Max"}, @neo)
25
- new_node.name.should == "Max"
26
- new_node.age.should == 31
25
+ expect(new_node.name).to eq("Max")
26
+ expect(new_node.age).to eq(31)
27
27
  end
28
28
 
29
29
  it "cannot create a node with more than one property not on the default rest server the other way" do
@@ -39,9 +39,9 @@ describe Neography::Node do
39
39
  it "can get a node that exists" do
40
40
  new_node = Neography::Node.create
41
41
  existing_node = Neography::Node.load(new_node)
42
- existing_node.should_not be_nil
43
- existing_node.neo_id.should_not be_nil
44
- existing_node.neo_id.should == new_node.neo_id
42
+ expect(existing_node).not_to be_nil
43
+ expect(existing_node.neo_id).not_to be_nil
44
+ expect(existing_node.neo_id).to eq(new_node.neo_id)
45
45
  end
46
46
 
47
47
  it "raises an error if it tries to load a node that does not exist" do
@@ -56,9 +56,9 @@ describe Neography::Node do
56
56
  @neo = Neography::Rest.new
57
57
  new_node = Neography::Node.create({}, @neo)
58
58
  existing_node = Neography::Node.load(new_node, @neo)
59
- existing_node.should_not be_nil
60
- existing_node.neo_id.should_not be_nil
61
- existing_node.neo_id.should == new_node.neo_id
59
+ expect(existing_node).not_to be_nil
60
+ expect(existing_node.neo_id).not_to be_nil
61
+ expect(existing_node.neo_id).to eq(new_node.neo_id)
62
62
  end
63
63
 
64
64
  it "cannot load a node that exists not on the default rest server the other way" do
@@ -77,9 +77,9 @@ describe Neography::Node do
77
77
  @neo.add_node_to_index("test_node_index", key, value, new_node)
78
78
  node_from_index = @neo.get_node_index("test_node_index", key, value)
79
79
  existing_node = Neography::Node.load(node_from_index)
80
- existing_node.should_not be_nil
81
- existing_node.neo_id.should_not be_nil
82
- existing_node.neo_id.should == new_node.neo_id
80
+ expect(existing_node).not_to be_nil
81
+ expect(existing_node.neo_id).not_to be_nil
82
+ expect(existing_node.neo_id).to eq(new_node.neo_id)
83
83
  end
84
84
 
85
85
  it "can get a node that exists via cypher" do
@@ -88,9 +88,9 @@ describe Neography::Node do
88
88
  @neo = Neography::Rest.new
89
89
  results = @neo.execute_query(cypher, {:id => new_node.neo_id.to_i})
90
90
  existing_node = Neography::Node.load(results)
91
- existing_node.should_not be_nil
92
- existing_node.neo_id.should_not be_nil
93
- existing_node.neo_id.should == new_node.neo_id
91
+ expect(existing_node).not_to be_nil
92
+ expect(existing_node.neo_id).not_to be_nil
93
+ expect(existing_node.neo_id).to eq(new_node.neo_id)
94
94
  end
95
95
 
96
96
 
@@ -110,13 +110,13 @@ describe Neography::Node do
110
110
  describe "exists?" do
111
111
  it "can tell if it exists" do
112
112
  new_node = Neography::Node.create
113
- new_node.exist?.should be_true
113
+ expect(new_node.exist?).to be true
114
114
  end
115
115
 
116
116
  it "can tell if does not exists" do
117
117
  new_node = Neography::Node.create
118
118
  new_node.del
119
- new_node.exist?.should be_false
119
+ expect(new_node.exist?).to be false
120
120
  end
121
121
  end
122
122
 
@@ -124,19 +124,19 @@ describe Neography::Node do
124
124
  it "can tell two nodes are the same with equal?" do
125
125
  new_node = Neography::Node.create
126
126
  another_node = Neography::Node.load(new_node)
127
- new_node.equal?(another_node).should be_true
127
+ expect(new_node.equal?(another_node)).to be true
128
128
  end
129
129
 
130
130
  it "can tell two nodes are the same with eql?" do
131
131
  new_node = Neography::Node.create
132
132
  another_node = Neography::Node.load(new_node)
133
- new_node.eql?(another_node).should be_true
133
+ expect(new_node.eql?(another_node)).to be true
134
134
  end
135
135
 
136
136
  it "can tell two nodes are the same with ==" do
137
137
  new_node = Neography::Node.create
138
138
  another_node = Neography::Node.load(new_node)
139
- (new_node == another_node).should be_true
139
+ expect(new_node == another_node).to be true
140
140
  end
141
141
  end
142
142
 
@@ -148,8 +148,8 @@ describe Neography::Node do
148
148
  new_node[:eyes] = "brown"
149
149
 
150
150
  existing_node = Neography::Node.load(new_node)
151
- existing_node.weight.should == 200
152
- existing_node.eyes.should == "brown"
151
+ expect(existing_node.weight).to eq(200)
152
+ expect(existing_node.eyes).to eq("brown")
153
153
  end
154
154
 
155
155
  it "can change a node's properties that already exist" do
@@ -159,8 +159,8 @@ describe Neography::Node do
159
159
  new_node.eyes = "brown"
160
160
 
161
161
  existing_node = Neography::Node.load(new_node)
162
- existing_node.weight.should == 200
163
- existing_node.eyes.should == "brown"
162
+ expect(existing_node.weight).to eq(200)
163
+ expect(existing_node.eyes).to eq("brown")
164
164
  end
165
165
 
166
166
  it "can change a node's properties that does not already exist using []=" do
@@ -171,9 +171,9 @@ describe Neography::Node do
171
171
  new_node[:hair] = "black"
172
172
 
173
173
  existing_node = Neography::Node.load(new_node)
174
- existing_node.weight.should == 200
175
- existing_node.eyes.should == "brown"
176
- existing_node.hair.should == "black"
174
+ expect(existing_node.weight).to eq(200)
175
+ expect(existing_node.eyes).to eq("brown")
176
+ expect(existing_node.hair).to eq("black")
177
177
  end
178
178
 
179
179
  it "can change a node's properties that does not already exist" do
@@ -182,23 +182,23 @@ describe Neography::Node do
182
182
  new_node.hair = "black"
183
183
 
184
184
  existing_node = Neography::Node.load(new_node)
185
- existing_node.hair.should == "black"
185
+ expect(existing_node.hair).to eq("black")
186
186
  end
187
187
 
188
188
  it "can pass issue 18" do
189
189
  n = Neography::Node.create("name" => "Test")
190
190
  n.prop = 1
191
- n.prop.should == 1
191
+ expect(n.prop).to eq(1)
192
192
  n.prop = 1
193
- n.prop.should == 1
194
- n[:prop].should == 1
193
+ expect(n.prop).to eq(1)
194
+ expect(n[:prop]).to eq(1)
195
195
  n[:prop2] = 2
196
- n[:prop2].should == 2
196
+ expect(n[:prop2]).to eq(2)
197
197
  n[:prop2] = 2
198
- n[:prop2].should == 2
198
+ expect(n[:prop2]).to eq(2)
199
199
  n.name
200
200
  n.name = "New Name"
201
- n.name.should == "New Name"
201
+ expect(n.name).to eq("New Name")
202
202
  end
203
203
 
204
204
  end
@@ -206,14 +206,14 @@ describe Neography::Node do
206
206
  describe "get node properties" do
207
207
  it "can get node properties using []" do
208
208
  new_node = Neography::Node.create("weight" => 150, "eyes" => "green")
209
- new_node[:weight].should == 150
210
- new_node[:eyes].should == "green"
209
+ expect(new_node[:weight]).to eq(150)
210
+ expect(new_node[:eyes]).to eq("green")
211
211
  end
212
212
 
213
213
  it "can get node properties" do
214
214
  new_node = Neography::Node.create("weight" => 150, "eyes" => "green")
215
- new_node.weight.should == 150
216
- new_node.eyes.should == "green"
215
+ expect(new_node.weight).to eq(150)
216
+ expect(new_node.eyes).to eq("green")
217
217
  end
218
218
  end
219
219
 
@@ -224,12 +224,12 @@ describe Neography::Node do
224
224
  new_node[:weight] = nil
225
225
  new_node[:eyes] = nil
226
226
 
227
- new_node[:weight].should be_nil
228
- new_node[:eyes].should be_nil
227
+ expect(new_node[:weight]).to be_nil
228
+ expect(new_node[:eyes]).to be_nil
229
229
 
230
230
  existing_node = Neography::Node.load(new_node)
231
- existing_node.weight.should be_nil
232
- existing_node.eyes.should be_nil
231
+ expect(existing_node.weight).to be_nil
232
+ expect(existing_node.eyes).to be_nil
233
233
  end
234
234
 
235
235
  it "can delete node properties" do
@@ -238,12 +238,12 @@ describe Neography::Node do
238
238
  new_node.weight = nil
239
239
  new_node.eyes = nil
240
240
 
241
- new_node.weight.should be_nil
242
- new_node.eyes.should be_nil
241
+ expect(new_node.weight).to be_nil
242
+ expect(new_node.eyes).to be_nil
243
243
 
244
244
  existing_node = Neography::Node.load(new_node)
245
- existing_node.weight.should be_nil
246
- existing_node.eyes.should be_nil
245
+ expect(existing_node.weight).to be_nil
246
+ expect(existing_node.eyes).to be_nil
247
247
  end
248
248
  end
249
249
 
@@ -255,6 +255,6 @@ describe Neography::Node do
255
255
  node
256
256
  }
257
257
 
258
- it { subject.labels.should == %w(Label Label2) }
258
+ it { expect(subject.labels).to eq(%w(Label Label2)) }
259
259
  end
260
260
  end
@@ -6,8 +6,8 @@ describe Neography do
6
6
  it 'should not convert strings to symbol' do
7
7
  node = subject.create_node({:text => ':1456'})
8
8
 
9
- node['data']['text'].class.should == String # fails! expected: String got: Symbol (using ==)
10
- node['data']['text'].should == ':1456'
9
+ expect(node['data']['text'].class).to eq(String) # fails! expected: String got: Symbol (using ==)
10
+ expect(node['data']['text']).to eq(':1456')
11
11
  end
12
12
  end
13
13
  end
@@ -7,8 +7,8 @@ describe Neography::Relationship do
7
7
  p2 = Neography::Node.create
8
8
 
9
9
  Neography::Relationship.create(:family, p1, p2)
10
- p1.outgoing(:family).should include(p2)
11
- p2.incoming(:family).should include(p1)
10
+ expect(p1.outgoing(:family)).to include(p2)
11
+ expect(p2.incoming(:family)).to include(p1)
12
12
  end
13
13
 
14
14
  it "#new(:family, p1, p2, :since => '1998', :colour => 'blue') creates relationship and sets its properties" do
@@ -16,10 +16,10 @@ describe Neography::Relationship do
16
16
  p2 = Neography::Node.create
17
17
  rel = Neography::Relationship.create(:family, p1, p2, :since => 1998, :colour => 'blue')
18
18
 
19
- rel[:since].should == 1998
20
- rel[:colour].should == 'blue'
21
- rel.since.should == 1998
22
- rel.colour.should == 'blue'
19
+ expect(rel[:since]).to eq(1998)
20
+ expect(rel[:colour]).to eq('blue')
21
+ expect(rel.since).to eq(1998)
22
+ expect(rel.colour).to eq('blue')
23
23
  end
24
24
 
25
25
  it "#outgoing(:friends).create(other) creates a new relationship between self and other node" do
@@ -27,10 +27,10 @@ describe Neography::Relationship do
27
27
  p2 = Neography::Node.create
28
28
  rel = p1.outgoing(:foo).create(p2)
29
29
 
30
- rel.should be_kind_of(Neography::Relationship)
31
- p1.outgoing(:foo).first.should == p2
32
- p1.outgoing(:foo).should include(p2)
33
- p2.incoming(:foo).should include(p1)
30
+ expect(rel).to be_kind_of(Neography::Relationship)
31
+ expect(p1.outgoing(:foo).first).to eq(p2)
32
+ expect(p1.outgoing(:foo)).to include(p2)
33
+ expect(p2.incoming(:foo)).to include(p1)
34
34
  end
35
35
  end
36
36
 
@@ -13,8 +13,8 @@ describe Neography::Rest do
13
13
  commands << [:create_node, {"name" => "Max " + x.to_s}]
14
14
  end
15
15
  batch_result = @neo.batch_no_streaming *commands
16
- batch_result.first["body"]["data"]["name"].should == "Max 0"
17
- batch_result.last["body"]["data"]["name"].should == "Max 999"
16
+ expect(batch_result.first["body"]["data"]["name"]).to eq("Max 0")
17
+ expect(batch_result.last["body"]["data"]["name"]).to eq("Max 999")
18
18
  end
19
19
 
20
20
  it "can send a 5000 item batch" do
@@ -23,8 +23,8 @@ describe Neography::Rest do
23
23
  commands << [:get_node, 0]
24
24
  end
25
25
  batch_result = @neo.batch_no_streaming *commands
26
- batch_result.first["body"]["self"].split('/').last.should == "0"
27
- batch_result.last["body"]["self"].split('/').last.should == "0"
26
+ expect(batch_result.first["body"]["self"].split('/').last).to eq("0")
27
+ expect(batch_result.last["body"]["self"].split('/').last).to eq("0")
28
28
  end
29
29
 
30
30
  it "can send a 20000 item batch" do
@@ -33,8 +33,8 @@ describe Neography::Rest do
33
33
  commands << [:create_node, {"name" => "Max " + x.to_s}]
34
34
  end
35
35
  batch_result = @neo.batch_no_streaming *commands
36
- batch_result.first["body"]["data"]["name"].should == "Max 0"
37
- batch_result.last["body"]["data"]["name"].should == "Max 19999"
36
+ expect(batch_result.first["body"]["data"]["name"]).to eq("Max 0")
37
+ expect(batch_result.last["body"]["data"]["name"]).to eq("Max 19999")
38
38
  end
39
39
  end
40
40
 
@@ -10,11 +10,11 @@ describe Neography::Rest do
10
10
  new_node = @neo.create_node
11
11
  new_node[:id] = new_node["self"].split('/').last
12
12
  batch_result = @neo.batch [:get_node, new_node]
13
- batch_result.first.should_not be_nil
14
- batch_result.first.should have_key("id")
15
- batch_result.first.should have_key("body")
16
- batch_result.first.should have_key("from")
17
- batch_result.first["body"]["self"].split('/').last.should == new_node[:id]
13
+ expect(batch_result.first).not_to be_nil
14
+ expect(batch_result.first).to have_key("id")
15
+ expect(batch_result.first).to have_key("body")
16
+ expect(batch_result.first).to have_key("from")
17
+ expect(batch_result.first["body"]["self"].split('/').last).to eq(new_node[:id])
18
18
  end
19
19
 
20
20
  it "can get multiple nodes" do
@@ -24,33 +24,33 @@ describe Neography::Rest do
24
24
  node2[:id] = node2["self"].split('/').last
25
25
 
26
26
  batch_result = @neo.batch [:get_node, node1], [:get_node, node2]
27
- batch_result.first.should_not be_nil
28
- batch_result.first.should have_key("id")
29
- batch_result.first.should have_key("body")
30
- batch_result.first.should have_key("from")
31
- batch_result.first["body"]["self"].split('/').last.should == node1[:id]
32
- batch_result.last.should have_key("id")
33
- batch_result.last.should have_key("body")
34
- batch_result.last.should have_key("from")
35
- batch_result.last["body"]["self"].split('/').last.should == node2[:id]
27
+ expect(batch_result.first).not_to be_nil
28
+ expect(batch_result.first).to have_key("id")
29
+ expect(batch_result.first).to have_key("body")
30
+ expect(batch_result.first).to have_key("from")
31
+ expect(batch_result.first["body"]["self"].split('/').last).to eq(node1[:id])
32
+ expect(batch_result.last).to have_key("id")
33
+ expect(batch_result.last).to have_key("body")
34
+ expect(batch_result.last).to have_key("from")
35
+ expect(batch_result.last["body"]["self"].split('/').last).to eq(node2[:id])
36
36
 
37
37
  end
38
38
 
39
39
  it "can create a single node" do
40
40
  batch_result = @neo.batch [:create_node, {"name" => "Max"}]
41
- batch_result.first["body"]["data"]["name"].should == "Max"
41
+ expect(batch_result.first["body"]["data"]["name"]).to eq("Max")
42
42
  end
43
43
 
44
44
  it "can create multiple nodes" do
45
45
  batch_result = @neo.batch [:create_node, {"name" => "Max"}], [:create_node, {"name" => "Marc"}]
46
- batch_result.first["body"]["data"]["name"].should == "Max"
47
- batch_result.last["body"]["data"]["name"].should == "Marc"
46
+ expect(batch_result.first["body"]["data"]["name"]).to eq("Max")
47
+ expect(batch_result.last["body"]["data"]["name"]).to eq("Marc")
48
48
  end
49
49
 
50
50
  it "can create multiple nodes given an *array" do
51
51
  batch_result = @neo.batch *[[:create_node, {"name" => "Max"}], [:create_node, {"name" => "Marc"}]]
52
- batch_result.first["body"]["data"]["name"].should == "Max"
53
- batch_result.last["body"]["data"]["name"].should == "Marc"
52
+ expect(batch_result.first["body"]["data"]["name"]).to eq("Max")
53
+ expect(batch_result.last["body"]["data"]["name"]).to eq("Marc")
54
54
  end
55
55
 
56
56
  it "can create a unique node" do
@@ -59,94 +59,108 @@ describe Neography::Rest do
59
59
  value = generate_text
60
60
  @neo.create_node_index(index_name)
61
61
  batch_result = @neo.batch [:create_unique_node, index_name, key, value, {"age" => 31, "name" => "Max"}]
62
- batch_result.first["body"]["data"]["name"].should == "Max"
63
- batch_result.first["body"]["data"]["age"].should == 31
62
+ expect(batch_result.first["body"]["data"]["name"]).to eq("Max")
63
+ expect(batch_result.first["body"]["data"]["age"]).to eq(31)
64
64
  new_node_id = batch_result.first["body"]["self"].split('/').last
65
65
  batch_result = @neo.batch [:create_unique_node, index_name, key, value, {"age" => 31, "name" => "Max"}]
66
- batch_result.first["body"]["self"].split('/').last.should == new_node_id
67
- batch_result.first["body"]["data"]["name"].should == "Max"
68
- batch_result.first["body"]["data"]["age"].should == 31
66
+ expect(batch_result.first["body"]["self"].split('/').last).to eq(new_node_id)
67
+ expect(batch_result.first["body"]["data"]["name"]).to eq("Max")
68
+ expect(batch_result.first["body"]["data"]["age"]).to eq(31)
69
69
 
70
70
  #Sanity Check
71
71
  existing_node = @neo.create_unique_node(index_name, key, value, {"age" => 31, "name" => "Max"})
72
- existing_node["self"].split('/').last.should == new_node_id
73
- existing_node["data"]["name"].should == "Max"
74
- existing_node["data"]["age"].should == 31
72
+ expect(existing_node["self"].split('/').last).to eq(new_node_id)
73
+ expect(existing_node["data"]["name"]).to eq("Max")
74
+ expect(existing_node["data"]["age"]).to eq(31)
75
75
  end
76
76
 
77
+ it "can create or fail a unique node" do
78
+ index_name = generate_text(6)
79
+ key = generate_text(6)
80
+ value = generate_text
81
+ @neo.create_node_index(index_name)
82
+ batch_result = @neo.batch [:create_or_fail_unique_node, index_name, key, value, {"age" => 31, "name" => "Max"}]
83
+ expect(batch_result.first["body"]["data"]["name"]).to eq("Max")
84
+ expect(batch_result.first["body"]["data"]["age"]).to eq(31)
85
+ new_node_id = batch_result.first["body"]["self"].split('/').last
86
+ expect {
87
+ batch_result = @neo.batch [:create_or_fail_unique_node, index_name, key, value, {"age" => 31, "name" => "Max"}]
88
+ }.to raise_error Neography::OperationFailureException
89
+
90
+ end
77
91
  it "can update a property of a node" do
78
92
  new_node = @neo.create_node("name" => "Max")
79
93
  batch_result = @neo.batch [:set_node_property, new_node, {"name" => "Marc"}]
80
- batch_result.first.should have_key("id")
81
- batch_result.first.should have_key("from")
94
+ expect(batch_result.first).to have_key("id")
95
+ expect(batch_result.first).to have_key("from")
82
96
  existing_node = @neo.get_node(new_node)
83
- existing_node["data"]["name"].should == "Marc"
97
+ expect(existing_node["data"]["name"]).to eq("Marc")
84
98
  end
85
99
 
86
100
  it "can update a property of multiple nodes" do
87
101
  node1 = @neo.create_node("name" => "Max")
88
102
  node2 = @neo.create_node("name" => "Marc")
89
103
  batch_result = @neo.batch [:set_node_property, node1, {"name" => "Tom"}], [:set_node_property, node2, {"name" => "Jerry"}]
90
- batch_result.first.should have_key("id")
91
- batch_result.first.should have_key("from")
92
- batch_result.last.should have_key("id")
93
- batch_result.last.should have_key("from")
104
+ expect(batch_result.first).to have_key("id")
105
+ expect(batch_result.first).to have_key("from")
106
+ expect(batch_result.last).to have_key("id")
107
+ expect(batch_result.last).to have_key("from")
94
108
  existing_node = @neo.get_node(node1)
95
- existing_node["data"]["name"].should == "Tom"
109
+ expect(existing_node["data"]["name"]).to eq("Tom")
96
110
  existing_node = @neo.get_node(node2)
97
- existing_node["data"]["name"].should == "Jerry"
111
+ expect(existing_node["data"]["name"]).to eq("Jerry")
98
112
  end
99
113
 
100
114
  it "can reset the properties of a node" do
101
115
  new_node = @neo.create_node("name" => "Max", "weight" => 200)
102
116
  batch_result = @neo.batch [:reset_node_properties, new_node, {"name" => "Marc"}]
103
- batch_result.first.should have_key("id")
104
- batch_result.first.should have_key("from")
117
+ expect(batch_result.first).to have_key("id")
118
+ expect(batch_result.first).to have_key("from")
105
119
  existing_node = @neo.get_node(new_node)
106
- existing_node["data"]["name"].should == "Marc"
107
- existing_node["data"]["weight"].should be_nil
120
+ expect(existing_node["data"]["name"]).to eq("Marc")
121
+ expect(existing_node["data"]["weight"]).to be_nil
108
122
  end
109
123
 
110
124
  it "can reset the properties of multiple nodes" do
111
125
  node1 = @neo.create_node("name" => "Max", "weight" => 200)
112
126
  node2 = @neo.create_node("name" => "Marc", "weight" => 180)
113
127
  batch_result = @neo.batch [:reset_node_properties, node1, {"name" => "Tom"}], [:reset_node_properties, node2, {"name" => "Jerry"}]
114
- batch_result.first.should have_key("id")
115
- batch_result.first.should have_key("from")
116
- batch_result.last.should have_key("id")
117
- batch_result.last.should have_key("from")
128
+ expect(batch_result.first).to have_key("id")
129
+ expect(batch_result.first).to have_key("from")
130
+ expect(batch_result.last).to have_key("id")
131
+ expect(batch_result.last).to have_key("from")
118
132
  existing_node = @neo.get_node(node1)
119
- existing_node["data"]["name"].should == "Tom"
120
- existing_node["data"]["weight"].should be_nil
133
+ expect(existing_node["data"]["name"]).to eq("Tom")
134
+ expect(existing_node["data"]["weight"]).to be_nil
121
135
  existing_node = @neo.get_node(node2)
122
- existing_node["data"]["name"].should == "Jerry"
123
- existing_node["data"]["weight"].should be_nil
136
+ expect(existing_node["data"]["name"]).to eq("Jerry")
137
+ expect(existing_node["data"]["weight"]).to be_nil
124
138
  end
125
139
 
126
140
  it "can remove a property of a node" do
127
141
  new_node = @neo.create_node("name" => "Max", "weight" => 200)
128
142
  batch_result = @neo.batch [:remove_node_property, new_node, "weight"]
129
- batch_result.first.should have_key("id")
130
- batch_result.first.should have_key("from")
143
+ expect(batch_result.first).to have_key("id")
144
+ expect(batch_result.first).to have_key("from")
131
145
  existing_node = @neo.get_node(new_node)
132
- existing_node["data"]["name"].should == "Max"
133
- existing_node["data"]["weight"].should be_nil
146
+ expect(existing_node["data"]["name"]).to eq("Max")
147
+ expect(existing_node["data"]["weight"]).to be_nil
134
148
  end
135
149
 
136
150
  it "can remove a property of multiple nodes" do
137
151
  node1 = @neo.create_node("name" => "Max", "weight" => 200)
138
152
  node2 = @neo.create_node("name" => "Marc", "weight" => 180)
139
153
  batch_result = @neo.batch [:remove_node_property, node1, "name"], [:remove_node_property, node2, "name"]
140
- batch_result.first.should have_key("id")
141
- batch_result.first.should have_key("from")
142
- batch_result.last.should have_key("id")
143
- batch_result.last.should have_key("from")
154
+ expect(batch_result.first).to have_key("id")
155
+ expect(batch_result.first).to have_key("from")
156
+ expect(batch_result.last).to have_key("id")
157
+ expect(batch_result.last).to have_key("from")
144
158
  existing_node = @neo.get_node(node1)
145
- existing_node["data"]["name"].should be_nil
146
- existing_node["data"]["weight"].should == 200
159
+ expect(existing_node["data"]["name"]).to be_nil
160
+ expect(existing_node["data"]["weight"]).to eq(200)
147
161
  existing_node = @neo.get_node(node2)
148
- existing_node["data"]["name"].should be_nil
149
- existing_node["data"]["weight"].should == 180
162
+ expect(existing_node["data"]["name"]).to be_nil
163
+ expect(existing_node["data"]["weight"]).to eq(180)
150
164
  end
151
165
 
152
166
  it "can get a single relationship" do
@@ -154,42 +168,42 @@ describe Neography::Rest do
154
168
  node2 = @neo.create_node
155
169
  new_relationship = @neo.create_relationship("friends", node1, node2)
156
170
  batch_result = @neo.batch [:get_relationship, new_relationship]
157
- batch_result.first["body"]["type"].should == "friends"
158
- batch_result.first["body"]["start"].split('/').last.should == node1["self"].split('/').last
159
- batch_result.first["body"]["end"].split('/').last.should == node2["self"].split('/').last
160
- batch_result.first["body"]["self"].should == new_relationship["self"]
171
+ expect(batch_result.first["body"]["type"]).to eq("friends")
172
+ expect(batch_result.first["body"]["start"].split('/').last).to eq(node1["self"].split('/').last)
173
+ expect(batch_result.first["body"]["end"].split('/').last).to eq(node2["self"].split('/').last)
174
+ expect(batch_result.first["body"]["self"]).to eq(new_relationship["self"])
161
175
  end
162
176
 
163
177
  it "can create a single relationship without properties" do
164
178
  node1 = @neo.create_node
165
179
  node2 = @neo.create_node
166
180
  batch_result = @neo.batch [:create_relationship, "friends", node1, node2]
167
- batch_result.first["body"]["type"].should == "friends"
168
- batch_result.first["body"]["data"]["since"].should be_nil
169
- batch_result.first["body"]["start"].split('/').last.should == node1["self"].split('/').last
170
- batch_result.first["body"]["end"].split('/').last.should == node2["self"].split('/').last
181
+ expect(batch_result.first["body"]["type"]).to eq("friends")
182
+ expect(batch_result.first["body"]["data"]["since"]).to be_nil
183
+ expect(batch_result.first["body"]["start"].split('/').last).to eq(node1["self"].split('/').last)
184
+ expect(batch_result.first["body"]["end"].split('/').last).to eq(node2["self"].split('/').last)
171
185
  end
172
186
 
173
187
  it "can create a single relationship" do
174
188
  node1 = @neo.create_node
175
189
  node2 = @neo.create_node
176
190
  batch_result = @neo.batch [:create_relationship, "friends", node1, node2, {:since => "high school"}]
177
- batch_result.first["body"]["type"].should == "friends"
178
- batch_result.first["body"]["data"]["since"].should == "high school"
179
- batch_result.first["body"]["start"].split('/').last.should == node1["self"].split('/').last
180
- batch_result.first["body"]["end"].split('/').last.should == node2["self"].split('/').last
191
+ expect(batch_result.first["body"]["type"]).to eq("friends")
192
+ expect(batch_result.first["body"]["data"]["since"]).to eq("high school")
193
+ expect(batch_result.first["body"]["start"].split('/').last).to eq(node1["self"].split('/').last)
194
+ expect(batch_result.first["body"]["end"].split('/').last).to eq(node2["self"].split('/').last)
181
195
  end
182
196
 
183
197
  it "can delete a single relationship" do
184
198
  node1 = @neo.create_node
185
199
  node2 = @neo.create_node
186
200
  batch_result = @neo.batch [:create_relationship, "friends", node1, node2, {:since => "time immemorial"}]
187
- batch_result.should_not be_nil
188
- batch_result[0]["status"].should == 201
201
+ expect(batch_result).not_to be_nil
202
+ expect(batch_result[0]["status"]).to eq(201)
189
203
  id = batch_result.first["body"]["self"].split("/").last
190
204
  batch_result = @neo.batch [:delete_relationship, id]
191
- batch_result[0]["status"].should == 204
192
- batch_result[0]["from"].should == "/relationship/#{id}"
205
+ expect(batch_result[0]["status"]).to eq(204)
206
+ expect(batch_result[0]["from"]).to eq("/relationship/#{id}")
193
207
  end
194
208
 
195
209
  it "can create a unique relationship" do
@@ -200,9 +214,9 @@ describe Neography::Rest do
200
214
  node1 = @neo.create_node
201
215
  node2 = @neo.create_node
202
216
  batch_result = @neo.batch [:create_unique_relationship, index_name, key, value, "friends", node1, node2]
203
- batch_result.first["body"]["type"].should == "friends"
204
- batch_result.first["body"]["start"].split('/').last.should == node1["self"].split('/').last
205
- batch_result.first["body"]["end"].split('/').last.should == node2["self"].split('/').last
217
+ expect(batch_result.first["body"]["type"]).to eq("friends")
218
+ expect(batch_result.first["body"]["start"].split('/').last).to eq(node1["self"].split('/').last)
219
+ expect(batch_result.first["body"]["end"].split('/').last).to eq(node2["self"].split('/').last)
206
220
  end
207
221
 
208
222
  it "can update a single relationship" do
@@ -210,14 +224,14 @@ describe Neography::Rest do
210
224
  node2 = @neo.create_node
211
225
  new_relationship = @neo.create_relationship("friends", node1, node2, {:since => "high school"})
212
226
  batch_result = @neo.batch [:set_relationship_property, new_relationship, {:since => "college"}]
213
- batch_result.first.should have_key("id")
214
- batch_result.first.should have_key("from")
227
+ expect(batch_result.first).to have_key("id")
228
+ expect(batch_result.first).to have_key("from")
215
229
  existing_relationship = @neo.get_relationship(new_relationship)
216
- existing_relationship["type"].should == "friends"
217
- existing_relationship["data"]["since"].should == "college"
218
- existing_relationship["start"].split('/').last.should == node1["self"].split('/').last
219
- existing_relationship["end"].split('/').last.should == node2["self"].split('/').last
220
- existing_relationship["self"].should == new_relationship["self"]
230
+ expect(existing_relationship["type"]).to eq("friends")
231
+ expect(existing_relationship["data"]["since"]).to eq("college")
232
+ expect(existing_relationship["start"].split('/').last).to eq(node1["self"].split('/').last)
233
+ expect(existing_relationship["end"].split('/').last).to eq(node2["self"].split('/').last)
234
+ expect(existing_relationship["self"]).to eq(new_relationship["self"])
221
235
  end
222
236
 
223
237
  it "can reset the properties of a relationship" do
@@ -225,22 +239,22 @@ describe Neography::Rest do
225
239
  node2 = @neo.create_node
226
240
  new_relationship = @neo.create_relationship("friends", node1, node2, {:since => "high school"})
227
241
  batch_result = @neo.batch [:reset_relationship_properties, new_relationship, {"since" => "college", "dated" => "yes"}]
228
- batch_result.first.should have_key("id")
229
- batch_result.first.should have_key("from")
242
+ expect(batch_result.first).to have_key("id")
243
+ expect(batch_result.first).to have_key("from")
230
244
  existing_relationship = @neo.get_relationship(batch_result.first["from"].split('/')[2])
231
- existing_relationship["type"].should == "friends"
232
- existing_relationship["data"]["since"].should == "college"
233
- existing_relationship["data"]["dated"].should == "yes"
234
- existing_relationship["start"].split('/').last.should == node1["self"].split('/').last
235
- existing_relationship["end"].split('/').last.should == node2["self"].split('/').last
236
- existing_relationship["self"].should == new_relationship["self"]
245
+ expect(existing_relationship["type"]).to eq("friends")
246
+ expect(existing_relationship["data"]["since"]).to eq("college")
247
+ expect(existing_relationship["data"]["dated"]).to eq("yes")
248
+ expect(existing_relationship["start"].split('/').last).to eq(node1["self"].split('/').last)
249
+ expect(existing_relationship["end"].split('/').last).to eq(node2["self"].split('/').last)
250
+ expect(existing_relationship["self"]).to eq(new_relationship["self"])
237
251
  end
238
252
 
239
253
  it "can drop a node index" do
240
254
  index_name = generate_text(6)
241
255
  @neo.create_node_index(index_name)
242
256
  @neo.batch [:drop_node_index, index_name]
243
- @neo.list_node_indexes[index_name].should be_nil
257
+ expect(@neo.list_node_indexes[index_name]).to be_nil
244
258
  end
245
259
 
246
260
  it "can create a node index" do
@@ -248,9 +262,9 @@ describe Neography::Rest do
248
262
  @neo.batch [:create_node_index, index_name, "fulltext", "lucene"]
249
263
  indexes = @neo.list_node_indexes
250
264
  index = indexes[index_name]
251
- index.should_not be_nil
252
- index["provider"].should == "lucene"
253
- index["type"].should == "fulltext"
265
+ expect(index).not_to be_nil
266
+ expect(index["provider"]).to eq("lucene")
267
+ expect(index["type"]).to eq("fulltext")
254
268
  end
255
269
 
256
270
  it "can add a node to an index" do
@@ -259,11 +273,11 @@ describe Neography::Rest do
259
273
  key = generate_text(6)
260
274
  value = generate_text
261
275
  batch_result = @neo.batch [:add_node_to_index, index_name, key, value, new_node]
262
- batch_result.first.should have_key("id")
263
- batch_result.first.should have_key("from")
276
+ expect(batch_result.first).to have_key("id")
277
+ expect(batch_result.first).to have_key("from")
264
278
  existing_index = @neo.find_node_index(index_name, key, value)
265
- existing_index.should_not be_nil
266
- existing_index.first["self"].should == new_node["self"]
279
+ expect(existing_index).not_to be_nil
280
+ expect(existing_index.first["self"]).to eq(new_node["self"])
267
281
  @neo.remove_node_from_index(index_name, key, value, new_node)
268
282
  end
269
283
 
@@ -275,9 +289,9 @@ describe Neography::Rest do
275
289
  new_node = @neo.create_node
276
290
  @neo.add_node_to_index(index_name, key, value, new_node)
277
291
  batch_result = @neo.batch [:get_node_index, index_name, key, value]
278
- batch_result.first.should have_key("id")
279
- batch_result.first.should have_key("from")
280
- batch_result.first["body"].first["self"].should == new_node["self"]
292
+ expect(batch_result.first).to have_key("id")
293
+ expect(batch_result.first).to have_key("from")
294
+ expect(batch_result.first["body"].first["self"]).to eq(new_node["self"])
281
295
  @neo.remove_node_from_index(index_name, key, value, new_node)
282
296
  end
283
297
 
@@ -291,43 +305,50 @@ describe Neography::Rest do
291
305
  new_relationship = @neo.create_relationship("friends", node1, node2, {:since => "high school"})
292
306
  @neo.add_relationship_to_index(index_name, key, value, new_relationship)
293
307
  batch_result = @neo.batch [:get_relationship_index, index_name, key, value]
294
- batch_result.first.should have_key("id")
295
- batch_result.first.should have_key("from")
296
- batch_result.first["body"].first["type"].should == "friends"
297
- batch_result.first["body"].first["start"].split('/').last.should == node1["self"].split('/').last
298
- batch_result.first["body"].first["end"].split('/').last.should == node2["self"].split('/').last
308
+ expect(batch_result.first).to have_key("id")
309
+ expect(batch_result.first).to have_key("from")
310
+ expect(batch_result.first["body"].first["type"]).to eq("friends")
311
+ expect(batch_result.first["body"].first["start"].split('/').last).to eq(node1["self"].split('/').last)
312
+ expect(batch_result.first["body"].first["end"].split('/').last).to eq(node2["self"].split('/').last)
299
313
  end
300
314
 
301
315
  it "can batch gremlin", :gremlin => true do
302
316
  batch_result = @neo.batch [:execute_script, "g.v(0)"]
303
- batch_result.first.should have_key("id")
304
- batch_result.first.should have_key("from")
305
- batch_result.first["body"]["self"].split('/').last.should == "0"
317
+ expect(batch_result.first).to have_key("id")
318
+ expect(batch_result.first).to have_key("from")
319
+ expect(batch_result.first["body"]["self"].split('/').last).to eq("0")
306
320
  end
307
321
 
308
322
  it "can batch gremlin with parameters", :gremlin => true do
309
323
  new_node = @neo.create_node
310
324
  id = new_node["self"].split('/').last
311
325
  batch_result = @neo.batch [:execute_script, "g.v(id)", {:id => id.to_i}]
312
- batch_result.first.should have_key("id")
313
- batch_result.first.should have_key("from")
314
- batch_result.first["body"]["self"].split('/').last.should == id
326
+ expect(batch_result.first).to have_key("id")
327
+ expect(batch_result.first).to have_key("from")
328
+ expect(batch_result.first["body"]["self"].split('/').last).to eq(id)
315
329
  end
316
330
 
317
331
  it "can batch cypher" do
318
332
  batch_result = @neo.batch [:execute_query, "start n=node(0) return n"]
319
- batch_result.first.should have_key("id")
320
- batch_result.first.should have_key("from")
321
- batch_result.first["body"]["data"][0][0]["self"].split('/').last.should == "0"
333
+ expect(batch_result.first).to have_key("id")
334
+ expect(batch_result.first).to have_key("from")
335
+ expect(batch_result.first["body"]["data"][0][0]["self"].split('/').last).to eq("0")
322
336
  end
323
337
 
324
338
  it "can batch cypher with parameters" do
325
339
  new_node = @neo.create_node
326
340
  id = new_node["self"].split('/').last
327
341
  batch_result = @neo.batch [:execute_query, "start n=node({id}) return n", {:id => id.to_i}]
328
- batch_result.first.should have_key("id")
329
- batch_result.first.should have_key("from")
330
- batch_result.first["body"]["data"][0][0]["self"].split('/').last.should == id
342
+ expect(batch_result.first).to have_key("id")
343
+ expect(batch_result.first).to have_key("from")
344
+ expect(batch_result.first["body"]["data"][0][0]["self"].split('/').last).to eq(id)
345
+ end
346
+
347
+ it "raises ParameterNotFoundException when a cypher parameter is missing and ORDER BY is used" do
348
+ q = "MATCH n WHERE n.x>{missing_parameter} RETURN n ORDER BY n"
349
+ expect{
350
+ @neo.batch [:execute_query, q, {}]
351
+ }.to raise_error Neography::ParameterNotFoundException
331
352
  end
332
353
 
333
354
  it "can delete a node in batch" do
@@ -337,10 +358,10 @@ describe Neography::Rest do
337
358
  id2 = node2['self'].split('/').last
338
359
  batch_result = @neo.batch [:delete_node, id1 ], [:delete_node, id2]
339
360
  expect {
340
- @neo.get_node(node1).should be_nil
361
+ expect(@neo.get_node(node1)).to be_nil
341
362
  }.to raise_error Neography::NodeNotFoundException
342
363
  expect {
343
- @neo.get_node(node2).should be_nil
364
+ expect(@neo.get_node(node2)).to be_nil
344
365
  }.to raise_error Neography::NodeNotFoundException
345
366
  end
346
367
 
@@ -359,9 +380,9 @@ describe Neography::Rest do
359
380
  [:remove_node_from_index, index, key, node2 ],
360
381
  [:remove_node_from_index, index, node3 ]
361
382
 
362
- @neo.get_node_index(index, key, value1).should be_nil
363
- @neo.get_node_index(index, key, value2).should be_nil
364
- @neo.get_node_index(index, key, value3).should be_nil
383
+ expect(@neo.get_node_index(index, key, value1)).to be_nil
384
+ expect(@neo.get_node_index(index, key, value2)).to be_nil
385
+ expect(@neo.get_node_index(index, key, value3)).to be_nil
365
386
  end
366
387
 
367
388
  it "can remove a relationship from an index in batch" do
@@ -378,8 +399,8 @@ describe Neography::Rest do
378
399
  batch_result = @neo.batch [:remove_relationship_from_index, index, key, relationship1],
379
400
  [:remove_relationship_from_index, index, key, relationship2]
380
401
 
381
- @neo.get_relationship_index(index, key, value1).should be_nil
382
- @neo.get_relationship_index(index, key, value2).should be_nil
402
+ expect(@neo.get_relationship_index(index, key, value1)).to be_nil
403
+ expect(@neo.get_relationship_index(index, key, value2)).to be_nil
383
404
  end
384
405
 
385
406
  it "can do spatial via Cypher in batch" do
@@ -390,47 +411,47 @@ describe Neography::Rest do
390
411
  [:execute_query, "start n = node:geobatchcypher({withinDistance}) return n", {:withinDistance => "withinDistance:[60.0,15.0,100.0]"}],
391
412
  [:execute_query, "start n = node:geobatchcypher({bbox}) return n", {:bbox => "bbox:[15.0,15.3,60.0,60.2]"}]
392
413
 
393
- batch_result[0]["body"]["provider"].should == "spatial"
394
- batch_result[0]["body"]["geometry_type"].should == "point"
395
- batch_result[0]["body"]["lat"].should == "lat"
396
- batch_result[0]["body"]["lon"].should == "lon"
397
- batch_result[1]["from"].should == "/index/node/geobatchcypher"
398
- batch_result[1]["body"]["data"].should == {"lat" => 60.1, "lon" => 15.2}
399
- batch_result[2]["body"]["data"].should_not be_empty
400
- batch_result[3]["body"]["data"].should_not be_empty
414
+ expect(batch_result[0]["body"]["provider"]).to eq("spatial")
415
+ expect(batch_result[0]["body"]["geometry_type"]).to eq("point")
416
+ expect(batch_result[0]["body"]["lat"]).to eq("lat")
417
+ expect(batch_result[0]["body"]["lon"]).to eq("lon")
418
+ expect(batch_result[1]["from"]).to eq("/index/node/geobatchcypher")
419
+ expect(batch_result[1]["body"]["data"]).to eq({"lat" => 60.1, "lon" => 15.2})
420
+ expect(batch_result[2]["body"]["data"]).not_to be_empty
421
+ expect(batch_result[3]["body"]["data"]).not_to be_empty
401
422
  end
402
423
  end
403
424
 
404
425
  describe "referenced batch" do
405
426
  it "can create a relationship from two newly created nodes" do
406
427
  batch_result = @neo.batch [:create_node, {"name" => "Max"}], [:create_node, {"name" => "Marc"}], [:create_relationship, "friends", "{0}", "{1}", {:since => "high school"}]
407
- batch_result.first["body"]["data"]["name"].should == "Max"
408
- batch_result[1]["body"]["data"]["name"].should == "Marc"
409
- batch_result.last["body"]["type"].should == "friends"
410
- batch_result.last["body"]["data"]["since"].should == "high school"
411
- batch_result.last["body"]["start"].split('/').last.should == batch_result.first["body"]["self"].split('/').last
412
- batch_result.last["body"]["end"].split('/').last.should == batch_result[1]["body"]["self"].split('/').last
428
+ expect(batch_result.first["body"]["data"]["name"]).to eq("Max")
429
+ expect(batch_result[1]["body"]["data"]["name"]).to eq("Marc")
430
+ expect(batch_result.last["body"]["type"]).to eq("friends")
431
+ expect(batch_result.last["body"]["data"]["since"]).to eq("high school")
432
+ expect(batch_result.last["body"]["start"].split('/').last).to eq(batch_result.first["body"]["self"].split('/').last)
433
+ expect(batch_result.last["body"]["end"].split('/').last).to eq(batch_result[1]["body"]["self"].split('/').last)
413
434
  end
414
435
 
415
436
  it "can create a relationship from an existing node and a newly created node" do
416
437
  node1 = @neo.create_node("name" => "Max", "weight" => 200)
417
438
  batch_result = @neo.batch [:create_node, {"name" => "Marc"}], [:create_relationship, "friends", "{0}", node1, {:since => "high school"}]
418
- batch_result.first["body"]["data"]["name"].should == "Marc"
419
- batch_result.last["body"]["type"].should == "friends"
420
- batch_result.last["body"]["data"]["since"].should == "high school"
421
- batch_result.last["body"]["start"].split('/').last.should == batch_result.first["body"]["self"].split('/').last
422
- batch_result.last["body"]["end"].split('/').last.should == node1["self"].split('/').last
439
+ expect(batch_result.first["body"]["data"]["name"]).to eq("Marc")
440
+ expect(batch_result.last["body"]["type"]).to eq("friends")
441
+ expect(batch_result.last["body"]["data"]["since"]).to eq("high school")
442
+ expect(batch_result.last["body"]["start"].split('/').last).to eq(batch_result.first["body"]["self"].split('/').last)
443
+ expect(batch_result.last["body"]["end"].split('/').last).to eq(node1["self"].split('/').last)
423
444
  end
424
445
 
425
446
  it "can add a newly created node to an index" do
426
447
  key = generate_text(6)
427
448
  value = generate_text
428
449
  batch_result = @neo.batch [:create_node, {"name" => "Max"}], [:add_node_to_index, "test_node_index", key, value, "{0}"]
429
- batch_result.first.should have_key("id")
430
- batch_result.first.should have_key("from")
450
+ expect(batch_result.first).to have_key("id")
451
+ expect(batch_result.first).to have_key("from")
431
452
  existing_index = @neo.find_node_index("test_node_index", key, value)
432
- existing_index.should_not be_nil
433
- existing_index.first["self"].should == batch_result.first["body"]["self"]
453
+ expect(existing_index).not_to be_nil
454
+ expect(existing_index.first["self"]).to eq(batch_result.first["body"]["self"])
434
455
  @neo.remove_node_from_index("test_node_index", key, value, batch_result.first["body"]["self"].split('/').last)
435
456
  end
436
457
 
@@ -440,28 +461,28 @@ describe Neography::Rest do
440
461
  node1 = @neo.create_node
441
462
  node2 = @neo.create_node
442
463
  batch_result = @neo.batch [:create_relationship, "friends", node1, node2, {:since => "high school"}], [:add_relationship_to_index, "test_relationship_index", key, value, "{0}"]
443
- batch_result.first["body"]["type"].should == "friends"
444
- batch_result.first["body"]["data"]["since"].should == "high school"
445
- batch_result.first["body"]["start"].split('/').last.should == node1["self"].split('/').last
446
- batch_result.first["body"]["end"].split('/').last.should == node2["self"].split('/').last
464
+ expect(batch_result.first["body"]["type"]).to eq("friends")
465
+ expect(batch_result.first["body"]["data"]["since"]).to eq("high school")
466
+ expect(batch_result.first["body"]["start"].split('/').last).to eq(node1["self"].split('/').last)
467
+ expect(batch_result.first["body"]["end"].split('/').last).to eq(node2["self"].split('/').last)
447
468
  existing_index = @neo.find_relationship_index("test_relationship_index", key, value)
448
- existing_index.should_not be_nil
449
- existing_index.first["self"].should == batch_result.first["body"]["self"]
469
+ expect(existing_index).not_to be_nil
470
+ expect(existing_index.first["self"]).to eq(batch_result.first["body"]["self"])
450
471
  end
451
472
 
452
473
  it "can reset the properties of a newly created relationship" do
453
474
  node1 = @neo.create_node
454
475
  node2 = @neo.create_node
455
476
  batch_result = @neo.batch [:create_relationship, "friends", node1, node2, {:since => "high school"}], [:reset_relationship_properties, "{0}", {"since" => "college", "dated" => "yes"}]
456
- batch_result.first.should have_key("id")
457
- batch_result.first.should have_key("from")
477
+ expect(batch_result.first).to have_key("id")
478
+ expect(batch_result.first).to have_key("from")
458
479
  existing_relationship = @neo.get_relationship(batch_result.first["body"]["self"].split('/').last)
459
- existing_relationship["type"].should == "friends"
460
- existing_relationship["data"]["since"].should == "college"
461
- existing_relationship["data"]["dated"].should == "yes"
462
- existing_relationship["start"].split('/').last.should == node1["self"].split('/').last
463
- existing_relationship["end"].split('/').last.should == node2["self"].split('/').last
464
- existing_relationship["self"].should == batch_result.first["body"]["self"]
480
+ expect(existing_relationship["type"]).to eq("friends")
481
+ expect(existing_relationship["data"]["since"]).to eq("college")
482
+ expect(existing_relationship["data"]["dated"]).to eq("yes")
483
+ expect(existing_relationship["start"].split('/').last).to eq(node1["self"].split('/').last)
484
+ expect(existing_relationship["end"].split('/').last).to eq(node2["self"].split('/').last)
485
+ expect(existing_relationship["self"]).to eq(batch_result.first["body"]["self"])
465
486
  end
466
487
 
467
488
  it "can kitchen sink" do
@@ -474,7 +495,7 @@ describe Neography::Rest do
474
495
  [:add_node_to_index, "test_node_index", key, value, "{1}"]
475
496
  [:create_relationship, "friends", "{0}", "{1}", {:since => "college"}]
476
497
  [:add_relationship_to_index, "test_relationship_index", key, value, "{4}"]
477
- batch_result.should_not be_nil
498
+ expect(batch_result).not_to be_nil
478
499
  end
479
500
 
480
501
  it "can get multiple relationships" do
@@ -484,15 +505,15 @@ describe Neography::Rest do
484
505
  new_relationship1 = @neo.create_relationship("friends", node1, node2)
485
506
  new_relationship2 = @neo.create_relationship("brothers", node1, node3)
486
507
  batch_result = @neo.batch [:get_node_relationships, node1]
487
- batch_result.first["body"].length.should be(2)
488
- batch_result.first["body"][0]["type"].should == "friends"
489
- batch_result.first["body"][0]["start"].split('/').last.should == node1["self"].split('/').last
490
- batch_result.first["body"][0]["end"].split('/').last.should == node2["self"].split('/').last
491
- batch_result.first["body"][0]["self"].should == new_relationship1["self"]
492
- batch_result.first["body"][1]["type"].should == "brothers"
493
- batch_result.first["body"][1]["start"].split('/').last.should == node1["self"].split('/').last
494
- batch_result.first["body"][1]["end"].split('/').last.should == node3["self"].split('/').last
495
- batch_result.first["body"][1]["self"].should == new_relationship2["self"]
508
+ expect(batch_result.first["body"].length).to be(2)
509
+ expect(batch_result.first["body"][0]["type"]).to eq("friends")
510
+ expect(batch_result.first["body"][0]["start"].split('/').last).to eq(node1["self"].split('/').last)
511
+ expect(batch_result.first["body"][0]["end"].split('/').last).to eq(node2["self"].split('/').last)
512
+ expect(batch_result.first["body"][0]["self"]).to eq(new_relationship1["self"])
513
+ expect(batch_result.first["body"][1]["type"]).to eq("brothers")
514
+ expect(batch_result.first["body"][1]["start"].split('/').last).to eq(node1["self"].split('/').last)
515
+ expect(batch_result.first["body"][1]["end"].split('/').last).to eq(node3["self"].split('/').last)
516
+ expect(batch_result.first["body"][1]["self"]).to eq(new_relationship2["self"])
496
517
  end
497
518
 
498
519
  it "can get relationships of specific type" do
@@ -502,11 +523,11 @@ describe Neography::Rest do
502
523
  new_relationship1 = @neo.create_relationship("friends", node1, node2)
503
524
  new_relationship2 = @neo.create_relationship("brothers", node1, node3)
504
525
  batch_result = @neo.batch [:get_node_relationships, node1, "out", "friends"]
505
- batch_result.first["body"].length.should be(1)
506
- batch_result.first["body"][0]["type"].should == "friends"
507
- batch_result.first["body"][0]["start"].split('/').last.should == node1["self"].split('/').last
508
- batch_result.first["body"][0]["end"].split('/').last.should == node2["self"].split('/').last
509
- batch_result.first["body"][0]["self"].should == new_relationship1["self"]
526
+ expect(batch_result.first["body"].length).to be(1)
527
+ expect(batch_result.first["body"][0]["type"]).to eq("friends")
528
+ expect(batch_result.first["body"][0]["start"].split('/').last).to eq(node1["self"].split('/').last)
529
+ expect(batch_result.first["body"][0]["end"].split('/').last).to eq(node2["self"].split('/').last)
530
+ expect(batch_result.first["body"][0]["self"]).to eq(new_relationship1["self"])
510
531
  end
511
532
 
512
533
  it "can create a relationship from a unique node" do
@@ -514,7 +535,7 @@ describe Neography::Rest do
514
535
  [:add_node_to_index, "person_ssn", "ssn", "000-00-0001", "{0}"],
515
536
  [:create_unique_node, "person", "ssn", "000-00-0001", {:first_name=>"Jane", :last_name=>"Doe", :ssn=>"000-00-0001", :_type=>"Person", :created_at=>1335269478}],
516
537
  [:create_relationship, "has", "{0}", "{2}", {}]
517
- batch_result.should_not be_nil
538
+ expect(batch_result).not_to be_nil
518
539
 
519
540
  # create_unique_node is returning an index result, not a node, so we can't do this yet.
520
541
  # See https://github.com/neo4j/community/issues/697
@@ -532,12 +553,12 @@ describe Neography::Rest do
532
553
  [:create_node, {:street1=>"94437 Kemmer Crossing", :street2=>"Apt. 333", :city=>"Abshireton", :state=>"AA", :zip=>"65820", :_type=>"Address", :created_at=>1335269478}],
533
554
  [:create_relationship, "has", "{0}", "{2}", {}]
534
555
  rescue Neography::NeographyError => e
535
- e.message.should == "Not Found"
536
- e.code.should == 404
537
- e.stacktrace.should be_nil
538
- e.request[:path].should == "/db/data/batch"
539
- e.request[:body].should_not be_nil
540
- e.index.should == 3
556
+ expect(e.message).to eq("Not Found")
557
+ expect(e.code).to eq(404)
558
+ expect(e.stacktrace).to be_nil
559
+ expect(e.request[:path]).to eq("/db/data/batch")
560
+ expect(e.request[:body]).not_to be_nil
561
+ expect(e.index).to eq(3)
541
562
  end
542
563
  end
543
564