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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/README.markdown +55 -12
  3. data/RELEASE_NOTES.md +20 -1
  4. data/lib/riak.rb +1 -0
  5. data/lib/riak/client.rb +2 -1
  6. data/lib/riak/client/beefcake/crdt/counter_loader.rb +18 -0
  7. data/lib/riak/client/beefcake/crdt/map_loader.rb +64 -0
  8. data/lib/riak/client/beefcake/crdt/set_loader.rb +18 -0
  9. data/lib/riak/client/beefcake/crdt_loader.rb +16 -59
  10. data/lib/riak/client/beefcake/crdt_operator.rb +2 -1
  11. data/lib/riak/client/instrumentation.rb +19 -0
  12. data/lib/riak/crdt/base.rb +16 -0
  13. data/lib/riak/errors/backend_creation.rb +9 -0
  14. data/lib/riak/instrumentation.rb +6 -0
  15. data/lib/riak/version.rb +1 -1
  16. data/riak-client.gemspec +3 -2
  17. data/spec/integration/riak/counters_spec.rb +1 -1
  18. data/spec/integration/riak/crdt_spec.rb +68 -23
  19. data/spec/integration/riak/protobuffs_backends_spec.rb +1 -1
  20. data/spec/integration/riak/threading_spec.rb +4 -4
  21. data/spec/integration/yokozuna/index_spec.rb +5 -5
  22. data/spec/integration/yokozuna/queries_spec.rb +15 -16
  23. data/spec/integration/yokozuna/schema_spec.rb +2 -2
  24. data/spec/riak/beefcake_protobuffs_backend/crdt_operator_spec.rb +8 -8
  25. data/spec/riak/beefcake_protobuffs_backend/object_methods_spec.rb +1 -1
  26. data/spec/riak/beefcake_protobuffs_backend_spec.rb +8 -8
  27. data/spec/riak/bucket_spec.rb +38 -38
  28. data/spec/riak/client_spec.rb +26 -27
  29. data/spec/riak/core_ext/to_param_spec.rb +2 -2
  30. data/spec/riak/counter_spec.rb +11 -11
  31. data/spec/riak/crdt/counter_spec.rb +4 -2
  32. data/spec/riak/crdt/inner_counter_spec.rb +1 -1
  33. data/spec/riak/crdt/inner_flag_spec.rb +4 -4
  34. data/spec/riak/crdt/inner_map_spec.rb +3 -3
  35. data/spec/riak/crdt/inner_register_spec.rb +5 -5
  36. data/spec/riak/crdt/inner_set_spec.rb +1 -1
  37. data/spec/riak/crdt/map_spec.rb +2 -2
  38. data/spec/riak/crdt/set_spec.rb +4 -2
  39. data/spec/riak/crdt/shared_examples.rb +15 -15
  40. data/spec/riak/crdt/typed_collection_spec.rb +16 -22
  41. data/spec/riak/escape_spec.rb +10 -10
  42. data/spec/riak/feature_detection_spec.rb +1 -1
  43. data/spec/riak/index_collection_spec.rb +7 -4
  44. data/spec/riak/instrumentation_spec.rb +124 -0
  45. data/spec/riak/link_spec.rb +12 -12
  46. data/spec/riak/list_buckets_spec.rb +2 -2
  47. data/spec/riak/map_reduce/filter_builder_spec.rb +5 -5
  48. data/spec/riak/map_reduce/phase_spec.rb +20 -20
  49. data/spec/riak/map_reduce_spec.rb +50 -50
  50. data/spec/riak/multiget_spec.rb +5 -5
  51. data/spec/riak/node_spec.rb +3 -3
  52. data/spec/riak/robject_spec.rb +46 -45
  53. data/spec/riak/search_spec.rb +11 -11
  54. data/spec/riak/secondary_index_spec.rb +9 -9
  55. data/spec/riak/stamp_spec.rb +5 -5
  56. data/spec/riak/walk_spec_spec.rb +30 -30
  57. data/spec/spec_helper.rb +6 -0
  58. data/spec/support/certs/ca.crt +19 -20
  59. data/spec/support/certs/client.crl +13 -0
  60. data/spec/support/certs/client.crt +68 -69
  61. data/spec/support/certs/client.csr +18 -0
  62. data/spec/support/certs/client.key +25 -25
  63. data/spec/support/certs/server.crl +11 -11
  64. data/spec/support/certs/server.crt +68 -69
  65. data/spec/support/certs/server.key +25 -25
  66. data/spec/support/unified_backend_examples.rb +33 -33
  67. metadata +31 -5
@@ -7,7 +7,7 @@ describe Riak::Util::Escape do
7
7
  @object.extend(Riak::Util::Escape)
8
8
  end
9
9
 
10
- it "should use URI by default for escaping" do
10
+ it "uses URI by default for escaping" do
11
11
  expect(Riak.escaper).to eq(URI)
12
12
  end
13
13
 
@@ -15,21 +15,21 @@ describe Riak::Util::Escape do
15
15
  before { @oldesc, Riak.escaper = Riak.escaper, CGI }
16
16
  after { Riak.escaper = @oldesc }
17
17
 
18
- it "should escape standard non-safe characters" do
18
+ it "escapes standard non-safe characters" do
19
19
  expect(@object.escape("some string")).to eq("some%20string")
20
20
  expect(@object.escape("another^one")).to eq("another%5Eone")
21
21
  expect(@object.escape("bracket[one")).to eq("bracket%5Bone")
22
22
  end
23
23
 
24
- it "should escape slashes" do
24
+ it "escapes slashes" do
25
25
  expect(@object.escape("some/inner/path")).to eq("some%2Finner%2Fpath")
26
26
  end
27
27
 
28
- it "should convert the bucket or key to a string before escaping" do
28
+ it "converts the bucket or key to a string before escaping" do
29
29
  expect(@object.escape(125)).to eq('125')
30
30
  end
31
31
 
32
- it "should unescape escaped strings" do
32
+ it "unescapes escaped strings" do
33
33
  expect(@object.unescape("some%20string")).to eq("some string")
34
34
  expect(@object.unescape("another%5Eone")).to eq("another^one")
35
35
  expect(@object.unescape("bracket%5Bone")).to eq("bracket[one")
@@ -41,26 +41,26 @@ describe Riak::Util::Escape do
41
41
  before { @oldesc, Riak.escaper = Riak.escaper, URI }
42
42
  after { Riak.escaper = @oldesc }
43
43
 
44
- it "should escape standard non-safe characters" do
44
+ it "escapes standard non-safe characters" do
45
45
  expect(@object.escape("some string")).to eq("some%20string")
46
46
  expect(@object.escape("another^one")).to eq("another%5Eone")
47
47
  expect(@object.escape("--one+two--")).to eq("--one%2Btwo--")
48
48
  end
49
49
 
50
- it "should allow URI-safe characters" do
50
+ it "allows URI-safe characters" do
51
51
  expect(@object.escape("bracket[one")).to eq("bracket[one")
52
52
  expect(@object.escape("sean@basho")).to eq("sean@basho")
53
53
  end
54
54
 
55
- it "should escape slashes" do
55
+ it "escapes slashes" do
56
56
  expect(@object.escape("some/inner/path")).to eq("some%2Finner%2Fpath")
57
57
  end
58
58
 
59
- it "should convert the bucket or key to a string before escaping" do
59
+ it "converts the bucket or key to a string before escaping" do
60
60
  expect(@object.escape(125)).to eq('125')
61
61
  end
62
62
 
63
- it "should unescape escaped strings" do
63
+ it "unescapes escaped strings" do
64
64
  expect(@object.unescape("some%20string")).to eq("some string")
65
65
  expect(@object.unescape("another%5Eone")).to eq("another^one")
66
66
  expect(@object.unescape("bracket%5Bone")).to eq("bracket[one")
@@ -10,7 +10,7 @@ describe Riak::Client::FeatureDetection do
10
10
  subject { klass.new }
11
11
 
12
12
  context "when the get_server_version is unimplemented" do
13
- it "should raise a NotImplementedError" do
13
+ it "raises a NotImplementedError" do
14
14
  expect { subject.server_version }.to raise_error(NotImplementedError)
15
15
  end
16
16
  end
@@ -2,14 +2,15 @@ require 'spec_helper'
2
2
 
3
3
  describe Riak::IndexCollection do
4
4
  describe "json initialization" do
5
- it "should accept a list of keys" do
5
+ it "accepts a list of keys" do
6
6
  @input = {
7
7
  'keys' => %w{first second third}
8
8
  }.to_json
9
9
  expect { @coll = Riak::IndexCollection.new_from_json @input }.not_to raise_error
10
10
  expect(%w{first second third}).to eq(@coll)
11
11
  end
12
- it "should accept a list of keys and a continuation" do
12
+
13
+ it "accepts a list of keys and a continuation" do
13
14
  @input = {
14
15
  'keys' => %w{first second third},
15
16
  'continuation' => 'examplecontinuation'
@@ -18,7 +19,8 @@ describe Riak::IndexCollection do
18
19
  expect(%w{first second third}).to eq(@coll)
19
20
  expect(@coll.continuation).to eq('examplecontinuation')
20
21
  end
21
- it "should accept a list of results hashes" do
22
+
23
+ it "accepts a list of results hashes" do
22
24
  @input = {
23
25
  'results' => [
24
26
  {'first' => 'first'},
@@ -31,7 +33,8 @@ describe Riak::IndexCollection do
31
33
  expect(%w{first second other}).to eq(@coll)
32
34
  expect({'first' => %w{first}, 'second' => %w{second other}}).to eq(@coll.with_terms)
33
35
  end
34
- it "should accept a list of results hashes and a continuation" do
36
+
37
+ it "accepts a list of results hashes and a continuation" do
35
38
  @input = {
36
39
  'results' => [
37
40
  {'first' => 'first'},
@@ -0,0 +1,124 @@
1
+ require 'spec_helper'
2
+
3
+ describe Riak::Client do
4
+
5
+ before do
6
+ @client = Riak::Client.new
7
+ @backend = double("Backend")
8
+ allow(@client).to receive(:backend).and_yield(@backend)
9
+ allow(@client).to receive(:http).and_yield(@backend)
10
+ @bucket = Riak::Bucket.new(@client, "foo")
11
+
12
+ @events = []
13
+ @notifier = ActiveSupport::Notifications.notifier
14
+ @notifier.subscribe { |*args| (@events ||= []) << event(*args) }
15
+ end
16
+
17
+ describe "instrumentation", instrumentation: true do
18
+
19
+ it "should notify on the 'buckets' operation" do
20
+ expect(@backend).to receive(:list_buckets).and_return(%w{test test2})
21
+ test_client_event(@client, 'riak.list_buckets') do
22
+ @client.buckets
23
+ end
24
+ end
25
+
26
+ it "should notify on the 'list_buckets' operation" do
27
+ expect(@backend).to receive(:list_buckets).and_return(%w{test test2})
28
+ test_client_event(@client, 'riak.list_buckets') do
29
+ @client.list_buckets
30
+ end
31
+ end
32
+
33
+ it "should notify on the 'list_keys' operation" do
34
+ expect(@backend).to receive(:list_keys).and_return(%w{test test2})
35
+ test_client_event(@client, 'riak.list_keys') do
36
+ @client.list_keys(@bucket)
37
+ end
38
+ end
39
+
40
+ it "should notify on the 'get_bucket_props' operation" do
41
+ expect(@backend).to receive(:get_bucket_props).and_return({})
42
+ test_client_event(@client, 'riak.get_bucket_props') do
43
+ @client.get_bucket_props(@bucket)
44
+ end
45
+ end
46
+
47
+ it "should notify on the 'set_bucket_props' operation" do
48
+ expect(@backend).to receive(:set_bucket_props).and_return({})
49
+ test_client_event(@client, 'riak.set_bucket_props') do
50
+ @client.set_bucket_props(@bucket, {})
51
+ end
52
+ end
53
+
54
+ it "should notify on the 'clear_bucket_props' operation" do
55
+ expect(@backend).to receive(:reset_bucket_props).and_return({})
56
+ test_client_event(@client, 'riak.clear_bucket_props') do
57
+ @client.clear_bucket_props(@bucket)
58
+ end
59
+ end
60
+
61
+ it "should notify on the 'get_index' operation" do
62
+ expect(@backend).to receive(:get_index).and_return({})
63
+ test_client_event(@client, 'riak.get_index') do
64
+ @client.get_index(@bucket, 'index', 'query', {})
65
+ end
66
+ end
67
+
68
+ it "should notify on the 'get_object' operation" do
69
+ expect(@backend).to receive(:fetch_object).and_return(nil)
70
+ test_client_event(@client, 'riak.get_object') do
71
+ @client.get_object(@bucket, 'bar')
72
+ end
73
+ end
74
+
75
+ it "should notify on the 'store_object' operation" do
76
+ expect(@backend).to receive(:store_object).and_return(nil)
77
+ test_client_event(@client, 'riak.store_object') do
78
+ @client.store_object(Object.new)
79
+ end
80
+ end
81
+
82
+ it "should notify on the 'reload_object' operation" do
83
+ expect(@backend).to receive(:reload_object).and_return(nil)
84
+ test_client_event(@client, 'riak.reload_object') do
85
+ @client.reload_object(Object.new)
86
+ end
87
+ end
88
+
89
+ it "should notify on the 'delete_object' operation" do
90
+ expect(@backend).to receive(:delete_object).and_return(nil)
91
+ test_client_event(@client, 'riak.delete_object') do
92
+ @client.delete_object(@bucket, 'bar')
93
+ end
94
+ end
95
+
96
+ it "should notify on the 'mapred' operation" do
97
+ @mapred = Riak::MapReduce.new(@client).add('test').map("function(){}").map("function(){}")
98
+ expect(@backend).to receive(:mapred).and_return(nil)
99
+ test_client_event(@client, 'riak.map_reduce') do
100
+ @client.mapred(@mapred)
101
+ end
102
+ end
103
+
104
+ it "should notify on the 'ping' operation" do
105
+ expect(@backend).to receive(:ping).and_return(nil)
106
+ test_client_event(@client, 'riak.ping') do
107
+ @client.ping
108
+ end
109
+ end
110
+ end
111
+ end
112
+
113
+ def test_client_event(client, event_name, &block)
114
+ block.call
115
+ expect(@events.size).to eql(1)
116
+ event = @events.first
117
+ expect(event.name).to eql(event_name)
118
+ expect(event.payload[:client_id]).to eql(client.client_id)
119
+ end
120
+
121
+ # name, start, finish, id, payload
122
+ def event(*args)
123
+ ActiveSupport::Notifications::Event.new(*args)
124
+ end
@@ -2,13 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  describe Riak::Link do
4
4
  describe "parsing a link header" do
5
- it "should create Link objects from the data" do
5
+ it "creates Link objects from the data" do
6
6
  result = Riak::Link.parse('</riak/foo/bar>; rel="tag", </riak/foo>; rel="up"')
7
7
  expect(result).to be_kind_of(Array)
8
8
  expect(result).to be_all {|i| Riak::Link === i }
9
9
  end
10
10
 
11
- it "should set the bucket, key, url and rel parameters properly" do
11
+ it "sets the bucket, key, url and rel parameters properly" do
12
12
  result = Riak::Link.parse('</riak/foo/bar>; riaktag="tag", </riak/foo>; rel="up"')
13
13
  expect(result[0].url).to eq("/riak/foo/bar")
14
14
  expect(result[0].bucket).to eq("foo")
@@ -20,14 +20,14 @@ describe Riak::Link do
20
20
  expect(result[1].rel).to eq("up")
21
21
  end
22
22
 
23
- it "should keep the url intact if it does not point to a bucket or bucket/key" do
23
+ it "keeps the url intact if it does not point to a bucket or bucket/key" do
24
24
  result = Riak::Link.parse('</mapred>; rel="riak_kv_wm_mapred"')
25
25
  expect(result[0].url).to eq("/mapred")
26
26
  expect(result[0].bucket).to be_nil
27
27
  expect(result[0].key).to be_nil
28
28
  end
29
29
 
30
- it "should parse the Riak 1.0 URL scheme" do
30
+ it "parses the Riak 1.0 URL scheme" do
31
31
  result = Riak::Link.parse('</buckets/b/keys/k>; riaktag="tag"').first
32
32
  expect(result.bucket).to eq('b')
33
33
  expect(result.key).to eq('k')
@@ -36,24 +36,24 @@ describe Riak::Link do
36
36
  end
37
37
 
38
38
  context "converting to a string" do
39
- it "should convert to a string appropriate for use in the Link header" do
39
+ it "to a string appropriate for use in the Link header" do
40
40
  expect(Riak::Link.new("/riak/foo", "up").to_s).to eq('</riak/foo>; riaktag="up"')
41
41
  expect(Riak::Link.new("/riak/foo/bar", "next").to_s).to eq('</riak/foo/bar>; riaktag="next"')
42
42
  expect(Riak::Link.new("/riak", "riak_kv_wm_raw").to_s).to eq('</riak>; riaktag="riak_kv_wm_raw"')
43
43
  end
44
44
 
45
- it "should convert to a string using the new URL scheme" do
45
+ it "converts to a string using the new URL scheme" do
46
46
  expect(Riak::Link.new("bucket", "key", "tag").to_s(true)).to eq('</buckets/bucket/keys/key>; riaktag="tag"')
47
47
  expect(Riak::Link.parse('</riak/bucket/key>; riaktag="tag"').first.to_s(true)).to eq('</buckets/bucket/keys/key>; riaktag="tag"')
48
48
  end
49
49
  end
50
50
 
51
- it "should convert to a walk spec when pointing to an object" do
51
+ it "converts to a walk spec when pointing to an object" do
52
52
  expect(Riak::Link.new("/riak/foo/bar", "next").to_walk_spec.to_s).to eq("foo,next,_")
53
53
  expect { Riak::Link.new("/riak/foo", "up").to_walk_spec }.to raise_error
54
54
  end
55
55
 
56
- it "should be equivalent to a link with the same url and rel" do
56
+ it "is equivalent to a link with the same url and rel" do
57
57
  one = Riak::Link.new("/riak/foo/bar", "next")
58
58
  two = Riak::Link.new("/riak/foo/bar", "next")
59
59
  expect(one).to eq(two)
@@ -61,21 +61,21 @@ describe Riak::Link do
61
61
  expect([two]).to include(one)
62
62
  end
63
63
 
64
- it "should unescape the bucket name" do
64
+ it "unescapes the bucket name" do
65
65
  expect(Riak::Link.new("/riak/bucket%20spaces/key", "foo").bucket).to eq("bucket spaces")
66
66
  end
67
67
 
68
- it "should unescape the key name" do
68
+ it "unescapes the key name" do
69
69
  expect(Riak::Link.new("/riak/bucket/key%2Fname", "foo").key).to eq("key/name")
70
70
  end
71
71
 
72
- it "should not rely on the prefix to equal /riak/ when extracting the bucket and key" do
72
+ it "doesn't rely on the prefix to equal /riak/ when extracting the bucket and key" do
73
73
  link = Riak::Link.new("/raw/bucket/key", "foo")
74
74
  expect(link.bucket).to eq("bucket")
75
75
  expect(link.key).to eq("key")
76
76
  end
77
77
 
78
- it "should construct from bucket, key and tag" do
78
+ it "constructs from bucket, key and tag" do
79
79
  link = Riak::Link.new("bucket", "key", "tag")
80
80
  expect(link.bucket).to eq("bucket")
81
81
  expect(link.key).to eq("key")
@@ -13,7 +13,7 @@ describe Riak::ListBuckets do
13
13
  end
14
14
 
15
15
  describe "non-streaming" do
16
- it 'should call the backend without a block' do
16
+ it 'calls the backend without a block' do
17
17
  @expect_list.with({}).and_return(%w{a b c d})
18
18
 
19
19
  @client.list_buckets
@@ -21,7 +21,7 @@ describe Riak::ListBuckets do
21
21
  end
22
22
 
23
23
  describe "streaming" do
24
- it 'should call the backend with a block' do
24
+ it 'calls the backend with a block' do
25
25
  @expect_list.
26
26
  and_yield(%w{abc abd abe}).
27
27
  and_yield(%w{bbb ccc ddd})
@@ -2,19 +2,19 @@ require 'spec_helper'
2
2
 
3
3
  describe Riak::MapReduce::FilterBuilder do
4
4
  subject { Riak::MapReduce::FilterBuilder.new }
5
- it "should evaluate the passed block on initialization" do
5
+ it "evaluates the passed block on initialization" do
6
6
  expect(subject.class.new do
7
7
  matches "foo"
8
8
  end.to_a).to eq([[:matches, "foo"]])
9
9
  end
10
10
 
11
- it "should add filters to the list" do
11
+ it "adds filters to the list" do
12
12
  subject.to_lower
13
13
  subject.similar_to("ripple", 3)
14
14
  expect(subject.to_a).to eq([[:to_lower],[:similar_to, "ripple", 3]])
15
15
  end
16
16
 
17
- it "should add a logical operation with a block" do
17
+ it "adds a logical operation with a block" do
18
18
  subject.OR do
19
19
  starts_with "foo"
20
20
  ends_with "bar"
@@ -22,11 +22,11 @@ describe Riak::MapReduce::FilterBuilder do
22
22
  expect(subject.to_a).to eq([[:or, [[:starts_with, "foo"],[:ends_with, "bar"]]]])
23
23
  end
24
24
 
25
- it "should raise an error on a filter arity mismatch" do
25
+ it "raises an error on a filter arity mismatch" do
26
26
  expect { subject.less_than }.to raise_error(ArgumentError)
27
27
  end
28
28
 
29
- it "should raise an error when a block is not given to a logical operation" do
29
+ it "raises an error when a block is not given to a logical operation" do
30
30
  expect { subject._or }.to raise_error(ArgumentError)
31
31
  end
32
32
  end
@@ -6,53 +6,53 @@ describe Riak::MapReduce::Phase do
6
6
  @erl_fun = "fun(Obj, _KeyData, _Arg) -> [{riak_object:key(Obj), riak_object:get_value(Obj)}] end."
7
7
  end
8
8
 
9
- it "should initialize with a type and a function" do
9
+ it "initializes with a type and a function" do
10
10
  phase = Riak::MapReduce::Phase.new(:type => :map, :function => @js_fun, :language => "javascript")
11
11
  expect(phase.type).to eq(:map)
12
12
  expect(phase.function).to eq(@js_fun)
13
13
  expect(phase.language).to eq("javascript")
14
14
  end
15
15
 
16
- it "should initialize with a type and an MF" do
16
+ it "initializes with a type and an MF" do
17
17
  phase = Riak::MapReduce::Phase.new(:type => :map, :function => ["module", "function"], :language => "erlang")
18
18
  expect(phase.type).to eq(:map)
19
19
  expect(phase.function).to eq(["module", "function"])
20
20
  expect(phase.language).to eq("erlang")
21
21
  end
22
22
 
23
- it "should initialize with a type and a bucket/key" do
23
+ it "initializes with a type and a bucket/key" do
24
24
  phase = Riak::MapReduce::Phase.new(:type => :map, :function => {:bucket => "funs", :key => "awesome_map"}, :language => "javascript")
25
25
  expect(phase.type).to eq(:map)
26
26
  expect(phase.function).to eq({:bucket => "funs", :key => "awesome_map"})
27
27
  expect(phase.language).to eq("javascript")
28
28
  end
29
29
 
30
- it "should assume the language is erlang when the function is an array" do
30
+ it "assumes the language is erlang when the function is an array" do
31
31
  phase = Riak::MapReduce::Phase.new(:type => :map, :function => ["module", "function"])
32
32
  expect(phase.language).to eq("erlang")
33
33
  end
34
34
 
35
- it "should assume the language is javascript when the function is a string and starts with function" do
35
+ it "assumes the language is javascript when the function is a string and starts with function" do
36
36
  phase = Riak::MapReduce::Phase.new(:type => :map, :function => @js_fun)
37
37
  expect(phase.language).to eq("javascript")
38
38
  end
39
39
 
40
- it "should assume the language is erlang when the function is a string and starts with anon fun" do
40
+ it "assumes the language is erlang when the function is a string and starts with anon fun" do
41
41
  phase = Riak::MapReduce::Phase.new(:type => :map, :function => @erl_fun)
42
42
  expect(phase.language).to eq("erlang")
43
43
  end
44
44
 
45
- it "should assume the language is javascript when the function is a hash" do
45
+ it "assumes the language is javascript when the function is a hash" do
46
46
  phase = Riak::MapReduce::Phase.new(:type => :map, :function => {:bucket => "jobs", :key => "awesome_map"})
47
47
  expect(phase.language).to eq("javascript")
48
48
  end
49
49
 
50
- it "should accept a WalkSpec for the function when a link phase" do
50
+ it "accepts a WalkSpec for the function when a link phase" do
51
51
  phase = Riak::MapReduce::Phase.new(:type => :link, :function => Riak::WalkSpec.new({}))
52
52
  expect(phase.function).to be_kind_of(Riak::WalkSpec)
53
53
  end
54
54
 
55
- it "should raise an error if a WalkSpec is given for a phase type other than :link" do
55
+ it "raises an error if a WalkSpec is given for a phase type other than :link" do
56
56
  expect { Riak::MapReduce::Phase.new(:type => :map, :function => Riak::WalkSpec.new({})) }.to raise_error(ArgumentError)
57
57
  end
58
58
 
@@ -67,39 +67,39 @@ describe Riak::MapReduce::Phase do
67
67
  @phase.type = type
68
68
  end
69
69
 
70
- it "should be an object with a single key of '#{type}'" do
70
+ it "is an object with a single key of '#{type}'" do
71
71
  expect(@phase.to_json).to match(/^\{"#{type}":/)
72
72
  end
73
73
 
74
- it "should include the language" do
74
+ it "includes the language" do
75
75
  expect(@phase.to_json).to match(/"language":/)
76
76
  end
77
77
 
78
- it "should include the keep value" do
78
+ it "includes the keep value" do
79
79
  expect(@phase.to_json).to match(/"keep":false/)
80
80
  @phase.keep = true
81
81
  expect(@phase.to_json).to match(/"keep":true/)
82
82
  end
83
83
 
84
- it "should include the function source when the function is a source string" do
84
+ it "includes the function source when the function is a source string" do
85
85
  @phase.function = "function(v,_,_){ return v; }"
86
86
  expect(@phase.to_json).to include(@phase.function)
87
87
  expect(@phase.to_json).to match(/"source":/)
88
88
  end
89
89
 
90
- it "should include the function name when the function is not a lambda" do
90
+ it "includes the function name when the function is not a lambda" do
91
91
  @phase.function = "Riak.mapValues"
92
92
  expect(@phase.to_json).to include('"name":"Riak.mapValues"')
93
93
  expect(@phase.to_json).not_to include('"source"')
94
94
  end
95
95
 
96
- it "should include the bucket and key when referring to a stored function" do
96
+ it "includes the bucket and key when referring to a stored function" do
97
97
  @phase.function = {:bucket => "design", :key => "wordcount_map"}
98
98
  expect(@phase.to_json).to include('"bucket":"design"')
99
99
  expect(@phase.to_json).to include('"key":"wordcount_map"')
100
100
  end
101
101
 
102
- it "should include the module and function when invoking an Erlang function" do
102
+ it "includes the module and function when invoking an Erlang function" do
103
103
  @phase.function = ["riak_mapreduce", "mapreduce_fun"]
104
104
  expect(@phase.to_json).to include('"module":"riak_mapreduce"')
105
105
  expect(@phase.to_json).to include('"function":"mapreduce_fun"')
@@ -113,23 +113,23 @@ describe Riak::MapReduce::Phase do
113
113
  @phase.function = {}
114
114
  end
115
115
 
116
- it "should be an object of a single key 'link'" do
116
+ it "is an object of a single key 'link'" do
117
117
  expect(@phase.to_json).to match(/^\{"link":/)
118
118
  end
119
119
 
120
- it "should include the bucket" do
120
+ it "includes the bucket" do
121
121
  expect(@phase.to_json).to match(/"bucket":"_"/)
122
122
  @phase.function[:bucket] = "foo"
123
123
  expect(@phase.to_json).to match(/"bucket":"foo"/)
124
124
  end
125
125
 
126
- it "should include the tag" do
126
+ it "includes the tag" do
127
127
  expect(@phase.to_json).to match(/"tag":"_"/)
128
128
  @phase.function[:tag] = "parent"
129
129
  expect(@phase.to_json).to match(/"tag":"parent"/)
130
130
  end
131
131
 
132
- it "should include the keep value" do
132
+ it "includes the keep value" do
133
133
  expect(@phase.to_json).to match(/"keep":false/)
134
134
  @phase.keep = true
135
135
  expect(@phase.to_json).to match(/"keep":true/)