riak-client 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +55 -12
- data/RELEASE_NOTES.md +20 -1
- data/lib/riak.rb +1 -0
- data/lib/riak/client.rb +2 -1
- data/lib/riak/client/beefcake/crdt/counter_loader.rb +18 -0
- data/lib/riak/client/beefcake/crdt/map_loader.rb +64 -0
- data/lib/riak/client/beefcake/crdt/set_loader.rb +18 -0
- data/lib/riak/client/beefcake/crdt_loader.rb +16 -59
- data/lib/riak/client/beefcake/crdt_operator.rb +2 -1
- data/lib/riak/client/instrumentation.rb +19 -0
- data/lib/riak/crdt/base.rb +16 -0
- data/lib/riak/errors/backend_creation.rb +9 -0
- data/lib/riak/instrumentation.rb +6 -0
- data/lib/riak/version.rb +1 -1
- data/riak-client.gemspec +3 -2
- data/spec/integration/riak/counters_spec.rb +1 -1
- data/spec/integration/riak/crdt_spec.rb +68 -23
- data/spec/integration/riak/protobuffs_backends_spec.rb +1 -1
- data/spec/integration/riak/threading_spec.rb +4 -4
- data/spec/integration/yokozuna/index_spec.rb +5 -5
- data/spec/integration/yokozuna/queries_spec.rb +15 -16
- data/spec/integration/yokozuna/schema_spec.rb +2 -2
- data/spec/riak/beefcake_protobuffs_backend/crdt_operator_spec.rb +8 -8
- data/spec/riak/beefcake_protobuffs_backend/object_methods_spec.rb +1 -1
- data/spec/riak/beefcake_protobuffs_backend_spec.rb +8 -8
- data/spec/riak/bucket_spec.rb +38 -38
- data/spec/riak/client_spec.rb +26 -27
- data/spec/riak/core_ext/to_param_spec.rb +2 -2
- data/spec/riak/counter_spec.rb +11 -11
- data/spec/riak/crdt/counter_spec.rb +4 -2
- data/spec/riak/crdt/inner_counter_spec.rb +1 -1
- data/spec/riak/crdt/inner_flag_spec.rb +4 -4
- data/spec/riak/crdt/inner_map_spec.rb +3 -3
- data/spec/riak/crdt/inner_register_spec.rb +5 -5
- data/spec/riak/crdt/inner_set_spec.rb +1 -1
- data/spec/riak/crdt/map_spec.rb +2 -2
- data/spec/riak/crdt/set_spec.rb +4 -2
- data/spec/riak/crdt/shared_examples.rb +15 -15
- data/spec/riak/crdt/typed_collection_spec.rb +16 -22
- data/spec/riak/escape_spec.rb +10 -10
- data/spec/riak/feature_detection_spec.rb +1 -1
- data/spec/riak/index_collection_spec.rb +7 -4
- data/spec/riak/instrumentation_spec.rb +124 -0
- data/spec/riak/link_spec.rb +12 -12
- data/spec/riak/list_buckets_spec.rb +2 -2
- data/spec/riak/map_reduce/filter_builder_spec.rb +5 -5
- data/spec/riak/map_reduce/phase_spec.rb +20 -20
- data/spec/riak/map_reduce_spec.rb +50 -50
- data/spec/riak/multiget_spec.rb +5 -5
- data/spec/riak/node_spec.rb +3 -3
- data/spec/riak/robject_spec.rb +46 -45
- data/spec/riak/search_spec.rb +11 -11
- data/spec/riak/secondary_index_spec.rb +9 -9
- data/spec/riak/stamp_spec.rb +5 -5
- data/spec/riak/walk_spec_spec.rb +30 -30
- data/spec/spec_helper.rb +6 -0
- data/spec/support/certs/ca.crt +19 -20
- data/spec/support/certs/client.crl +13 -0
- data/spec/support/certs/client.crt +68 -69
- data/spec/support/certs/client.csr +18 -0
- data/spec/support/certs/client.key +25 -25
- data/spec/support/certs/server.crl +11 -11
- data/spec/support/certs/server.crt +68 -69
- data/spec/support/certs/server.key +25 -25
- data/spec/support/unified_backend_examples.rb +33 -33
- metadata +31 -5
@@ -2,13 +2,13 @@
|
|
2
2
|
describe Riak do
|
3
3
|
require 'riak/core_ext/to_param'
|
4
4
|
|
5
|
-
it "
|
5
|
+
it "converts params correctly" do
|
6
6
|
expect({ :name => 'David', :nationality => 'Danish' }.to_param).to eq("name=David&nationality=Danish")
|
7
7
|
end
|
8
8
|
|
9
9
|
# Based on the activesupport implementation.
|
10
10
|
# https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/object/to_param.rb
|
11
|
-
it "
|
11
|
+
it "converts namespaced params correctly" do
|
12
12
|
expect({ :name => 'David', :nationality => 'Danish' }.to_param('user')).to eq("user%5Bname%5D=David&user%5Bnationality%5D=Danish")
|
13
13
|
end
|
14
14
|
|
data/spec/riak/counter_spec.rb
CHANGED
@@ -10,13 +10,13 @@ describe Riak::Counter do
|
|
10
10
|
allow(@bucket).to receive('is_a?').and_return(true)
|
11
11
|
end
|
12
12
|
|
13
|
-
it "
|
13
|
+
it "sets the bucket and key" do
|
14
14
|
ctr = Riak::Counter.new @bucket, @key
|
15
15
|
expect(ctr.bucket).to eq(@bucket)
|
16
16
|
expect(ctr.key).to eq(@key)
|
17
17
|
end
|
18
18
|
|
19
|
-
it "
|
19
|
+
it "requires allow_mult" do
|
20
20
|
@bad_bucket = Riak::Bucket.allocate
|
21
21
|
allow(@bad_bucket).to receive(:allow_mult).and_return(false)
|
22
22
|
allow(@bad_bucket).to receive(:client).and_return(double('client'))
|
@@ -44,37 +44,37 @@ describe Riak::Counter do
|
|
44
44
|
@increment_expectation = proc{|n| expect(@backend).to receive(:post_counter).with(@bucket, @key, n, {})}
|
45
45
|
end
|
46
46
|
|
47
|
-
it "
|
47
|
+
it "increments by 1 by default" do
|
48
48
|
@increment_expectation[1]
|
49
49
|
@ctr.increment
|
50
50
|
end
|
51
51
|
|
52
|
-
it "
|
52
|
+
it "increments by positive numbers" do
|
53
53
|
@increment_expectation[15]
|
54
54
|
@ctr.increment 15
|
55
55
|
end
|
56
56
|
|
57
|
-
it "
|
57
|
+
it "increments by negative numbers" do
|
58
58
|
@increment_expectation[-12]
|
59
59
|
@ctr.increment -12
|
60
60
|
end
|
61
61
|
|
62
|
-
it "
|
62
|
+
it "decrements by 1 by default" do
|
63
63
|
@increment_expectation[-1]
|
64
64
|
@ctr.decrement
|
65
65
|
end
|
66
66
|
|
67
|
-
it "
|
67
|
+
it "decrements by positive numbers" do
|
68
68
|
@increment_expectation[-30]
|
69
69
|
@ctr.decrement 30
|
70
70
|
end
|
71
71
|
|
72
|
-
it "
|
72
|
+
it "decrements by negative numbers" do
|
73
73
|
@increment_expectation[41]
|
74
74
|
@ctr.decrement -41
|
75
75
|
end
|
76
76
|
|
77
|
-
it "
|
77
|
+
it "forbids incrementing by non-integers" do
|
78
78
|
[1.1, nil, :'1', '1', 2.0/2, [1]].each do |candidate|
|
79
79
|
expect do
|
80
80
|
@ctr.increment candidate
|
@@ -109,12 +109,12 @@ describe Riak::Counter do
|
|
109
109
|
@ctr = Riak::Counter.new @bucket, @key
|
110
110
|
end
|
111
111
|
|
112
|
-
it "
|
112
|
+
it "doesn't retry on timeout" do
|
113
113
|
@expect_post.once.and_raise('timeout')
|
114
114
|
expect(proc { @ctr.increment }).to raise_error
|
115
115
|
end
|
116
116
|
|
117
|
-
it "
|
117
|
+
it "doesn't retry on quorum failure" do
|
118
118
|
@expect_post.once.and_raise('quorum not satisfied')
|
119
119
|
expect(proc { @ctr.increment }).to raise_error
|
120
120
|
end
|
@@ -8,7 +8,7 @@ describe Riak::Crdt::Counter do
|
|
8
8
|
allow(b).to receive(:is_a?).and_return(true)
|
9
9
|
end
|
10
10
|
end
|
11
|
-
it '
|
11
|
+
it 'initializes with bucket, key, and optional bucket-type' do
|
12
12
|
expect{ described_class.new bucket, 'key' }.to_not raise_error
|
13
13
|
expect{ described_class.new bucket, 'key', 'type' }.to_not raise_error
|
14
14
|
end
|
@@ -18,6 +18,7 @@ describe Riak::Crdt::Counter do
|
|
18
18
|
describe 'with a client' do
|
19
19
|
let(:response){ double 'response', key: nil }
|
20
20
|
let(:operator){ double 'operator' }
|
21
|
+
let(:loader){ double 'loader', get_loader_for_value: nil }
|
21
22
|
let(:backend){ double 'backend' }
|
22
23
|
let(:client){ double 'client' }
|
23
24
|
|
@@ -25,11 +26,12 @@ describe Riak::Crdt::Counter do
|
|
25
26
|
allow(bucket).to receive(:client).and_return(client)
|
26
27
|
allow(client).to receive(:backend).and_yield(backend)
|
27
28
|
allow(backend).to receive(:crdt_operator).and_return(operator)
|
29
|
+
allow(backend).to receive(:crdt_loader).and_return(loader)
|
28
30
|
end
|
29
31
|
|
30
32
|
include_examples 'Counter CRDT'
|
31
33
|
|
32
|
-
it '
|
34
|
+
it 'batches properly' do
|
33
35
|
expect(operator).
|
34
36
|
to receive(:operate) { |bucket, key, type, operations|
|
35
37
|
expect(bucket).to eq bucket
|
@@ -5,7 +5,7 @@ describe Riak::Crdt::InnerFlag do
|
|
5
5
|
describe 'a truthy flag' do
|
6
6
|
subject { described_class.new parent, true }
|
7
7
|
|
8
|
-
it '
|
8
|
+
it 'feels truthy' do
|
9
9
|
expect(subject).to be
|
10
10
|
end
|
11
11
|
end
|
@@ -13,7 +13,7 @@ describe Riak::Crdt::InnerFlag do
|
|
13
13
|
describe 'a falsey flag' do
|
14
14
|
subject { described_class.new parent, false }
|
15
15
|
|
16
|
-
it '
|
16
|
+
it 'feels falsey' do
|
17
17
|
expect(subject).to_not be
|
18
18
|
end
|
19
19
|
end
|
@@ -21,7 +21,7 @@ describe Riak::Crdt::InnerFlag do
|
|
21
21
|
describe 'updating' do
|
22
22
|
let(:new_value){ false }
|
23
23
|
|
24
|
-
it '
|
24
|
+
it '\asks the class for an update operation' do
|
25
25
|
operation = described_class.update(new_value)
|
26
26
|
|
27
27
|
expect(operation.value).to eq new_value
|
@@ -30,7 +30,7 @@ describe Riak::Crdt::InnerFlag do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
describe 'deleting' do
|
33
|
-
it '
|
33
|
+
it 'asks the class for a delete operation' do
|
34
34
|
operation = described_class.delete
|
35
35
|
|
36
36
|
expect(operation.type).to eq :flag
|
@@ -17,13 +17,13 @@ describe Riak::Crdt::InnerMap do
|
|
17
17
|
}
|
18
18
|
end
|
19
19
|
|
20
|
-
it '
|
20
|
+
it 'is initializable with a nested hash of maps' do
|
21
21
|
expect{described_class.new parent, populated_contents}.
|
22
22
|
to_not raise_error
|
23
23
|
end
|
24
24
|
|
25
25
|
describe 'deleting the inner map' do
|
26
|
-
it '
|
26
|
+
it 'asks the class for a delete operation' do
|
27
27
|
operation = described_class.delete
|
28
28
|
|
29
29
|
expect(operation.type).to eq :map
|
@@ -32,7 +32,7 @@ describe Riak::Crdt::InnerMap do
|
|
32
32
|
|
33
33
|
describe 'receiving an operation' do
|
34
34
|
let(:inner_operation){ double 'inner operation' }
|
35
|
-
it '
|
35
|
+
it 'wraps the operation in an update operation and pass it to the parent' do
|
36
36
|
subject.name = 'name'
|
37
37
|
|
38
38
|
expect(parent).to receive(:operate) do |name, op|
|
@@ -4,17 +4,17 @@ describe Riak::Crdt::InnerRegister do
|
|
4
4
|
let(:parent){ double 'parent' }
|
5
5
|
subject { described_class.new parent, "espressos" }
|
6
6
|
|
7
|
-
it '
|
7
|
+
it 'feels like a string' do
|
8
8
|
expect(subject).to match 'espressos'
|
9
9
|
expect{ subject.gsub('s', 'x') }.to_not raise_error
|
10
10
|
expect(subject.gsub('s', 'x')).to eq 'exprexxox'
|
11
11
|
end
|
12
12
|
|
13
13
|
describe 'immutability' do
|
14
|
-
it '
|
14
|
+
it 'is frozen' do
|
15
15
|
expect(subject.frozen?).to be
|
16
16
|
end
|
17
|
-
it "
|
17
|
+
it "isn't be gsub!-able" do
|
18
18
|
# "gsub!-able" is awful, open to suggestions
|
19
19
|
expect{ subject.gsub!('s', 'x') }.to raise_error
|
20
20
|
end
|
@@ -22,7 +22,7 @@ describe Riak::Crdt::InnerRegister do
|
|
22
22
|
|
23
23
|
describe 'updating' do
|
24
24
|
let(:new_value){ 'new value' }
|
25
|
-
it "
|
25
|
+
it "asks the class for an update operation" do
|
26
26
|
operation = described_class.update(new_value)
|
27
27
|
|
28
28
|
expect(operation.value).to eq new_value
|
@@ -31,7 +31,7 @@ describe Riak::Crdt::InnerRegister do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
describe 'deleting' do
|
34
|
-
it '
|
34
|
+
it 'asks the class for a delete operation' do
|
35
35
|
operation = described_class.delete
|
36
36
|
|
37
37
|
expect(operation.type).to eq :register
|
@@ -12,7 +12,7 @@ describe Riak::Crdt::InnerSet do
|
|
12
12
|
|
13
13
|
include_examples 'Set CRDT'
|
14
14
|
|
15
|
-
it '
|
15
|
+
it 'sends additions to the parent' do
|
16
16
|
expect(parent).to receive(:operate) do |name, op|
|
17
17
|
expect(name).to eq set_name
|
18
18
|
expect(op.type).to eq :set
|
data/spec/riak/crdt/map_spec.rb
CHANGED
@@ -28,7 +28,7 @@ describe Riak::Crdt::Map do
|
|
28
28
|
include_examples 'Map CRDT'
|
29
29
|
|
30
30
|
describe 'batch mode' do
|
31
|
-
it '
|
31
|
+
it 'queues up operations' do
|
32
32
|
expect(operator).
|
33
33
|
to receive(:operate) do |bucket, key_arg, type, operations|
|
34
34
|
|
@@ -51,7 +51,7 @@ describe Riak::Crdt::Map do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
describe 'immediate mode' do
|
54
|
-
it '
|
54
|
+
it 'submits member operations immediately' do
|
55
55
|
expect(operator).
|
56
56
|
to receive(:operate) do |bucket, key_arg, type, operations|
|
57
57
|
|
data/spec/riak/crdt/set_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe Riak::Crdt::Set do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
it '
|
12
|
+
it 'initializes with bucket, key, and optional bucket-type' do
|
13
13
|
expect{described_class.new bucket, 'key', 'optional bucket type'}.
|
14
14
|
to_not raise_error
|
15
15
|
end
|
@@ -19,6 +19,7 @@ describe Riak::Crdt::Set do
|
|
19
19
|
describe 'with a client' do
|
20
20
|
let(:response){ double 'response', key: nil }
|
21
21
|
let(:operator){ double 'operator' }
|
22
|
+
let(:loader){ double 'loader', get_loader_for_value: nil }
|
22
23
|
let(:backend){ double 'backend' }
|
23
24
|
let(:client){ double 'client' }
|
24
25
|
|
@@ -26,11 +27,12 @@ describe Riak::Crdt::Set do
|
|
26
27
|
allow(bucket).to receive(:client).and_return(client)
|
27
28
|
allow(client).to receive(:backend).and_yield(backend)
|
28
29
|
allow(backend).to receive(:crdt_operator).and_return(operator)
|
30
|
+
allow(backend).to receive(:crdt_loader).and_return(loader)
|
29
31
|
end
|
30
32
|
|
31
33
|
include_examples 'Set CRDT'
|
32
34
|
|
33
|
-
it '
|
35
|
+
it 'batches properly' do
|
34
36
|
expect(operator).
|
35
37
|
to receive(:operate) { |bucket, key, type, operations|
|
36
38
|
|
@@ -1,74 +1,74 @@
|
|
1
1
|
shared_examples_for "Map CRDT" do
|
2
2
|
let(:typed_collection){ Riak::Crdt::TypedCollection }
|
3
3
|
|
4
|
-
it '
|
4
|
+
it 'contains counters' do
|
5
5
|
expect(subject).to respond_to(:counters)
|
6
6
|
expect(subject.counters).to be_an_instance_of typed_collection
|
7
7
|
end
|
8
8
|
|
9
|
-
it '
|
9
|
+
it 'contains flags' do
|
10
10
|
expect(subject).to respond_to(:flags)
|
11
11
|
expect(subject.counters).to be_an_instance_of typed_collection
|
12
12
|
end
|
13
13
|
|
14
|
-
it '
|
14
|
+
it 'contains maps' do
|
15
15
|
expect(subject).to respond_to(:maps)
|
16
16
|
expect(subject.counters).to be_an_instance_of typed_collection
|
17
17
|
end
|
18
18
|
|
19
|
-
it '
|
19
|
+
it 'contains registers' do
|
20
20
|
expect(subject).to respond_to(:registers)
|
21
21
|
expect(subject.counters).to be_an_instance_of typed_collection
|
22
22
|
end
|
23
23
|
|
24
|
-
it '
|
24
|
+
it 'contains sets' do
|
25
25
|
expect(subject).to respond_to(:sets)
|
26
26
|
expect(subject.counters).to be_an_instance_of typed_collection
|
27
27
|
end
|
28
28
|
|
29
|
-
it '
|
29
|
+
it 'accepts operations' do
|
30
30
|
expect(subject).to respond_to(:operate)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
shared_examples_for "Counter CRDT" do
|
35
|
-
it '
|
35
|
+
it 'has a value' do
|
36
36
|
expect(subject).to respond_to :value
|
37
37
|
end
|
38
38
|
|
39
|
-
it '
|
39
|
+
it 'has an increment method' do
|
40
40
|
expect(subject).to respond_to :increment
|
41
41
|
end
|
42
42
|
|
43
|
-
it '
|
43
|
+
it 'has a decrement method' do
|
44
44
|
expect(subject).to respond_to :decrement
|
45
45
|
end
|
46
46
|
|
47
|
-
it '
|
47
|
+
it 'has a batch method' do
|
48
48
|
expect(subject).to respond_to :batch
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
shared_examples_for 'Set CRDT' do
|
53
|
-
it '
|
53
|
+
it 'has a value' do
|
54
54
|
expect(subject).to respond_to :value
|
55
55
|
expect(subject).to respond_to :members
|
56
56
|
expect(subject).to respond_to :to_a
|
57
57
|
end
|
58
58
|
|
59
|
-
it '
|
59
|
+
it 'has an include? method' do
|
60
60
|
expect(subject).to respond_to :include?
|
61
61
|
end
|
62
62
|
|
63
|
-
it '
|
63
|
+
it 'has an empty? method' do
|
64
64
|
expect(subject).to respond_to :empty?
|
65
65
|
end
|
66
66
|
|
67
|
-
it '
|
67
|
+
it 'has an add method' do
|
68
68
|
expect(subject).to respond_to :add
|
69
69
|
end
|
70
70
|
|
71
|
-
it '
|
71
|
+
it 'has a remove method' do
|
72
72
|
expect(subject).to respond_to :remove
|
73
73
|
end
|
74
74
|
end
|
@@ -5,7 +5,7 @@ describe Riak::Crdt::TypedCollection do
|
|
5
5
|
let(:operation){ double 'operation' }
|
6
6
|
|
7
7
|
describe 'initialization' do
|
8
|
-
it "
|
8
|
+
it "accepts a type, parent, and hash of values" do
|
9
9
|
expect{ described_class.new Riak::Crdt::Counter, parent, {} }.to_not raise_error
|
10
10
|
end
|
11
11
|
end
|
@@ -17,7 +17,7 @@ describe Riak::Crdt::TypedCollection do
|
|
17
17
|
described_class.new register_class, parent, existing: 'existing'
|
18
18
|
end
|
19
19
|
|
20
|
-
it '
|
20
|
+
it 'exposes them as frozen strings that are really Registers' do
|
21
21
|
expect(subject[:existing]).to eq 'existing'
|
22
22
|
expect(subject['existing']).to eq 'existing'
|
23
23
|
expect(subject[:existing]).to be_an_instance_of register_class
|
@@ -29,10 +29,7 @@ describe Riak::Crdt::TypedCollection do
|
|
29
29
|
|
30
30
|
let(:new_value){ 'the new value' }
|
31
31
|
|
32
|
-
it
|
33
|
-
should ask the register class for an operation with the new value,
|
34
|
-
add a name to it, and pass it up to the parent
|
35
|
-
EOD
|
32
|
+
it 'asks the register class for an operation' do
|
36
33
|
expect(register_class).to receive(:update).
|
37
34
|
with(new_value).
|
38
35
|
and_return(operation)
|
@@ -51,10 +48,7 @@ describe Riak::Crdt::TypedCollection do
|
|
51
48
|
|
52
49
|
describe 'removing' do
|
53
50
|
|
54
|
-
it
|
55
|
-
should ask the register class for a remove operation, add a name to
|
56
|
-
it, and pass it up to the parent
|
57
|
-
EOD
|
51
|
+
it 'asks the register class for a remove operation' do
|
58
52
|
expect(register_class).
|
59
53
|
to receive(:delete).
|
60
54
|
and_return(operation)
|
@@ -77,12 +71,12 @@ describe Riak::Crdt::TypedCollection do
|
|
77
71
|
described_class.new flag_class, parent, truthy: true, falsey: false
|
78
72
|
end
|
79
73
|
|
80
|
-
it '
|
74
|
+
it 'exposes them as booleans' do
|
81
75
|
expect(subject[:truthy]).to eq true
|
82
76
|
expect(subject['falsey']).to eq false
|
83
77
|
end
|
84
78
|
|
85
|
-
it '
|
79
|
+
it 'updates them' do
|
86
80
|
expect(flag_class).
|
87
81
|
to receive(:update).
|
88
82
|
with(true).
|
@@ -99,7 +93,7 @@ describe Riak::Crdt::TypedCollection do
|
|
99
93
|
subject['become_truthy'] = true
|
100
94
|
end
|
101
95
|
|
102
|
-
it '
|
96
|
+
it 'deletes them' do
|
103
97
|
expect(flag_class).
|
104
98
|
to receive(:delete).
|
105
99
|
and_return(operation)
|
@@ -120,19 +114,19 @@ describe Riak::Crdt::TypedCollection do
|
|
120
114
|
|
121
115
|
subject{ described_class.new counter_class, parent, zero: 0, one: 1 }
|
122
116
|
|
123
|
-
it '
|
117
|
+
it 'exposes existing ones as Counter instances' do
|
124
118
|
expect(subject['zero']).to be_an_instance_of counter_class
|
125
119
|
expect(subject['zero'].to_i).to eq 0
|
126
120
|
|
127
121
|
expect(subject['one'].to_i).to eq 1
|
128
122
|
end
|
129
123
|
|
130
|
-
it '
|
124
|
+
it 'exposes new ones as Counter instances' do
|
131
125
|
expect(subject['new_zero']).to be_an_instance_of counter_class
|
132
126
|
expect(subject['new_zero'].to_i).to eq 0
|
133
127
|
end
|
134
128
|
|
135
|
-
it '
|
129
|
+
it 'allows incrementing and decrementing' do
|
136
130
|
counter_name = 'counter'
|
137
131
|
|
138
132
|
expect(parent).to receive(:operate) do |op|
|
@@ -156,17 +150,17 @@ describe Riak::Crdt::TypedCollection do
|
|
156
150
|
|
157
151
|
subject{ described_class.new set_class, parent, brewers: %w{aeropress clever v60}}
|
158
152
|
|
159
|
-
it '
|
153
|
+
it 'exposes existing ones as Set instances' do
|
160
154
|
expect(subject['brewers']).to be_an_instance_of set_class
|
161
155
|
expect(subject['brewers']).to include 'aeropress'
|
162
156
|
end
|
163
157
|
|
164
|
-
it '
|
158
|
+
it 'exposes new ones as empty Set instances' do
|
165
159
|
expect(subject['filters']).to be_an_instance_of set_class
|
166
160
|
expect(subject['filters']).to be_empty
|
167
161
|
end
|
168
162
|
|
169
|
-
it '
|
163
|
+
it 'allows adding and removing' do
|
170
164
|
set_name = 'brewers'
|
171
165
|
|
172
166
|
expect(parent).to receive(:operate) do |op|
|
@@ -205,17 +199,17 @@ describe Riak::Crdt::TypedCollection do
|
|
205
199
|
described_class.new map_class, parent, contents
|
206
200
|
end
|
207
201
|
|
208
|
-
it '
|
202
|
+
it 'exposes existing ones as populated Map instances' do
|
209
203
|
expect(subject['a']).to be_an_instance_of map_class
|
210
204
|
expect(subject['a'].registers['hello']).to eq 'world'
|
211
205
|
end
|
212
206
|
|
213
|
-
it '
|
207
|
+
it 'exposes new ones as empty Map instances' do
|
214
208
|
expect(subject['b']).to be_an_instance_of map_class
|
215
209
|
expect(subject['b'].registers['hello']).to be_nil
|
216
210
|
end
|
217
211
|
|
218
|
-
it '
|
212
|
+
it 'cascades operations to a parent map' do
|
219
213
|
expect(operation).
|
220
214
|
to receive(:name=).
|
221
215
|
with(inner_map_name)
|