arangorb 0.1.0 → 1.0.0

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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/ArangoRB.gemspec +2 -2
  3. data/README.md +418 -123
  4. data/lib/ArangoRB_AQL.rb +90 -103
  5. data/lib/ArangoRB_Col.rb +476 -159
  6. data/lib/ArangoRB_DB.rb +305 -79
  7. data/lib/ArangoRB_Doc.rb +112 -114
  8. data/lib/ArangoRB_Edg.rb +81 -62
  9. data/lib/ArangoRB_Gra.rb +125 -76
  10. data/lib/ArangoRB_Index.rb +144 -0
  11. data/lib/ArangoRB_Ser.rb +439 -18
  12. data/lib/ArangoRB_Task.rb +136 -0
  13. data/lib/ArangoRB_Tra.rb +47 -42
  14. data/lib/ArangoRB_Tran.rb +48 -0
  15. data/lib/ArangoRB_User.rb +152 -0
  16. data/lib/ArangoRB_Ver.rb +74 -57
  17. data/lib/arangorb.rb +4 -0
  18. data/spec/arangoRB_helper.rb +2 -9
  19. data/spec/arangoRestart_helper.rb +14 -0
  20. data/spec/lib/{arangoAQL_helper.rb → 0.1.0/arangoAQL_helper.rb} +2 -21
  21. data/spec/lib/{arangoC_helper.rb → 0.1.0/arangoC_helper.rb} +40 -19
  22. data/spec/lib/{arangoDB_helper.rb → 0.1.0/arangoDB_helper.rb} +13 -13
  23. data/spec/lib/{arangoDoc_helper.rb → 0.1.0/arangoDoc_helper.rb} +10 -23
  24. data/spec/lib/0.1.0/arangoE_helper.rb +50 -0
  25. data/spec/lib/{arangoG_helper.rb → 0.1.0/arangoG_helper.rb} +7 -21
  26. data/spec/lib/0.1.0/arangoS_helper.rb +37 -0
  27. data/spec/lib/0.1.0/arangoT_helper.rb +48 -0
  28. data/spec/lib/{arangoV_helper.rb → 0.1.0/arangoV_helper.rb} +6 -22
  29. data/spec/lib/1.0.0/arangoC_helper.rb +73 -0
  30. data/spec/lib/1.0.0/arangoDB_helper.rb +81 -0
  31. data/spec/lib/1.0.0/arangoI_helper.rb +43 -0
  32. data/spec/lib/1.0.0/arangoS_helper.rb +196 -0
  33. data/spec/lib/1.0.0/arangoTa_helper.rb +49 -0
  34. data/spec/lib/1.0.0/arangoTr_helper.rb +15 -0
  35. data/spec/lib/1.0.0/arangoU_helper.rb +72 -0
  36. data/spec/lib/arangoRB_0.1.0_helper.rb +9 -0
  37. data/spec/lib/arangoRB_1.0.0_helper.rb +6 -0
  38. data/spec/spec_helper.rb +34 -0
  39. metadata +28 -15
  40. data/spec/lib/arangoE_helper.rb +0 -70
  41. data/spec/lib/arangoS_helper.rb +0 -28
  42. data/spec/lib/arangoT_helper.rb +0 -67
@@ -1,38 +1,26 @@
1
- require_relative './../spec_helper'
2
-
3
- describe ArangoC do
4
- before :all do
5
- ArangoS.default_server user: "root", password: "tretretre", server: "localhost", port: "8529"
6
- ArangoS.database = "MyDatabase"
7
- ArangoS.collection = "MyCollection"
8
- ArangoDB.new.create
9
- @myCollection = ArangoC.new
10
- @myEdgeCollection = ArangoC.new collection: "MyEdgeCollection"
11
- end
12
-
13
- after :all do
14
- ArangoDB.new.destroy
15
- end
1
+ require_relative './../../spec_helper'
16
2
 
3
+ describe ArangoCollection do
17
4
  context "#new" do
18
5
  it "create a new instance without global" do
19
- myCollection = ArangoC.new collection: "MyCollection"
6
+ myCollection = ArangoCollection.new collection: "MyCollection"
20
7
  expect(myCollection.collection).to eq "MyCollection"
21
8
  end
22
9
 
23
10
  it "create a new instance with global" do
24
- myCollection = ArangoC.new
11
+ myCollection = ArangoCollection.new
25
12
  expect(myCollection.collection).to eq "MyCollection"
26
13
  end
27
14
 
28
15
  it "create a new instance with type Edge" do
29
- myCollection = ArangoC.new collection: "MyCollection", type: "Edge"
16
+ myCollection = ArangoCollection.new collection: "MyCollection", type: "Edge"
30
17
  expect(myCollection.type).to eq "Edge"
31
18
  end
32
19
  end
33
20
 
34
21
  context "#create" do
35
22
  it "create a new Collection" do
23
+ @myCollection.destroy
36
24
  myCollection = @myCollection.create
37
25
  expect(myCollection.collection).to eq "MyCollection"
38
26
  end
@@ -43,6 +31,7 @@ describe ArangoC do
43
31
  end
44
32
 
45
33
  it "create a new Edge Collection" do
34
+ @myEdgeCollection.destroy
46
35
  myCollection = @myEdgeCollection.create_edge_collection
47
36
  expect(myCollection.type).to eq "Edge"
48
37
  end
@@ -81,7 +70,7 @@ describe ArangoC do
81
70
  end
82
71
 
83
72
  it "statistics" do
84
- info = @myCollection.stats
73
+ info = @myCollection.statistics
85
74
  expect(info["lastTick"]).to eq "0"
86
75
  end
87
76
 
@@ -105,10 +94,42 @@ describe ArangoC do
105
94
  expect(info.collection).to eq "MyCollection"
106
95
  end
107
96
 
97
+ it "search Document by key match" do
98
+ docs = @myCollection.create_document document: [{"_key" => "ThisIsATest1", "test" => "fantastic"}, {"_key" => "ThisIsATest2"}]
99
+ result = @myCollection.documentByKeys keys: ["ThisIsATest1", docs[1]]
100
+ expect(result[0].body["test"]).to eq "fantastic"
101
+ end
102
+
103
+ it "remove Document by key match" do
104
+ docs = @myCollection.create_document document: [{"_key" => "ThisIsATest3", "test" => "fantastic"}, {"_key" => "ThisIsATest4"}]
105
+ result = @myCollection.removeByKeys keys: ["ThisIsATest3", docs[1]]
106
+ expect(result).to eq 2
107
+ end
108
+
109
+ it "remove Document by match" do
110
+ @myCollection.create_document document: [{"_key" => "ThisIsATest5", "test" => "fantastic"}, {"_key" => "ThisIsATest6"}]
111
+ result = @myCollection.removeMatch match: {"test" => "fantastic"}
112
+ expect(result).to eq 2
113
+ end
114
+
115
+ it "replace Document by match" do
116
+ @myCollection.create_document document: {"test" => "fantastic", "val" => 4}
117
+ result = @myCollection.replaceMatch match: {"test" => "fantastic"}, newValue: {"val" => 5}
118
+ expect(result).to eq 1
119
+ end
120
+
121
+ it "update Document by match" do
122
+ @myCollection.create_document document: {"test" => "fantastic2", "val" => 5}
123
+ result = @myCollection.updateMatch match: {"val" => 5}, newValue: {"val" => 6}
124
+ expect(result).to eq 2
125
+ end
126
+
108
127
  it "search random Document" do
109
128
  info = @myCollection.random
110
129
  expect(info.collection).to eq "MyCollection"
111
130
  end
131
+
132
+
112
133
  end
113
134
 
114
135
  context "#modify" do
@@ -1,26 +1,22 @@
1
- require_relative './../spec_helper'
1
+ require_relative './../../spec_helper'
2
2
 
3
- describe ArangoDB do
4
- before :all do
5
- ArangoS.default_server user: "root", password: "tretretre", server: "localhost", port: "8529"
6
- ArangoS.database = "MyDatabase"
7
- @myDatabase = ArangoDB.new
8
- end
3
+ describe ArangoDatabase do
9
4
 
10
5
  context "#new" do
11
6
  it "create a new instance without global" do
12
- myDatabase = ArangoDB.new database: "MyDatabase"
7
+ myDatabase = ArangoDatabase.new database: "MyDatabase"
13
8
  expect(myDatabase.database).to eq "MyDatabase"
14
9
  end
15
10
 
16
11
  it "create a new instance with global" do
17
- myDatabase = ArangoDB.new
12
+ myDatabase = ArangoDatabase.new
18
13
  expect(myDatabase.database).to eq "MyDatabase"
19
14
  end
20
15
  end
21
16
 
22
17
  context "#create" do
23
18
  it "create a new Database" do
19
+ @myDatabase.destroy
24
20
  myDatabase = @myDatabase.create
25
21
  expect(myDatabase.database).to eq "MyDatabase"
26
22
  end
@@ -33,12 +29,12 @@ describe ArangoDB do
33
29
 
34
30
  context "#info" do
35
31
  it "obtain general info" do
36
- info = ArangoDB.info
37
- expect(info["name"]).to eq "_system"
32
+ info = @myDatabase.info
33
+ expect(info["name"]).to eq "MyDatabase"
38
34
  end
39
35
 
40
36
  it "list databases" do
41
- list = ArangoDB.databases
37
+ list = ArangoDatabase.databases
42
38
  expect(list.length).to be >= 1
43
39
  end
44
40
 
@@ -73,7 +69,11 @@ describe ArangoDB do
73
69
  end
74
70
 
75
71
  it "kill" do
76
- expect(@myDatabase.killQuery(id: "4353453463443").class).to be String
72
+ @myCollection = ArangoCollection.new.create
73
+ @myCollection.create_document document: [{"num" => 1, "_key" => "FirstKey"}, {"num" => 1}, {"num" => 1}, {"num" => 1}, {"num" => 1}, {"num" => 1}, {"num" => 1}, {"num" => 2}, {"num" => 2}, {"num" => 2}, {"num" => 3}, {"num" => 2}, {"num" => 5}, {"num" => 2}]
74
+ @myAQL.size = 3
75
+ @myAQL.execute
76
+ expect((@myDatabase.killQuery query: @myAQL).split(" ")[0]).to eq "cannot"
77
77
  end
78
78
 
79
79
  it "changeProperties" do
@@ -1,41 +1,28 @@
1
- require_relative './../spec_helper'
2
-
3
- describe ArangoDoc do
4
- before :all do
5
- ArangoS.default_server user: "root", password: "tretretre", server: "localhost", port: "8529"
6
- ArangoS.database = "MyDatabase"
7
- ArangoS.collection = "MyCollection"
8
- ArangoDB.new.create
9
- @myCollection = ArangoC.new.create
10
- @myEdgeCollection = ArangoC.new(collection: "MyEdgeCollection").create_edge_collection
11
- @myDocument = ArangoDoc.new body: {"Hello" => "World", "num" => 1}, key: "FirstDocument"
12
- end
13
-
14
- after :all do
15
- ArangoDB.new.destroy
16
- end
1
+ require_relative './../../spec_helper'
17
2
 
3
+ describe ArangoDocument do
18
4
  context "#new" do
19
5
  it "create a new Document instance without global" do
20
- myDocument = ArangoDoc.new collection: "MyCollection", database: "MyDatabase"
6
+ myDocument = ArangoDocument.new collection: "MyCollection", database: "MyDatabase"
21
7
  expect(myDocument.collection).to eq "MyCollection"
22
8
  end
23
9
 
24
10
  it "create a new instance with global" do
25
- myDocument = ArangoDoc.new key: "myKey", body: {"Hello" => "World"}
11
+ myDocument = ArangoDocument.new key: "myKey", body: {"Hello" => "World"}
26
12
  expect(myDocument.key).to eq "myKey"
27
13
  end
28
14
 
29
15
  it "create a new Edge instance" do
30
- a = ArangoDoc.new(key: "myA", body: {"Hello" => "World"}).create
31
- b = ArangoDoc.new(key: "myB", body: {"Hello" => "World"}).create
32
- myEdgeDocument = ArangoDoc.new collection: "MyEdgeCollection", from: a, to: b
16
+ a = ArangoDocument.new(key: "myA", body: {"Hello" => "World"}).create
17
+ b = ArangoDocument.new(key: "myB", body: {"Hello" => "World"}).create
18
+ myEdgeDocument = ArangoDocument.new collection: "MyEdgeCollection", from: a, to: b
33
19
  expect(myEdgeDocument.body["_from"]).to eq a.id
34
20
  end
35
21
  end
36
22
 
37
23
  context "#create" do
38
24
  it "create a new Document" do
25
+ @myDocument.destroy
39
26
  myDocument = @myDocument.create
40
27
  expect(myDocument.body["Hello"]).to eq "World"
41
28
  end
@@ -47,7 +34,7 @@ describe ArangoDoc do
47
34
 
48
35
  it "create a new Edge" do
49
36
  myDoc = @myCollection.create_document document: [{"A" => "B", "num" => 1}, {"C" => "D", "num" => 3}]
50
- myEdge = ArangoDoc.new collection: "MyEdgeCollection", from: myDoc[0].id, to: myDoc[1].id
37
+ myEdge = ArangoDocument.new collection: "MyEdgeCollection", from: myDoc[0].id, to: myDoc[1].id
51
38
  myEdge = myEdge.create
52
39
  expect(myEdge.body["_from"]).to eq myDoc[0].id
53
40
  end
@@ -60,7 +47,7 @@ describe ArangoDoc do
60
47
  end
61
48
 
62
49
  it "retrieve Edges" do
63
- testmy = @myEdgeCollection.create_edge from: ["MyCollection/myA", "MyCollection/myB"], to: @myDocument
50
+ @myEdgeCollection.create_edge from: ["MyCollection/myA", "MyCollection/myB"], to: @myDocument
64
51
  myEdges = @myDocument.retrieve_edges(collection: @myEdgeCollection)
65
52
  expect(myEdges.length).to eq 2
66
53
  end
@@ -0,0 +1,50 @@
1
+ require_relative './../../spec_helper'
2
+
3
+ describe ArangoEdge do
4
+ context "#new" do
5
+ it "create a new Edge instance" do
6
+ a = ArangoVertex.new(key: "myA", body: {"Hello" => "World"}).create
7
+ b = ArangoVertex.new(key: "myB", body: {"Hello" => "World"}).create
8
+ myEdgeDocument = ArangoEdge.new collection: "MyEdgeCollection", from: a, to: b
9
+ expect(myEdgeDocument.body["_from"]).to eq a.id
10
+ end
11
+ end
12
+
13
+ context "#create" do
14
+ it "create a new Edge" do
15
+ myDoc = @myCollection.create_document document: [{"A" => "B", "num" => 1}, {"C" => "D", "num" => 3}]
16
+ myEdge = ArangoEdge.new from: myDoc[0].id, to: myDoc[1].id, collection: "MyEdgeCollection"
17
+ myEdge = myEdge.create
18
+ expect(myEdge.body["_from"]).to eq myDoc[0].id
19
+ end
20
+ end
21
+
22
+ context "#info" do
23
+ it "retrieve Document" do
24
+ myDocument = @myEdge.retrieve
25
+ expect(myDocument.collection).to eq "MyEdgeCollection"
26
+ end
27
+ end
28
+
29
+ context "#modify" do
30
+ it "replace" do
31
+ a = ArangoVertex.new(body: {"Hello" => "World"}).create
32
+ b = ArangoVertex.new(body: {"Hello" => "World!!"}).create
33
+ myDocument = @myEdge.replace body: {"_from" => a.id, "_to" => b.id}
34
+ expect(myDocument.body["_from"]).to eq a.id
35
+ end
36
+
37
+ it "update" do
38
+ cc = ArangoVertex.new(body: {"Hello" => "World!!!"}).create
39
+ myDocument = @myEdge.update body: {"_to" => cc.id}
40
+ expect(myDocument.body["_to"]).to eq cc.id
41
+ end
42
+ end
43
+
44
+ context "#destroy" do
45
+ it "delete a Document" do
46
+ result = @myEdge.destroy
47
+ expect(result).to eq true
48
+ end
49
+ end
50
+ end
@@ -1,37 +1,21 @@
1
- require_relative './../spec_helper'
2
-
3
- describe ArangoG do
4
- before :all do
5
- ArangoS.default_server user: "root", password: "tretretre", server: "localhost", port: "8529"
6
- ArangoS.database = "MyDatabase"
7
- ArangoS.collection = "MyCollection"
8
- ArangoDB.new.create
9
- @myCollection = ArangoC.new.create
10
- @myCollectionB = ArangoC.new(collection: "MyCollectionB").create
11
- @myCollectionC = ArangoC.new(collection: "MyCollectionC").create
12
- @myCollectionD = ArangoC.new(collection: "MyCollectionD").create
13
- @myEdgeCollection = ArangoC.new(collection: "MyEdgeCollection").create_edge_collection
14
- @myGraph = ArangoG.new graph: "MyGraph"
15
- end
16
-
17
- after :all do
18
- ArangoDB.new.destroy
19
- end
1
+ require_relative './../../spec_helper'
20
2
 
3
+ describe ArangoGraph do
21
4
  context "#new" do
22
5
  it "create a new Graph instance without global" do
23
- myGraph = ArangoG.new graph: "MyGraph", database: "MyDatabase"
6
+ myGraph = ArangoGraph.new graph: "MyGraph", database: "MyDatabase"
24
7
  expect(myGraph.graph).to eq "MyGraph"
25
8
  end
26
9
 
27
10
  it "create a new instance with global" do
28
- myGraph = ArangoG.new
11
+ myGraph = ArangoGraph.new
29
12
  expect(myGraph.graph).to eq "MyGraph"
30
13
  end
31
14
  end
32
15
 
33
16
  context "#create" do
34
17
  it "create new graph" do
18
+ @myGraph.destroy
35
19
  myGraph = @myGraph.create
36
20
  expect(myGraph.graph).to eq "MyGraph"
37
21
  end
@@ -46,6 +30,8 @@ describe ArangoG do
46
30
 
47
31
  context "#manageVertexCollections" do
48
32
  it "add VertexCollection" do
33
+ @myGraph.removeEdgeCollection collection: "MyEdgeCollection"
34
+ @myGraph.removeVertexCollection collection: "MyCollection"
49
35
  myGraph = @myGraph.addVertexCollection collection: "MyCollection"
50
36
  expect(myGraph.orphanCollections[0]).to eq "MyCollection"
51
37
  end
@@ -0,0 +1,37 @@
1
+ require_relative './../../spec_helper'
2
+
3
+ describe ArangoServer do
4
+ context "#database" do
5
+ it "setup a global database" do
6
+ ArangoServer.database = "MyDatabase"
7
+ expect(ArangoServer.database).to eq "MyDatabase"
8
+ end
9
+ end
10
+
11
+ context "#graph" do
12
+ it "setup a global graph" do
13
+ ArangoServer.graph = "MyGraph"
14
+ expect(ArangoServer.graph).to eq "MyGraph"
15
+ end
16
+ end
17
+
18
+ context "#collection" do
19
+ it "setup a global collection" do
20
+ ArangoServer.collection = "MyCollection"
21
+ expect(ArangoServer.collection).to eq "MyCollection"
22
+ end
23
+ end
24
+
25
+ context "#verbose" do
26
+ it "try verbose" do
27
+ ArangoServer.verbose = true
28
+ result = ArangoCollection.new(collection: "Test").create
29
+ expect(result.class).to be Hash
30
+ end
31
+
32
+ it "print verbose" do
33
+ ArangoServer.verbose = true
34
+ expect(ArangoServer.verbose).to be true
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,48 @@
1
+ require_relative './../../spec_helper'
2
+
3
+ describe ArangoTraversal do
4
+ context "#new" do
5
+ it "create a new Traversal instance" do
6
+ myTraversal = ArangoTraversal.new
7
+ expect(myTraversal.database).to eq "MyDatabase"
8
+ end
9
+
10
+ it "instantiate start Vertex" do
11
+ @myTraversal.vertex = @myDoc[0]
12
+ expect(@myTraversal.vertex).to eq "MyCollection/FirstKey"
13
+ end
14
+
15
+ it "instantiate Graph" do
16
+ @myTraversal.graph = @myGraph
17
+ expect(@myTraversal.graph).to eq @myGraph.graph
18
+ end
19
+
20
+ it "instantiate EdgeCollection" do
21
+ @myTraversal.collection = @myEdgeCollection
22
+ expect(@myTraversal.collection).to eq @myEdgeCollection.collection
23
+ end
24
+
25
+ it "instantiate Direction" do
26
+ @myTraversal.in
27
+ expect(@myTraversal.direction).to eq "inbound"
28
+ end
29
+
30
+ it "instantiate Max" do
31
+ @myTraversal.max = 3
32
+ expect(@myTraversal.max).to eq 3
33
+ end
34
+
35
+ it "instantiate Min" do
36
+ @myTraversal.min = 1
37
+ expect(@myTraversal.min).to eq 1
38
+ end
39
+ end
40
+
41
+ context "#execute" do
42
+ it "execute Traversal" do
43
+ @myTraversal.any
44
+ @myTraversal.execute
45
+ expect(@myTraversal.vertices.length).to be >= 30
46
+ end
47
+ end
48
+ end
@@ -1,37 +1,21 @@
1
- require_relative './../spec_helper'
2
-
3
- describe ArangoV do
4
- before :all do
5
- ArangoS.default_server user: "root", password: "tretretre", server: "localhost", port: "8529"
6
- ArangoS.database = "MyDatabase"
7
- ArangoS.collection = "MyCollection"
8
- ArangoS.graph = "MyGraph"
9
- ArangoDB.new.create
10
- @myGraph = ArangoG.new.create
11
- @myCollection = ArangoC.new.create
12
- @myEdgeCollection = ArangoC.new(collection: "MyEdgeCollection").create_edge_collection
13
- @myVertex = ArangoV.new body: {"Hello" => "World", "num" => 1}, key: "FirstDocument"
14
- @myGraph.addVertexCollection collection: "MyCollection"
15
- end
16
-
17
- after :all do
18
- ArangoDB.new.destroy
19
- end
1
+ require_relative './../../spec_helper'
20
2
 
3
+ describe ArangoVertex do
21
4
  context "#new" do
22
5
  it "create a new Document instance without global" do
23
- myVertex = ArangoV.new collection: "MyCollection", database: "MyDatabase", graph: "MyGraph"
6
+ myVertex = ArangoVertex.new collection: "MyCollection", database: "MyDatabase", graph: "MyGraph"
24
7
  expect(myVertex.collection).to eq "MyCollection"
25
8
  end
26
9
 
27
10
  it "create a new instance with global" do
28
- myVertex = ArangoV.new key: "myKey", body: {"Hello" => "World"}
11
+ myVertex = ArangoVertex.new key: "myKey", body: {"Hello" => "World"}
29
12
  expect(myVertex.key).to eq "myKey"
30
13
  end
31
14
  end
32
15
 
33
16
  context "#create" do
34
17
  it "create a new Document" do
18
+ @myVertex.destroy
35
19
  myVertex = @myVertex.create
36
20
  expect(myVertex.body["Hello"]).to eq "World"
37
21
  end
@@ -49,7 +33,7 @@ describe ArangoV do
49
33
  end
50
34
 
51
35
  it "retrieve Edges" do
52
- testmy = @myEdgeCollection.create_edge from: ["MyCollection/myA", "MyCollection/myB"], to: @myVertex
36
+ @myEdgeCollection.create_edge from: ["MyCollection/myA", "MyCollection/myB"], to: @myVertex
53
37
  myEdges = @myVertex.retrieve_edges(collection: @myEdgeCollection)
54
38
  expect(myEdges.length).to eq 2
55
39
  end
@@ -0,0 +1,73 @@
1
+ require_relative './../../spec_helper'
2
+
3
+ describe ArangoCollection do
4
+ context "#get" do
5
+ it "revision" do
6
+ expect(@myCollection.revision.to_i).to be >= 1
7
+ end
8
+
9
+ it "collection" do
10
+ expect(@myCollection.rotate).to eq "could not rotate journal: no journal"
11
+ end
12
+ end
13
+
14
+ context "#import" do
15
+ it "import" do
16
+ attributes = ["value", "num", "name"]
17
+ values = [["uno",1,"ONE"],["due",2,"TWO"],["tre",3,"THREE"]]
18
+ result = @myCollection.import attributes: attributes, values: values
19
+ expect(result["created"]).to eq 3
20
+ end
21
+
22
+ it "import single" do
23
+ attributes = ["value", "num", "name"]
24
+ values = ["uno",1,"ONE"]
25
+ result = @myCollection.import attributes: attributes, values: values
26
+ expect(result["created"]).to eq 1
27
+ end
28
+
29
+ it "importJSON" do
30
+ body = [{"value": "uno", "num": 1, "name": "ONE"}, {"value": "due", "num": 2, "name": "DUE"}]
31
+ result = @myCollection.importJSON body: body
32
+ expect(result["created"]).to eq 2
33
+ end
34
+ end
35
+
36
+ context "#export" do
37
+ it "export" do
38
+ result = @myCollection.export
39
+ expect(result[0].class).to be ArangoDocument
40
+ end
41
+
42
+ it "exportNext" do
43
+ result = @myCollection.export batchSize: 3
44
+ result = @myCollection.exportNext
45
+ expect(result[0].class).to be ArangoDocument
46
+ end
47
+ end
48
+
49
+ context "#indexes" do
50
+ it "indexes" do
51
+ expect(@myCollection.indexes["indexes"][0].class).to be ArangoIndex
52
+ end
53
+ #
54
+ # it "retrieve" do
55
+ # expect((@myCollection.retrieveIndex id: 0).unique).to be true
56
+ # end
57
+ #
58
+ it "create" do
59
+ myIndex = @myCollection.createIndex unique: false, fields: "num", type: "hash"
60
+ expect(myIndex.fields).to eq ["num"]
61
+ end
62
+ #
63
+ # it "delete" do
64
+ # expect(@myCollection.deleteIndex id: @myIndex.key).to eq true
65
+ # end
66
+ end
67
+
68
+ context "#replication" do
69
+ it "data" do
70
+ expect(@myCollection.data.length).to be > 100
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,81 @@
1
+ require_relative './../../spec_helper'
2
+
3
+ describe ArangoDatabase do
4
+ # context "#async" do
5
+ # it "pendingAsync" do
6
+ # ArangoServer.async = "store"
7
+ # ArangoAQL.new(query: "FOR u IN MyCollection RETURN u.num").execute
8
+ # expect(@myDatabase.pendingAsync).to eq []
9
+ # end
10
+ #
11
+ # it "fetchAsync" do
12
+ # ArangoServer.async = "store"
13
+ # id = ArangoAQL.new(query: "FOR u IN MyCollection RETURN u.num").execute
14
+ # expect(@myDatabase.fetchAsync(id: id)["count"]).to eq 18
15
+ # end
16
+ #
17
+ # it "retrieveAsync" do
18
+ # ArangoServer.async = "store"
19
+ # ArangoAQL.new(query: "FOR u IN MyCollection RETURN u.num").execute
20
+ # expect(@myDatabase.retrievePendingAsync).to eq []
21
+ # end
22
+ #
23
+ # it "cancelAsync" do
24
+ # ArangoServer.async = "store"
25
+ # id = ArangoAQL.new(query: "FOR u IN MyCollection RETURN u.num").execute
26
+ # expect(@myDatabase.cancelAsync(id: id)).to eq "not found"
27
+ # end
28
+ #
29
+ # it "destroyAsync" do
30
+ # ArangoServer.async = "store"
31
+ # id = ArangoAQL.new(query: "FOR u IN MyCollection RETURN u.num").execute
32
+ # expect(@myDatabase.destroyAsync type: id).to be true
33
+ # end
34
+ # end
35
+ # end
36
+
37
+ context "#replication" do
38
+ it "inventory" do
39
+ expect(@myDatabase.inventory["collections"].class).to be Array
40
+ end
41
+
42
+ it "clusterInventory" do
43
+ expect(@myDatabase.clusterInventory).to eq "this operation is only valid on a coordinator in a cluster"
44
+ end
45
+
46
+ it "logger" do
47
+ expect(@myDatabase.logger["state"]["running"]).to be true
48
+ end
49
+
50
+ it "lastLogger" do
51
+ expect(@myDatabase.loggerFollow.class).to be String
52
+ end
53
+
54
+ it "fistTick" do
55
+ expect(@myDatabase.firstTick.to_i).to be >= 1
56
+ end
57
+
58
+ it "rangeTick" do
59
+ expect(@myDatabase.rangeTick[0]["datafile"].class).to be String
60
+ end
61
+
62
+ it "configurationReplication" do
63
+ expect(@myDatabase.configurationReplication["requestTimeout"]).to eq 600
64
+ end
65
+
66
+ it "modifyConfigurationReplication" do
67
+ result = @myDatabase.modifyConfigurationReplication autoStart: true
68
+ expect(result["autoStart"]).to be true
69
+ end
70
+ end
71
+
72
+ context "#user" do
73
+ it "grant" do
74
+ expect(@myDatabase.grant user: @myUser).to be true
75
+ end
76
+
77
+ it "revoke" do
78
+ expect(@myDatabase.revoke user: @myUser).to be true
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,43 @@
1
+ require_relative './../../spec_helper'
2
+
3
+ describe ArangoIndex do
4
+ context "#new" do
5
+ it "create a new Index without global" do
6
+ myIndex = ArangoIndex.new collection: @myCollection, database: @myDatabase, fields: "num", unique: false, id: "myIndex"
7
+ expect(myIndex.id).to eq "myIndex"
8
+ end
9
+
10
+ it "create a new Index with global" do
11
+ myIndex = ArangoIndex.new fields: "num", unique: false, id: "myIndex2"
12
+ expect(myIndex.id).to eq "myIndex2"
13
+ end
14
+ end
15
+
16
+ context "#create" do
17
+ it "create a new Index" do
18
+ result = @myIndex.create
19
+ expect(result.type).to eq "hash"
20
+ end
21
+ end
22
+
23
+ context "#retrieve" do
24
+ it "retrieve an Index" do
25
+ result = @myIndex.retrieve
26
+ expect(result.type).to eq "hash"
27
+ end
28
+ end
29
+
30
+ context "#info" do
31
+ it "list Indexes" do
32
+ result = ArangoIndex.indexes
33
+ expect(result["indexes"][0].class).to be ArangoIndex
34
+ end
35
+ end
36
+
37
+ context "#destroy" do
38
+ it "destroy" do
39
+ result = @myIndex.destroy
40
+ expect(result).to be true
41
+ end
42
+ end
43
+ end