ashikawa-core 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +3 -3
- data/CHANGELOG.md +49 -0
- data/Gemfile +3 -2
- data/Gemfile.devtools +14 -22
- data/Guardfile +3 -2
- data/README.md +37 -6
- data/Rakefile +2 -1
- data/ashikawa-core.gemspec +2 -2
- data/cache/Mac_applications +1 -0
- data/config/devtools.yml +5 -0
- data/config/flay.yml +1 -1
- data/config/flog.yml +1 -2
- data/config/reek.yml +1 -1
- data/config/rubocop.yml +23 -25
- data/lib/ashikawa-core.rb +6 -5
- data/lib/ashikawa-core/collection.rb +142 -165
- data/lib/ashikawa-core/configuration.rb +41 -2
- data/lib/ashikawa-core/connection.rb +17 -16
- data/lib/ashikawa-core/cursor.rb +18 -12
- data/lib/ashikawa-core/database.rb +69 -59
- data/lib/ashikawa-core/document.rb +22 -20
- data/lib/ashikawa-core/edge.rb +8 -6
- data/lib/ashikawa-core/exceptions/client_error.rb +1 -0
- data/lib/ashikawa-core/exceptions/client_error/authentication_failed.rb +25 -0
- data/lib/ashikawa-core/exceptions/client_error/bad_syntax.rb +3 -2
- data/lib/ashikawa-core/exceptions/client_error/resource_not_found.rb +3 -2
- data/lib/ashikawa-core/exceptions/client_error/resource_not_found/collection_not_found.rb +3 -2
- data/lib/ashikawa-core/exceptions/client_error/resource_not_found/document_not_found.rb +3 -2
- data/lib/ashikawa-core/exceptions/client_error/resource_not_found/index_not_found.rb +3 -2
- data/lib/ashikawa-core/exceptions/no_collection_provided.rb +1 -0
- data/lib/ashikawa-core/exceptions/server_error.rb +1 -0
- data/lib/ashikawa-core/exceptions/server_error/json_error.rb +3 -2
- data/lib/ashikawa-core/figure.rb +18 -17
- data/lib/ashikawa-core/index.rb +15 -5
- data/lib/ashikawa-core/key_options.rb +5 -4
- data/lib/ashikawa-core/query.rb +38 -27
- data/lib/ashikawa-core/request_preprocessor.rb +4 -3
- data/lib/ashikawa-core/response_preprocessor.rb +64 -24
- data/lib/ashikawa-core/status.rb +1 -0
- data/lib/ashikawa-core/transaction.rb +12 -11
- data/lib/ashikawa-core/version.rb +2 -1
- data/spec/acceptance/basic_spec.rb +117 -116
- data/spec/acceptance/index_spec.rb +18 -15
- data/spec/acceptance/query_spec.rb +61 -64
- data/spec/acceptance/spec_helper.rb +26 -3
- data/spec/acceptance/transactions_spec.rb +12 -16
- data/spec/setup/arangodb.sh +2 -2
- data/spec/unit/collection_spec.rb +224 -242
- data/spec/unit/configuration_spec.rb +64 -0
- data/spec/unit/connection_spec.rb +121 -111
- data/spec/unit/cursor_spec.rb +78 -65
- data/spec/unit/database_spec.rb +112 -163
- data/spec/unit/document_spec.rb +74 -70
- data/spec/unit/edge_spec.rb +45 -33
- data/spec/unit/exception_spec.rb +28 -38
- data/spec/unit/figure_spec.rb +44 -47
- data/spec/unit/index_spec.rb +27 -24
- data/spec/unit/key_options_spec.rb +19 -17
- data/spec/unit/query_spec.rb +186 -135
- data/spec/unit/spec_helper.rb +14 -3
- data/spec/unit/status_spec.rb +37 -37
- data/spec/unit/transaction_spec.rb +71 -74
- data/tasks/adjustments.rake +10 -34
- metadata +11 -13
- data/spec/acceptance/arango_helper.rb +0 -27
- data/spec/acceptance_auth/arango_helper.rb +0 -30
- data/spec/acceptance_auth/auth_spec.rb +0 -40
- data/spec/acceptance_auth/spec_helper.rb +0 -6
data/spec/unit/database_spec.rb
CHANGED
@@ -1,232 +1,181 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
require 'unit/spec_helper'
|
2
3
|
require 'ashikawa-core/database'
|
3
4
|
|
4
5
|
describe Ashikawa::Core::Database do
|
5
6
|
subject { Ashikawa::Core::Database }
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
let(:url) { double }
|
9
|
+
let(:host) { double }
|
10
|
+
let(:port) { double }
|
11
|
+
let(:scheme) { double }
|
12
|
+
let(:connection) { double('connection', host: host, port: port, scheme: scheme) }
|
13
|
+
let(:js_function) { double }
|
14
|
+
let(:collections) { double }
|
15
|
+
let(:transaction) { double }
|
16
|
+
let(:logger) { double }
|
17
|
+
let(:adapter) { double }
|
18
|
+
let(:configuration) { double }
|
19
|
+
|
20
|
+
it 'should initialize with a configuration object' do
|
21
|
+
expect(Ashikawa::Core::Configuration).to receive(:new)
|
22
|
+
.and_return(configuration)
|
23
|
+
expect(configuration).to receive(:connection)
|
24
|
+
expect { |b| Ashikawa::Core::Database.new(&b) }.to yield_with_args(configuration)
|
13
25
|
end
|
14
26
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
database = subject.new do |config|
|
20
|
-
config.connection = @connection
|
21
|
-
end
|
22
|
-
database.host.should == "localhost"
|
23
|
-
database.port.should == 8529
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should initialize with a connection string" do
|
27
|
-
Ashikawa::Core::Connection.stub(:new).with("http://localhost:8529", {
|
28
|
-
:logger => nil,
|
29
|
-
:adapter => nil
|
30
|
-
}).and_return(double)
|
31
|
-
Ashikawa::Core::Connection.should_receive(:new).with("http://localhost:8529", {
|
32
|
-
:logger => nil,
|
33
|
-
:adapter => nil
|
34
|
-
})
|
35
|
-
|
36
|
-
subject.new do |config|
|
37
|
-
config.url = "http://localhost:8529"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should initialize with a connection string and logger" do
|
42
|
-
logger = double
|
43
|
-
Ashikawa::Core::Connection.stub(:new).with("http://localhost:8529", {
|
44
|
-
:logger => logger,
|
45
|
-
:adapter => nil
|
46
|
-
}).and_return(double)
|
47
|
-
Ashikawa::Core::Connection.should_receive(:new).with("http://localhost:8529", {
|
48
|
-
:logger => logger,
|
49
|
-
:adapter => nil
|
50
|
-
})
|
51
|
-
|
52
|
-
subject.new do |config|
|
53
|
-
config.url = "http://localhost:8529"
|
54
|
-
config.logger = logger
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should initialize with a connection string and adapter" do
|
59
|
-
adapter = double
|
60
|
-
Ashikawa::Core::Connection.stub(:new).with("http://localhost:8529", {
|
61
|
-
:logger => nil,
|
62
|
-
:adapter => adapter
|
63
|
-
}).and_return(double)
|
64
|
-
Ashikawa::Core::Connection.should_receive(:new).with("http://localhost:8529", {
|
65
|
-
:logger => nil,
|
66
|
-
:adapter => adapter
|
67
|
-
})
|
68
|
-
|
69
|
-
subject.new do |config|
|
70
|
-
config.url = "http://localhost:8529"
|
71
|
-
config.adapter = adapter
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should throw an argument error when neither url nor connection was provided" do
|
76
|
-
adapter = double
|
77
|
-
logger = double
|
78
|
-
|
79
|
-
expect {
|
80
|
-
subject.new do |config|
|
81
|
-
config.adapter = adapter
|
82
|
-
config.logger = logger
|
27
|
+
describe 'initialized database' do
|
28
|
+
subject do
|
29
|
+
Ashikawa::Core::Database.new do |config|
|
30
|
+
config.connection = connection
|
83
31
|
end
|
84
|
-
}.to raise_error(ArgumentError, /either an url or a connection/)
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should create a query" do
|
88
|
-
database = subject.new do |config|
|
89
|
-
config.connection = @connection
|
90
32
|
end
|
91
33
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
database.query
|
97
|
-
end
|
34
|
+
it 'should create a query' do
|
35
|
+
expect(Ashikawa::Core::Query).to receive(:new)
|
36
|
+
.exactly(1).times
|
37
|
+
.with(subject)
|
98
38
|
|
99
|
-
|
100
|
-
|
101
|
-
Ashikawa::Core::Database.new do |config|
|
102
|
-
config.connection = @connection
|
103
|
-
end
|
104
|
-
}
|
39
|
+
subject.query
|
40
|
+
end
|
105
41
|
|
106
|
-
it
|
107
|
-
|
42
|
+
it 'should delegate authentication to the connection' do
|
43
|
+
expect(connection).to receive(:authenticate_with)
|
44
|
+
.with({ username: 'user', password: 'password' })
|
108
45
|
|
109
|
-
subject.authenticate_with :
|
46
|
+
subject.authenticate_with username: 'user', password: 'password'
|
110
47
|
end
|
111
48
|
|
112
|
-
it
|
113
|
-
|
114
|
-
|
49
|
+
it 'should fetch all available non-system collections' do
|
50
|
+
expect(connection).to receive(:send_request)
|
51
|
+
.with('collection')
|
52
|
+
.and_return { server_response('collections/all') }
|
115
53
|
|
116
54
|
(0..1).each do |k|
|
117
|
-
Ashikawa::Core::Collection.
|
55
|
+
expect(Ashikawa::Core::Collection).to receive(:new)
|
56
|
+
.with(subject, server_response('collections/all')['collections'][k])
|
118
57
|
end
|
119
58
|
|
120
|
-
subject.collections.length.
|
59
|
+
expect(subject.collections.length).to eq(2)
|
121
60
|
end
|
122
61
|
|
123
|
-
it
|
124
|
-
|
125
|
-
|
62
|
+
it 'should fetch all available non-system collections' do
|
63
|
+
expect(connection).to receive(:send_request)
|
64
|
+
.with('collection')
|
65
|
+
.and_return { server_response('collections/all') }
|
126
66
|
|
127
|
-
Ashikawa::Core::Collection.
|
67
|
+
expect(Ashikawa::Core::Collection).to receive(:new)
|
68
|
+
.exactly(5).times
|
128
69
|
|
129
|
-
subject.system_collections.length.
|
70
|
+
expect(subject.system_collections.length).to eq(5)
|
130
71
|
end
|
131
72
|
|
132
|
-
it
|
133
|
-
|
134
|
-
|
135
|
-
|
73
|
+
it 'should create a non volatile collection by default' do
|
74
|
+
expect(connection).to receive(:send_request)
|
75
|
+
.with('collection', post: { name: 'volatile_collection' })
|
76
|
+
.and_return { server_response('collections/60768679') }
|
136
77
|
|
137
|
-
Ashikawa::Core::Collection.
|
78
|
+
expect(Ashikawa::Core::Collection).to receive(:new)
|
79
|
+
.with(subject, server_response('collections/60768679'))
|
138
80
|
|
139
|
-
subject.create_collection(
|
81
|
+
subject.create_collection('volatile_collection')
|
140
82
|
end
|
141
83
|
|
142
|
-
it
|
143
|
-
|
144
|
-
|
145
|
-
|
84
|
+
it 'should create a volatile collection when asked' do
|
85
|
+
expect(connection).to receive(:send_request)
|
86
|
+
.with('collection', post: { name: 'volatile_collection', isVolatile: true })
|
87
|
+
.and_return { |path| server_response('collections/60768679') }
|
146
88
|
|
147
|
-
Ashikawa::Core::Collection.
|
89
|
+
expect(Ashikawa::Core::Collection).to receive(:new)
|
90
|
+
.with(subject, server_response('collections/60768679'))
|
148
91
|
|
149
|
-
subject.create_collection(
|
92
|
+
subject.create_collection('volatile_collection', is_volatile: true)
|
150
93
|
end
|
151
94
|
|
152
|
-
it
|
153
|
-
|
154
|
-
|
155
|
-
:
|
156
|
-
|
157
|
-
|
158
|
-
|
95
|
+
it 'should create an autoincrement collection when asked' do
|
96
|
+
expect(connection).to receive(:send_request).with('collection',
|
97
|
+
post: {
|
98
|
+
name: 'autoincrement_collection', keyOptions: {
|
99
|
+
type: 'autoincrement',
|
100
|
+
offset: 0,
|
101
|
+
increment: 10,
|
102
|
+
allowUserKeys: false
|
103
|
+
}
|
159
104
|
}
|
160
|
-
|
105
|
+
)
|
161
106
|
|
162
|
-
Ashikawa::Core::Collection.
|
107
|
+
expect(Ashikawa::Core::Collection).to receive(:new)
|
163
108
|
|
164
|
-
subject.create_collection(
|
165
|
-
:
|
166
|
-
:
|
167
|
-
:
|
168
|
-
:
|
109
|
+
subject.create_collection('autoincrement_collection', key_options: {
|
110
|
+
type: :autoincrement,
|
111
|
+
offset: 0,
|
112
|
+
increment: 10,
|
113
|
+
allow_user_keys: false
|
169
114
|
})
|
170
115
|
end
|
171
116
|
|
172
|
-
it
|
173
|
-
|
174
|
-
|
175
|
-
|
117
|
+
it 'should create an edge collection when asked' do
|
118
|
+
expect(connection).to receive(:send_request)
|
119
|
+
.with('collection', post: { name: 'volatile_collection', type: 3 })
|
120
|
+
.and_return { |path| server_response('collections/60768679') }
|
176
121
|
|
177
|
-
Ashikawa::Core::Collection.
|
122
|
+
expect(Ashikawa::Core::Collection).to receive(:new)
|
123
|
+
.with(subject, server_response('collections/60768679'))
|
178
124
|
|
179
|
-
subject.create_collection(
|
125
|
+
subject.create_collection('volatile_collection', content_type: :edge)
|
180
126
|
end
|
181
127
|
|
182
|
-
it
|
183
|
-
|
184
|
-
|
128
|
+
it 'should fetch a single collection if it exists' do
|
129
|
+
expect(connection).to receive(:send_request)
|
130
|
+
.with('collection/60768679')
|
131
|
+
.and_return { |path| server_response('collections/60768679') }
|
185
132
|
|
186
|
-
Ashikawa::Core::Collection.
|
133
|
+
expect(Ashikawa::Core::Collection).to receive(:new)
|
134
|
+
.with(subject, server_response('collections/60768679'))
|
187
135
|
|
188
|
-
subject.collection(
|
136
|
+
subject.collection(60_768_679)
|
189
137
|
end
|
190
138
|
|
191
|
-
it
|
192
|
-
|
193
|
-
|
139
|
+
it 'should fetch a single collection with the array syntax' do
|
140
|
+
expect(connection).to receive(:send_request)
|
141
|
+
.with('collection/60768679')
|
142
|
+
.and_return { |path| server_response('collections/60768679') }
|
194
143
|
|
195
|
-
Ashikawa::Core::Collection.
|
144
|
+
expect(Ashikawa::Core::Collection).to receive(:new)
|
145
|
+
.with(subject, server_response('collections/60768679'))
|
196
146
|
|
197
|
-
subject[
|
147
|
+
subject[60_768_679]
|
198
148
|
end
|
199
149
|
|
200
150
|
it "should create a single collection if it doesn't exist" do
|
201
|
-
|
151
|
+
allow(connection).to receive :send_request do |path, method|
|
202
152
|
method ||= {}
|
203
|
-
if method.
|
204
|
-
server_response(
|
153
|
+
if method.key? :post
|
154
|
+
server_response('collections/60768679')
|
205
155
|
else
|
206
156
|
raise Ashikawa::Core::CollectionNotFoundException
|
207
157
|
end
|
208
158
|
end
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
Ashikawa::Core::Collection.should_receive(:new).with(subject, server_response("collections/60768679"))
|
159
|
+
expect(connection).to receive(:send_request).with('collection/new_collection')
|
160
|
+
expect(connection).to receive(:send_request).with('collection', post: { name: 'new_collection' })
|
161
|
+
expect(Ashikawa::Core::Collection).to receive(:new).with(subject, server_response('collections/60768679'))
|
213
162
|
|
214
163
|
subject['new_collection']
|
215
164
|
end
|
216
165
|
|
217
|
-
it
|
218
|
-
|
166
|
+
it 'should send a request via the connection object' do
|
167
|
+
expect(connection).to receive(:send_request)
|
168
|
+
.with('my/path', post: { data: 'mydata' })
|
219
169
|
|
220
|
-
subject.send_request
|
170
|
+
subject.send_request 'my/path', post: { data: 'mydata' }
|
221
171
|
end
|
222
172
|
|
223
|
-
|
224
|
-
|
225
|
-
|
173
|
+
it 'should create a transaction' do
|
174
|
+
expect(Ashikawa::Core::Transaction).to receive(:new)
|
175
|
+
.with(subject, js_function, collections)
|
176
|
+
.and_return(transaction)
|
226
177
|
|
227
|
-
|
228
|
-
Ashikawa::Core::Transaction.should_receive(:new).with(subject, js_function, collections).and_return { transaction }
|
229
|
-
subject.create_transaction(js_function, collections).should == transaction
|
178
|
+
expect(subject.create_transaction(js_function, collections)).to be(transaction)
|
230
179
|
end
|
231
180
|
end
|
232
181
|
end
|
data/spec/unit/document_spec.rb
CHANGED
@@ -1,112 +1,116 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
require 'unit/spec_helper'
|
2
3
|
require 'ashikawa-core/document'
|
3
4
|
|
4
5
|
describe Ashikawa::Core::Document do
|
5
6
|
let(:database) { double }
|
6
|
-
let(:
|
7
|
+
let(:id) { 164 }
|
8
|
+
let(:path) { 'document/164' }
|
9
|
+
let(:key) { double }
|
10
|
+
let(:revision) { double }
|
11
|
+
let(:first_name) { double }
|
12
|
+
let(:last_name) { double }
|
13
|
+
let(:more_info) { double }
|
14
|
+
let(:delete_payload) {{ delete: {} }}
|
15
|
+
let(:raw_data) do
|
7
16
|
{
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
17
|
+
'_id' => id,
|
18
|
+
'_key' => key,
|
19
|
+
'_rev' => revision,
|
20
|
+
'first_name' => first_name,
|
21
|
+
'last_name' => last_name
|
13
22
|
}
|
14
|
-
|
15
|
-
let(:raw_data_without_id)
|
23
|
+
end
|
24
|
+
let(:raw_data_without_id) do
|
16
25
|
{
|
17
|
-
|
18
|
-
|
26
|
+
'first_name' => first_name,
|
27
|
+
'last_name' => last_name
|
19
28
|
}
|
20
|
-
}
|
21
|
-
subject { Ashikawa::Core::Document }
|
22
|
-
|
23
|
-
it "should initialize data with ID" do
|
24
|
-
document = subject.new database, raw_data
|
25
|
-
document.id.should == "1234567/2345678"
|
26
|
-
document.key.should == "2345678"
|
27
|
-
document.revision.should == "3456789"
|
28
29
|
end
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
document.id.should == :not_persisted
|
33
|
-
document.revision.should == :not_persisted
|
34
|
-
end
|
31
|
+
describe 'initializing' do
|
32
|
+
subject { Ashikawa::Core::Document }
|
35
33
|
|
36
|
-
|
37
|
-
|
34
|
+
let(:additional_data) do
|
35
|
+
{
|
36
|
+
more_info: more_info
|
37
|
+
}
|
38
|
+
end
|
38
39
|
|
39
|
-
it
|
40
|
-
subject
|
40
|
+
it 'should initialize with data including ID' do
|
41
|
+
document = subject.new(database, raw_data)
|
42
|
+
expect(document.id).to eq(id)
|
43
|
+
expect(document.key).to eq(key)
|
44
|
+
expect(document.revision).to eq(revision)
|
41
45
|
end
|
42
46
|
|
43
|
-
it
|
44
|
-
subject
|
47
|
+
it 'should initialize with data not including ID' do
|
48
|
+
document = subject.new(database, raw_data_without_id)
|
49
|
+
expect(document.id).to eq(:not_persisted)
|
50
|
+
expect(document.revision).to eq(:not_persisted)
|
45
51
|
end
|
46
52
|
|
47
|
-
it
|
48
|
-
|
49
|
-
|
50
|
-
|
53
|
+
it 'should initialize with additional data' do
|
54
|
+
document = subject.new(database, raw_data, additional_data)
|
55
|
+
expect(document['more_info']).to eq(more_info)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe 'initialized document with ID' do
|
60
|
+
subject { Ashikawa::Core::Document.new(database, raw_data) }
|
61
|
+
|
62
|
+
let(:new_last_name) { double }
|
63
|
+
let(:raw_data_without_id_and_new_last_name) do
|
64
|
+
{
|
65
|
+
'first_name' => first_name,
|
66
|
+
'last_name' => new_last_name
|
67
|
+
}
|
68
|
+
end
|
51
69
|
|
70
|
+
its(['first_name']) { should be(first_name) }
|
71
|
+
its(['no_name']) { should be_nil }
|
72
|
+
its(:hash) { should be_instance_of Hash }
|
73
|
+
its(:hash) { should include('first_name' => first_name) }
|
74
|
+
|
75
|
+
it 'should be deletable' do
|
76
|
+
expect(database).to receive(:send_request).with(path, delete_payload)
|
52
77
|
subject.delete
|
53
78
|
end
|
54
79
|
|
55
|
-
it
|
56
|
-
database.
|
57
|
-
|
80
|
+
it 'should store changes to the database' do
|
81
|
+
expect(database).to receive(:send_request).with(path,
|
82
|
+
{ put: raw_data_without_id_and_new_last_name }
|
58
83
|
)
|
59
84
|
|
60
|
-
subject[
|
85
|
+
subject['last_name'] = new_last_name
|
61
86
|
subject.save
|
62
87
|
end
|
63
88
|
|
64
|
-
it
|
65
|
-
|
66
|
-
|
67
|
-
hash["first_name"].should == subject["first_name"]
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should be refreshable" do
|
71
|
-
database.should_receive(:send_request).with("document/#{raw_data['_id']}", {}).and_return {
|
72
|
-
{ "name" => "Jeff" }
|
89
|
+
it 'should be refreshable' do
|
90
|
+
expect(database).to receive(:send_request).with(path, {}).and_return {
|
91
|
+
{ 'name' => 'Jeff' }
|
73
92
|
}
|
74
93
|
|
75
94
|
refreshed_subject = subject.refresh!
|
76
|
-
refreshed_subject.
|
77
|
-
subject[
|
95
|
+
expect(refreshed_subject).to eq(subject)
|
96
|
+
expect(subject['name']).to eq('Jeff')
|
78
97
|
end
|
79
98
|
end
|
80
99
|
|
81
|
-
describe
|
100
|
+
describe 'initialized document without ID' do
|
82
101
|
subject { Ashikawa::Core::Document.new database, raw_data_without_id }
|
83
102
|
|
84
|
-
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should return nil for an non-existing attribute" do
|
89
|
-
subject["no_name"].should be_nil
|
90
|
-
end
|
103
|
+
its(['first_name']) { should be(first_name) }
|
104
|
+
its(['no_name']) { should be_nil }
|
91
105
|
|
92
|
-
it
|
93
|
-
database.
|
106
|
+
it 'should not be deletable' do
|
107
|
+
expect(database).not_to receive :send_request
|
94
108
|
expect { subject.delete }.to raise_error Ashikawa::Core::DocumentNotFoundException
|
95
109
|
end
|
96
110
|
|
97
|
-
it
|
98
|
-
database.
|
111
|
+
it 'should not store changes to the database' do
|
112
|
+
expect(database).not_to receive :send_request
|
99
113
|
expect { subject.save }.to raise_error Ashikawa::Core::DocumentNotFoundException
|
100
114
|
end
|
101
115
|
end
|
102
|
-
|
103
|
-
describe "Deprecated methods" do
|
104
|
-
subject { Ashikawa::Core::Document.new database, raw_data_without_id }
|
105
|
-
|
106
|
-
it "should mark `to_hash` as deprecated" do
|
107
|
-
subject.should_receive(:hash)
|
108
|
-
subject.should_receive(:warn).with("`to_hash` is deprecated, please use `hash`")
|
109
|
-
subject.to_hash
|
110
|
-
end
|
111
|
-
end
|
112
116
|
end
|