arangorb 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,196 @@
1
+ require_relative './../../spec_helper'
2
+
3
+ describe ArangoServer do
4
+ context "#general" do
5
+ it "address" do
6
+ expect(ArangoServer.address).to eq "localhost:8529"
7
+ end
8
+
9
+ it "username" do
10
+ expect(ArangoServer.username).to eq "root"
11
+ end
12
+
13
+ it "request" do
14
+ expect(ArangoServer.request[":body"].class).to be NilClass
15
+ end
16
+ end
17
+
18
+ context "#user" do
19
+ it "setup a global user" do
20
+ ArangoServer.user = "MyUser2"
21
+ expect(ArangoServer.user).to eq "MyUser2"
22
+ end
23
+ end
24
+
25
+ context "#monitoring" do
26
+ it "log" do
27
+ expect(ArangoServer.log["totalAmount"]).to be >= 0
28
+ end
29
+
30
+ it "reload" do
31
+ expect(ArangoServer.reload).to be true
32
+ end
33
+
34
+ it "statistics" do
35
+ expect(ArangoServer.statistics["enabled"]).to be true
36
+ end
37
+
38
+ it "statisticsDescription" do
39
+ expect(ArangoServer.statistics(description: true)["groups"][0].nil?).to be false
40
+ end
41
+
42
+ it "role" do
43
+ expect(ArangoServer.role.class).to eq String
44
+ end
45
+
46
+ # it "server" do
47
+ # expect(ArangoServer.server.class).to eq String
48
+ # end
49
+
50
+ it "serverID" do
51
+ expect(ArangoServer.serverId.to_i).to be >= 1
52
+ end
53
+
54
+ # it "clusterStatistics" do
55
+ # expect(ArangoServer.clusterStatistics.class).to eq String
56
+ # end
57
+ end
58
+
59
+ context "#lists" do
60
+ it "endpoints" do
61
+ expect(ArangoServer.endpoints[0].keys[0]).to eq "endpoint"
62
+ end
63
+
64
+ it "users" do
65
+ expect(ArangoServer.users[0].class).to be ArangoUser
66
+ end
67
+
68
+ it "databases" do
69
+ expect(ArangoServer.databases[0].class).to be ArangoDatabase
70
+ end
71
+ end
72
+
73
+ context "#async" do
74
+ it "create async" do
75
+ ArangoServer.async = "store"
76
+ expect(ArangoServer.async).to eq "store"
77
+ end
78
+
79
+ it "pendingAsync" do
80
+ ArangoServer.async = "store"
81
+ ArangoAQL.new(query: "FOR u IN MyCollection RETURN u.num").execute
82
+ expect(ArangoServer.pendingAsync).to eq []
83
+ end
84
+
85
+ it "fetchAsync" do
86
+ ArangoServer.async = "store"
87
+ id = ArangoAQL.new(query: "FOR u IN MyCollection RETURN u.num").execute
88
+ expect(ArangoServer.fetchAsync(id: id)["count"]).to eq 18
89
+ end
90
+
91
+ it "retrieveAsync" do
92
+ ArangoServer.async = "store"
93
+ ArangoAQL.new(query: "FOR u IN MyCollection RETURN u.num").execute
94
+ expect(ArangoServer.retrievePendingAsync).to eq []
95
+ end
96
+
97
+ it "cancelAsync" do
98
+ ArangoServer.async = "store"
99
+ id = ArangoAQL.new(query: "FOR u IN MyCollection RETURN u.num").execute
100
+ expect(ArangoServer.cancelAsync(id: id)).to eq "not found"
101
+ end
102
+
103
+ it "destroyAsync" do
104
+ ArangoServer.async = "store"
105
+ id = ArangoAQL.new(query: "FOR u IN MyCollection RETURN u.num").execute
106
+ expect(ArangoServer.destroyAsync type: id).to be true
107
+ end
108
+ end
109
+
110
+ context "#batch" do
111
+ it "batch" do
112
+ ArangoServer.async = false
113
+ ArangoCollection.new.create
114
+ queries = [{
115
+ "type": "POST",
116
+ "address": "/_db/MyDatabase/_api/collection",
117
+ "body": {"name": "newCOLLECTION"},
118
+ "id": "1"
119
+ },
120
+ {
121
+ "type": "GET",
122
+ "address": "/_api/database",
123
+ "id": "2"
124
+ }]
125
+ expect((ArangoServer.batch queries: queries).class).to be String
126
+ end
127
+
128
+ it "createDumpBatch" do
129
+ expect((ArangoServer.createDumpBatch ttl: 100).to_i).to be > 1
130
+ end
131
+
132
+ it "prolongDumpBatch" do
133
+ dumpBatchID = ArangoServer.createDumpBatch ttl: 100
134
+ expect((ArangoServer.prolongDumpBatch ttl: 100, id: dumpBatchID).to_i).to be > 1
135
+ end
136
+
137
+ it "destroyDumpBatch" do
138
+ dumpBatchID = ArangoServer.createDumpBatch ttl: 100
139
+ expect(ArangoServer.destroyDumpBatch id: dumpBatchID).to be true
140
+ end
141
+ end
142
+
143
+ context "#task" do
144
+ it "tasks" do
145
+ result = ArangoServer.tasks
146
+ expect(result[0].id.class).to be String
147
+ end
148
+ end
149
+
150
+ context "#miscellaneous" do
151
+ it "version" do
152
+ expect(ArangoServer.version["server"]).to eq "arango"
153
+ end
154
+
155
+ it "propertyWAL" do
156
+ ArangoServer.changePropertyWAL historicLogfiles: 14
157
+ expect(ArangoServer.propertyWAL["historicLogfiles"]).to eq 14
158
+ end
159
+
160
+ it "flushWAL" do
161
+ expect(ArangoServer.flushWAL).to be true
162
+ end
163
+
164
+ it "transactions" do
165
+ expect(ArangoServer.transactions["runningTransactions"]).to be >= 0
166
+ end
167
+
168
+ it "time" do
169
+ expect(ArangoServer.time.class).to be Float
170
+ end
171
+
172
+ it "echo" do
173
+ expect(ArangoServer.echo["user"]).to eq "root"
174
+ end
175
+
176
+ it "databaseVersion" do
177
+ expect(ArangoServer.databaseVersion.to_i).to be >= 1
178
+ end
179
+
180
+ it "sleep" do
181
+ expect(ArangoServer.sleep duration: 10).to be >= 1
182
+ end
183
+
184
+ # it "shutdown" do
185
+ # result = ArangoServer.shutdown
186
+ # `sudo service arangodb restart`
187
+ # expect(result).to eq "OK"
188
+ # end
189
+
190
+ # it "test" do
191
+ # print ArangoServer.test body: {"num" => 1}
192
+ # end
193
+ end
194
+
195
+
196
+ end
@@ -0,0 +1,49 @@
1
+ require_relative './../../spec_helper'
2
+
3
+ describe ArangoTask do
4
+ context "#new" do
5
+ it "create new instance" do
6
+ myArangoTask = ArangoTask.new id: "mytaskid", name: "MyTaskID", command: "(function(params) { require('@arangodb').print(params); })(params)", params: {"foo" => "bar", "bar" => "foo"}, period: 2
7
+ expect(myArangoTask.params["foo"]).to eq "bar"
8
+ end
9
+ end
10
+
11
+ context "#create" do
12
+ it "create a new Task instance" do
13
+ myArangoTask = ArangoTask.new name: "MyTaskID", command: "(function(params) { require('@arangodb').print(params); })(params)", params: {"foo" => "bar", "bar" => "foo"}, period: 2
14
+ expect(myArangoTask.create.created.class).to eq Float
15
+ end
16
+
17
+ it "create a new Task instance with ID" do
18
+ myArangoTask = ArangoTask.new id: "mytaskid", name: "MyTaskID", command: "(function(params) { require('@arangodb').print(params); })(params)", params: {"foo2" => "bar2", "bar2" => "foo2"}, period: 2
19
+ expect(myArangoTask.create.params["foo2"]).to eq "bar2"
20
+ end
21
+
22
+ it "duplilcate a Task instance with ID" do
23
+ myArangoTask = ArangoTask.new id: "mytaskid", name: "MyTaskID", command: "(function(params) { require('@arangodb').print(params); })(params)", params: {"foo21" => "bar2", "bar21" => "foo21"}, period: 2
24
+ expect(myArangoTask.create).to eq "duplicate task id"
25
+ end
26
+ end
27
+
28
+ context "#retrieve" do
29
+ it "retrieve lists" do
30
+ myArangoTask = ArangoTask.new name: "MyTaskID", command: "(function(params) { require('@arangodb').print(params); })(params)", params: {"foo2" => "bar2", "bar2" => "foo2"}, period: 2
31
+ myArangoTask.create
32
+ result = ArangoTask.tasks.map{|x| x.database}
33
+ expect(result.include? 'MyDatabase').to be true
34
+ end
35
+
36
+ it "retrieve" do
37
+ myArangoTask = ArangoTask.new name: "MyTaskID", command: "(function(params) { require('@arangodb').print(params); })(params)", params: {"foo2" => "bar2", "bar2" => "foo2"}, period: 2
38
+ myArangoTask.create
39
+ expect(myArangoTask.retrieve.params["foo2"]).to eq "bar2"
40
+ end
41
+ end
42
+
43
+ context "#destroy" do
44
+ it "destroy" do
45
+ myArangoTask = ArangoTask.new id: "mytaskid"
46
+ expect(myArangoTask.destroy).to be true
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,15 @@
1
+ require_relative './../../spec_helper'
2
+
3
+ describe ArangoTransaction do
4
+ context "#new and use" do
5
+ it "create new instance" do
6
+ myArangoTransaction = ArangoTransaction.new action: "function(){ var db = require('@arangodb').db; db.MyCollection.save({}); return db.MyCollection.count(); }", write: @myCollection
7
+ expect(myArangoTransaction.collections["write"][0]).to eq "MyCollection"
8
+ end
9
+
10
+ it "execute" do
11
+ myArangoTransaction = ArangoTransaction.new action: "function(){ var db = require('@arangodb').db; db.MyCollection.save({}); return db.MyCollection.count(); }", write: @myCollection
12
+ expect(myArangoTransaction.execute).to be >= 1
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,72 @@
1
+ require_relative './../../spec_helper'
2
+
3
+ describe ArangoUser do
4
+ context "#new" do
5
+ it "create a new User without global" do
6
+ myUser = ArangoUser.new user: "MyUser2", password: "Test"
7
+ expect(myUser.user).to eq "MyUser2"
8
+ end
9
+
10
+ it "create a new instance with global" do
11
+ myUser = ArangoUser.new
12
+ expect(myUser.user).to eq "MyUser"
13
+ end
14
+ end
15
+
16
+ context "#create" do
17
+ it "create a new user" do
18
+ @myUser.destroy
19
+ @myUser = ArangoUser.new user: "MyUser", password: "Test"
20
+ result = @myUser.create
21
+ expect(result.user).to eq "MyUser"
22
+ end
23
+
24
+ it "create a duplicate user" do
25
+ result = @myUser.create
26
+ expect(result).to eq "duplicate user"
27
+ end
28
+ end
29
+
30
+ context "#info" do
31
+ it "retrieve User" do
32
+ myUser = @myUser.retrieve
33
+ expect(myUser.active).to be true
34
+ end
35
+ end
36
+
37
+ context "#database" do
38
+ it "grant" do
39
+ result = @myUser.grant database: @myDatabase
40
+ expect(result).to be true
41
+ end
42
+
43
+ it "databases" do
44
+ result = @myUser.databases
45
+ expect(result["MyDatabase"]).to eq "rw"
46
+ end
47
+
48
+ it "revoke" do
49
+ result = @myUser.revoke database: @myDatabase
50
+ expect(result).to be true
51
+ end
52
+ end
53
+
54
+ context "#modify" do
55
+ it "replace" do
56
+ @myUser.replace active: false, password: "Test"
57
+ expect(@myUser.active).to be false
58
+ end
59
+
60
+ it "update" do
61
+ @myUser.update active: false, password: "Test"
62
+ expect(@myUser.active).to be false
63
+ end
64
+ end
65
+
66
+ context "#destroy" do
67
+ it "destroy" do
68
+ result = @myUser.destroy
69
+ expect(result).to be true
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,9 @@
1
+ require "lib/0.1.0/arangoS_helper"
2
+ require "lib/0.1.0/arangoDB_helper"
3
+ require "lib/0.1.0/arangoC_helper"
4
+ require "lib/0.1.0/arangoDoc_helper"
5
+ require "lib/0.1.0/arangoG_helper"
6
+ require "lib/0.1.0/arangoV_helper"
7
+ require "lib/0.1.0/arangoE_helper"
8
+ require "lib/0.1.0/arangoT_helper"
9
+ require "lib/0.1.0/arangoAQL_helper"
@@ -0,0 +1,6 @@
1
+ require "lib/1.0.0/arangoS_helper"
2
+ require "lib/1.0.0/arangoDB_helper"
3
+ require "lib/1.0.0/arangoC_helper"
4
+ require "lib/1.0.0/arangoU_helper"
5
+ require "lib/1.0.0/arangoTr_helper"
6
+ require "lib/1.0.0/arangoTa_helper"
data/spec/spec_helper.rb CHANGED
@@ -3,4 +3,38 @@ require_relative File.expand_path('../../lib/arangorb', __FILE__)
3
3
 
4
4
  RSpec.configure do |config|
5
5
  config.color = true
6
+ config.before(:all) do
7
+ ArangoServer.default_server user: "root", password: "", server: "localhost", port: "8529"
8
+ ArangoServer.database = "MyDatabase"
9
+ ArangoServer.collection = "MyCollection"
10
+ ArangoServer.graph = "MyGraph"
11
+ ArangoServer.user = "MyUser"
12
+ ArangoServer.verbose = false
13
+ ArangoServer.async = false
14
+ @myDatabase = ArangoDatabase.new.create
15
+ @myGraph = ArangoGraph.new.create
16
+ @myCollection = ArangoCollection.new.create
17
+ @myCollectionB = ArangoCollection.new(collection: "MyCollectionB").create
18
+ @myDocument = ArangoDocument.new(body: {"Hello" => "World", "num" => 1}, key: "FirstDocument").create
19
+ @myEdgeCollection = ArangoCollection.new(collection: "MyEdgeCollection").create_edge_collection
20
+ @myGraph.addVertexCollection collection: "MyCollection"
21
+ @myGraph.addEdgeCollection collection: "MyEdgeCollection", from: "MyCollection", to: "MyCollection"
22
+ @myAQL = ArangoAQL.new query: "FOR u IN MyCollection RETURN u.num"
23
+ @myDoc = @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}]
24
+ @myEdgeCollection.create_edge from: [@myDoc[0].id, @myDoc[1].id, @myDoc[2].id, @myDoc[3].id, @myDoc[7].id], to: [@myDoc[4].id, @myDoc[5].id, @myDoc[6].id, @myDoc[8].id]
25
+ @myVertex = ArangoVertex.new(body: {"Hello" => "World", "num" => 1}, key: "FirstVertex").create
26
+ @vertexA = ArangoVertex.new(body: {"Hello" => "World", "num" => 1}).create
27
+ @vertexB = ArangoVertex.new(body: {"Hello" => "Moon", "num" => 2}).create
28
+ @myEdge = ArangoEdge.new(from: @vertexA, to: @vertexB, collection: "MyEdgeCollection").create
29
+ @myIndex = @myCollection.createIndex unique: false, fields: "num", type: "hash", id: "MyIndex"
30
+ @myTraversal = ArangoTraversal.new
31
+ @myUser = ArangoUser.new.create
32
+ end
33
+
34
+ config.after(:all) do
35
+ ArangoDatabase.new.destroy
36
+ ArangoUser.new.destroy
37
+ @myUser.destroy unless @myUser.nil?
38
+ @myIndex.destroy unless @myIndex.nil?
39
+ end
6
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arangorb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Martin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-27 00:00:00.000000000 Z
11
+ date: 2016-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -30,9 +30,8 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 0.14.0
33
- description: ArangoDB is a powerful mixed database based on documents and graphs,
34
- with an interesting language called AQl. ArangoRB is a Ruby gems to use Ruby to
35
- interact with its HTTP API.
33
+ description: ArangoDB is a powerful mixed database based on documents and graphs.
34
+ ArangoRB is an experimental Ruby gems that uses ArangoDB's HTTP API.
36
35
  email:
37
36
  - stefano@seluxit.com
38
37
  executables: []
@@ -49,20 +48,34 @@ files:
49
48
  - lib/ArangoRB_Doc.rb
50
49
  - lib/ArangoRB_Edg.rb
51
50
  - lib/ArangoRB_Gra.rb
51
+ - lib/ArangoRB_Index.rb
52
52
  - lib/ArangoRB_Ser.rb
53
+ - lib/ArangoRB_Task.rb
53
54
  - lib/ArangoRB_Tra.rb
55
+ - lib/ArangoRB_Tran.rb
56
+ - lib/ArangoRB_User.rb
54
57
  - lib/ArangoRB_Ver.rb
55
58
  - lib/arangorb.rb
56
59
  - spec/arangoRB_helper.rb
57
- - spec/lib/arangoAQL_helper.rb
58
- - spec/lib/arangoC_helper.rb
59
- - spec/lib/arangoDB_helper.rb
60
- - spec/lib/arangoDoc_helper.rb
61
- - spec/lib/arangoE_helper.rb
62
- - spec/lib/arangoG_helper.rb
63
- - spec/lib/arangoS_helper.rb
64
- - spec/lib/arangoT_helper.rb
65
- - spec/lib/arangoV_helper.rb
60
+ - spec/arangoRestart_helper.rb
61
+ - spec/lib/0.1.0/arangoAQL_helper.rb
62
+ - spec/lib/0.1.0/arangoC_helper.rb
63
+ - spec/lib/0.1.0/arangoDB_helper.rb
64
+ - spec/lib/0.1.0/arangoDoc_helper.rb
65
+ - spec/lib/0.1.0/arangoE_helper.rb
66
+ - spec/lib/0.1.0/arangoG_helper.rb
67
+ - spec/lib/0.1.0/arangoS_helper.rb
68
+ - spec/lib/0.1.0/arangoT_helper.rb
69
+ - spec/lib/0.1.0/arangoV_helper.rb
70
+ - spec/lib/1.0.0/arangoC_helper.rb
71
+ - spec/lib/1.0.0/arangoDB_helper.rb
72
+ - spec/lib/1.0.0/arangoI_helper.rb
73
+ - spec/lib/1.0.0/arangoS_helper.rb
74
+ - spec/lib/1.0.0/arangoTa_helper.rb
75
+ - spec/lib/1.0.0/arangoTr_helper.rb
76
+ - spec/lib/1.0.0/arangoU_helper.rb
77
+ - spec/lib/arangoRB_0.1.0_helper.rb
78
+ - spec/lib/arangoRB_1.0.0_helper.rb
66
79
  - spec/spec_helper.rb
67
80
  homepage: https://github.com/StefanoMartin/ArangoRB
68
81
  licenses:
@@ -84,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
97
  version: '0'
85
98
  requirements: []
86
99
  rubyforge_project:
87
- rubygems_version: 2.4.8
100
+ rubygems_version: 2.5.1
88
101
  signing_key:
89
102
  specification_version: 4
90
103
  summary: A simple ruby client for ArangoDB
@@ -1,70 +0,0 @@
1
- require_relative './../spec_helper'
2
-
3
- describe ArangoE 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
- @myGraph.addVertexCollection collection: "MyCollection"
14
- @myGraph.addEdgeCollection collection: "MyEdgeCollection", from: "MyCollection", to: "MyCollection"
15
- @vertexA = ArangoV.new(body: {"Hello" => "World", "num" => 1}).create
16
- @vertexB = ArangoV.new(body: {"Hello" => "Moon", "num" => 2}).create
17
- @myEdge = ArangoE.new(from: @vertexA, to: @vertexB, collection: "MyEdgeCollection").create
18
- end
19
-
20
- after :all do
21
- ArangoDB.new.destroy
22
- end
23
-
24
- context "#new" do
25
- it "create a new Edge instance" do
26
- a = ArangoV.new(key: "myA", body: {"Hello" => "World"}).create
27
- b = ArangoV.new(key: "myB", body: {"Hello" => "World"}).create
28
- myEdgeDocument = ArangoE.new collection: "MyEdgeCollection", from: a, to: b
29
- expect(myEdgeDocument.body["_from"]).to eq a.id
30
- end
31
- end
32
-
33
- context "#create" do
34
- it "create a new Edge" do
35
- myDoc = @myCollection.create_document document: [{"A" => "B", "num" => 1}, {"C" => "D", "num" => 3}]
36
- myEdge = ArangoE.new from: myDoc[0].id, to: myDoc[1].id, collection: "MyEdgeCollection"
37
- myEdge = myEdge.create
38
- expect(myEdge.body["_from"]).to eq myDoc[0].id
39
- end
40
- end
41
-
42
- context "#info" do
43
- it "retrieve Document" do
44
- myDocument = @myEdge.retrieve
45
- expect(myDocument.collection).to eq "MyEdgeCollection"
46
- end
47
- end
48
-
49
- context "#modify" do
50
- it "replace" do
51
- a = ArangoV.new(body: {"Hello" => "World"}).create
52
- b = ArangoV.new(body: {"Hello" => "World!!"}).create
53
- myDocument = @myEdge.replace body: {"_from" => a.id, "_to" => b.id}
54
- expect(myDocument.body["_from"]).to eq a.id
55
- end
56
-
57
- it "update" do
58
- cc = ArangoV.new(body: {"Hello" => "World!!!"}).create
59
- myDocument = @myEdge.update body: {"_to" => cc.id}
60
- expect(myDocument.body["_to"]).to eq cc.id
61
- end
62
- end
63
-
64
- context "#destroy" do
65
- it "delete a Document" do
66
- result = @myEdge.destroy
67
- expect(result).to eq true
68
- end
69
- end
70
- end
@@ -1,28 +0,0 @@
1
- require_relative './../spec_helper'
2
-
3
- describe ArangoS do
4
- before :all do
5
- ArangoS.default_server user: "root", password: "tretretre", server: "localhost", port: "8529"
6
- end
7
-
8
- context "#database" do
9
- it "setup a global database" do
10
- ArangoS.database = "MyDatabase"
11
- expect(ArangoS.database).to eq "MyDatabase"
12
- end
13
- end
14
-
15
- context "#graph" do
16
- it "setup a global graph" do
17
- ArangoS.graph = "MyGraph"
18
- expect(ArangoS.graph).to eq "MyGraph"
19
- end
20
- end
21
-
22
- context "#collection" do
23
- it "setup a global collection" do
24
- ArangoS.collection = "MyCollection"
25
- expect(ArangoS.collection).to eq "MyCollection"
26
- end
27
- end
28
- end
@@ -1,67 +0,0 @@
1
- require_relative './../spec_helper'
2
-
3
- describe ArangoT 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
- @myGraph.addEdgeCollection collection: "MyEdgeCollection", from: "MyCollection", to: "MyCollection"
14
- @myTransaction = ArangoT.new
15
- @myDoc = @myCollection.create_document document: [{"num" => 1, "_key" => "FirstKey"}, {"num" => 2}, {"num" => 3}, {"num" => 4}, {"num" => 5}, {"num" => 6}, {"num" => 7}]
16
- @myEdgeCollection.create_edge from: [@myDoc[0].id, @myDoc[1].id, @myDoc[2].id, @myDoc[3].id], to: [@myDoc[4].id, @myDoc[5].id, @myDoc[6].id]
17
- end
18
-
19
- after :all do
20
- ArangoDB.new.destroy
21
- end
22
-
23
- context "#new" do
24
- it "create a new Transaction instance" do
25
- myTransaction = ArangoT.new
26
- expect(@myTransaction.database).to eq "MyDatabase"
27
- end
28
-
29
- it "instantiate start Vertex" do
30
- @myTransaction.vertex = @myDoc[0]
31
- expect(@myTransaction.vertex).to eq "MyCollection/FirstKey"
32
- end
33
-
34
- it "instantiate Graph" do
35
- @myTransaction.graph = @myGraph
36
- expect(@myTransaction.graph).to eq @myGraph.graph
37
- end
38
-
39
- it "instantiate EdgeCollection" do
40
- @myTransaction.collection = @myEdgeCollection
41
- expect(@myTransaction.collection).to eq @myEdgeCollection.collection
42
- end
43
-
44
- it "instantiate Direction" do
45
- @myTransaction.in
46
- expect(@myTransaction.direction).to eq "inbound"
47
- end
48
-
49
- it "instantiate Max" do
50
- @myTransaction.max = 3
51
- expect(@myTransaction.max).to eq 3
52
- end
53
-
54
- it "instantiate Min" do
55
- @myTransaction.min = 1
56
- expect(@myTransaction.min).to eq 1
57
- end
58
- end
59
-
60
- context "#execute" do
61
- it "execute Transaction" do
62
- @myTransaction.any
63
- @myTransaction.execute
64
- expect(@myTransaction.vertices.length).to eq 30
65
- end
66
- end
67
- end