riak-client 1.4.5 → 2.0.0.rc1

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 (180) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Gemfile +0 -1
  4. data/{LICENSE → LICENSE.md} +0 -0
  5. data/README.markdown +211 -66
  6. data/RELEASE_NOTES.md +22 -47
  7. data/Rakefile +45 -0
  8. data/lib/riak.rb +1 -1
  9. data/lib/riak/bucket.rb +2 -2
  10. data/lib/riak/client.rb +22 -195
  11. data/lib/riak/client/beefcake/crdt_loader.rb +127 -0
  12. data/lib/riak/client/beefcake/crdt_operator.rb +222 -0
  13. data/lib/riak/client/beefcake/footer +4 -0
  14. data/lib/riak/client/beefcake/header +6 -0
  15. data/lib/riak/client/beefcake/message_codes.rb +29 -0
  16. data/lib/riak/client/beefcake/message_overlay.rb +61 -0
  17. data/lib/riak/client/beefcake/messages.rb +733 -371
  18. data/lib/riak/client/beefcake/object_methods.rb +1 -1
  19. data/lib/riak/client/beefcake/protocol.rb +105 -0
  20. data/lib/riak/client/beefcake/socket.rb +243 -0
  21. data/lib/riak/client/beefcake_protobuffs_backend.rb +262 -122
  22. data/lib/riak/client/node.rb +4 -75
  23. data/lib/riak/client/protobuffs_backend.rb +6 -14
  24. data/lib/riak/client/search.rb +0 -64
  25. data/lib/riak/client/yokozuna.rb +52 -0
  26. data/lib/riak/counter.rb +1 -1
  27. data/lib/riak/crdt.rb +21 -0
  28. data/lib/riak/crdt/base.rb +97 -0
  29. data/lib/riak/crdt/batch_counter.rb +19 -0
  30. data/lib/riak/crdt/batch_map.rb +41 -0
  31. data/lib/riak/crdt/counter.rb +71 -0
  32. data/lib/riak/crdt/inner_counter.rb +74 -0
  33. data/lib/riak/crdt/inner_flag.rb +42 -0
  34. data/lib/riak/crdt/inner_map.rb +53 -0
  35. data/lib/riak/crdt/inner_register.rb +26 -0
  36. data/lib/riak/crdt/inner_set.rb +95 -0
  37. data/lib/riak/crdt/map.rb +88 -0
  38. data/lib/riak/crdt/operation.rb +19 -0
  39. data/lib/riak/crdt/set.rb +156 -0
  40. data/lib/riak/crdt/typed_collection.rb +131 -0
  41. data/lib/riak/errors/base.rb +9 -0
  42. data/lib/riak/errors/connection_error.rb +44 -0
  43. data/lib/riak/errors/crdt_error.rb +18 -0
  44. data/lib/riak/errors/failed_request.rb +56 -0
  45. data/lib/riak/errors/protobuffs_error.rb +11 -0
  46. data/lib/riak/i18n.rb +2 -0
  47. data/lib/riak/json.rb +1 -1
  48. data/lib/riak/locale/en.yml +26 -1
  49. data/lib/riak/locale/fr.yml +0 -1
  50. data/lib/riak/map_reduce.rb +1 -1
  51. data/lib/riak/map_reduce/results.rb +1 -1
  52. data/lib/riak/multiget.rb +1 -2
  53. data/lib/riak/rcontent.rb +8 -3
  54. data/lib/riak/robject.rb +2 -8
  55. data/lib/riak/secondary_index.rb +4 -4
  56. data/lib/riak/serializers.rb +1 -1
  57. data/lib/riak/util/escape.rb +3 -5
  58. data/lib/riak/version.rb +1 -1
  59. data/lib/riak/walk_spec.rb +7 -3
  60. data/riak-client.gemspec +10 -8
  61. data/spec/fixtures/bitcask.txt +25 -0
  62. data/spec/integration/riak/bucket_types_spec.rb +61 -0
  63. data/spec/integration/riak/counters_spec.rb +17 -32
  64. data/spec/integration/riak/crdt_spec.rb +181 -0
  65. data/spec/integration/riak/crdt_validation/map_spec.rb +63 -0
  66. data/spec/integration/riak/crdt_validation/set_spec.rb +122 -0
  67. data/spec/integration/riak/protobuffs_backends_spec.rb +9 -26
  68. data/spec/integration/riak/security_spec.rb +94 -0
  69. data/spec/integration/riak/threading_spec.rb +24 -67
  70. data/spec/integration/yokozuna/index_spec.rb +61 -0
  71. data/spec/integration/yokozuna/queries_spec.rb +116 -0
  72. data/spec/integration/yokozuna/schema_spec.rb +49 -0
  73. data/spec/riak/beefcake_protobuffs_backend/crdt_operator_spec.rb +222 -0
  74. data/spec/riak/beefcake_protobuffs_backend/object_methods_spec.rb +4 -4
  75. data/spec/riak/beefcake_protobuffs_backend/protocol_spec.rb +189 -0
  76. data/spec/riak/beefcake_protobuffs_backend/socket_spec.rb +151 -0
  77. data/spec/riak/beefcake_protobuffs_backend_spec.rb +68 -106
  78. data/spec/riak/bucket_spec.rb +81 -77
  79. data/spec/riak/client_spec.rb +43 -340
  80. data/spec/riak/core_ext/to_param_spec.rb +2 -2
  81. data/spec/riak/counter_spec.rb +20 -20
  82. data/spec/riak/crdt/counter_spec.rb +52 -0
  83. data/spec/riak/crdt/inner_counter_spec.rb +21 -0
  84. data/spec/riak/crdt/inner_flag_spec.rb +39 -0
  85. data/spec/riak/crdt/inner_map_spec.rb +47 -0
  86. data/spec/riak/crdt/inner_register_spec.rb +40 -0
  87. data/spec/riak/crdt/inner_set_spec.rb +33 -0
  88. data/spec/riak/crdt/map_spec.rb +77 -0
  89. data/spec/riak/crdt/set_spec.rb +58 -0
  90. data/spec/riak/crdt/shared_examples.rb +74 -0
  91. data/spec/riak/crdt/typed_collection_spec.rb +231 -0
  92. data/spec/riak/escape_spec.rb +33 -37
  93. data/spec/riak/feature_detection_spec.rb +45 -45
  94. data/spec/riak/index_collection_spec.rb +12 -12
  95. data/spec/riak/link_spec.rb +34 -34
  96. data/spec/riak/list_buckets_spec.rb +7 -7
  97. data/spec/riak/map_reduce/filter_builder_spec.rb +6 -6
  98. data/spec/riak/map_reduce/phase_spec.rb +35 -35
  99. data/spec/riak/map_reduce_spec.rb +89 -87
  100. data/spec/riak/multiget_spec.rb +20 -15
  101. data/spec/riak/node_spec.rb +5 -152
  102. data/spec/riak/robject_spec.rb +95 -108
  103. data/spec/riak/search_spec.rb +17 -139
  104. data/spec/riak/secondary_index_spec.rb +49 -49
  105. data/spec/riak/serializers_spec.rb +9 -9
  106. data/spec/riak/stamp_spec.rb +9 -9
  107. data/spec/riak/walk_spec_spec.rb +46 -46
  108. data/spec/spec_helper.rb +14 -22
  109. data/spec/support/certs/README.md +13 -0
  110. data/spec/support/certs/ca.crt +22 -0
  111. data/spec/support/certs/client.crt +95 -0
  112. data/spec/support/certs/client.key +27 -0
  113. data/spec/support/certs/empty_ca.crt +21 -0
  114. data/spec/support/certs/server.crl +13 -0
  115. data/spec/support/certs/server.crt +95 -0
  116. data/spec/support/certs/server.key +27 -0
  117. data/spec/support/integration_setup.rb +1 -1
  118. data/spec/support/search_corpus_setup.rb +29 -8
  119. data/spec/support/test_client.rb +46 -0
  120. data/spec/support/test_client.yml.example +10 -0
  121. data/spec/support/unified_backend_examples.rb +104 -83
  122. data/spec/support/version_filter.rb +2 -2
  123. data/spec/support/wait_until.rb +14 -0
  124. metadata +134 -132
  125. data/erl_src/riak_kv_test014_backend.beam +0 -0
  126. data/erl_src/riak_kv_test014_backend.erl +0 -189
  127. data/erl_src/riak_kv_test_backend.beam +0 -0
  128. data/erl_src/riak_kv_test_backend.erl +0 -731
  129. data/erl_src/riak_search_test_backend.beam +0 -0
  130. data/erl_src/riak_search_test_backend.erl +0 -175
  131. data/lib/riak/client/excon_backend.rb +0 -172
  132. data/lib/riak/client/http_backend.rb +0 -413
  133. data/lib/riak/client/http_backend/bucket_streamer.rb +0 -15
  134. data/lib/riak/client/http_backend/chunked_json_streamer.rb +0 -42
  135. data/lib/riak/client/http_backend/configuration.rb +0 -227
  136. data/lib/riak/client/http_backend/key_streamer.rb +0 -15
  137. data/lib/riak/client/http_backend/object_methods.rb +0 -114
  138. data/lib/riak/client/http_backend/request_headers.rb +0 -34
  139. data/lib/riak/client/http_backend/transport_methods.rb +0 -201
  140. data/lib/riak/client/instrumentation.rb +0 -25
  141. data/lib/riak/client/net_http_backend.rb +0 -82
  142. data/lib/riak/cluster.rb +0 -151
  143. data/lib/riak/failed_request.rb +0 -81
  144. data/lib/riak/instrumentation.rb +0 -6
  145. data/lib/riak/node.rb +0 -40
  146. data/lib/riak/node/configuration.rb +0 -304
  147. data/lib/riak/node/console.rb +0 -133
  148. data/lib/riak/node/control.rb +0 -207
  149. data/lib/riak/node/defaults.rb +0 -85
  150. data/lib/riak/node/generation.rb +0 -127
  151. data/lib/riak/node/log.rb +0 -34
  152. data/lib/riak/node/version.rb +0 -29
  153. data/lib/riak/search.rb +0 -3
  154. data/lib/riak/test_server.rb +0 -89
  155. data/lib/riak/util/headers.rb +0 -32
  156. data/lib/riak/util/multipart.rb +0 -52
  157. data/lib/riak/util/multipart/stream_parser.rb +0 -62
  158. data/spec/fixtures/munchausen.txt +0 -1033
  159. data/spec/integration/riak/cluster_spec.rb +0 -88
  160. data/spec/integration/riak/http_backends_spec.rb +0 -180
  161. data/spec/integration/riak/node_spec.rb +0 -170
  162. data/spec/integration/riak/test_server_spec.rb +0 -57
  163. data/spec/riak/excon_backend_spec.rb +0 -102
  164. data/spec/riak/headers_spec.rb +0 -21
  165. data/spec/riak/http_backend/configuration_spec.rb +0 -273
  166. data/spec/riak/http_backend/object_methods_spec.rb +0 -243
  167. data/spec/riak/http_backend/transport_methods_spec.rb +0 -97
  168. data/spec/riak/http_backend_spec.rb +0 -367
  169. data/spec/riak/instrumentation_spec.rb +0 -167
  170. data/spec/riak/multipart_spec.rb +0 -23
  171. data/spec/riak/net_http_backend_spec.rb +0 -15
  172. data/spec/riak/stream_parser_spec.rb +0 -53
  173. data/spec/support/drb_mock_server.rb +0 -39
  174. data/spec/support/http_backend_implementation_examples.rb +0 -253
  175. data/spec/support/mock_server.rb +0 -81
  176. data/spec/support/mocks.rb +0 -4
  177. data/spec/support/riak_test.rb +0 -77
  178. data/spec/support/sometimes.rb +0 -46
  179. data/spec/support/test_server.rb +0 -61
  180. data/spec/support/test_server.yml.example +0 -14
@@ -6,17 +6,17 @@ describe Riak::IndexCollection do
6
6
  @input = {
7
7
  'keys' => %w{first second third}
8
8
  }.to_json
9
- lambda { @coll = Riak::IndexCollection.new_from_json @input }.should_not raise_error
10
- %w{first second third}.should == @coll
9
+ expect { @coll = Riak::IndexCollection.new_from_json @input }.not_to raise_error
10
+ expect(%w{first second third}).to eq(@coll)
11
11
  end
12
12
  it "should accept a list of keys and a continuation" do
13
13
  @input = {
14
14
  'keys' => %w{first second third},
15
15
  'continuation' => 'examplecontinuation'
16
16
  }.to_json
17
- lambda { @coll = Riak::IndexCollection.new_from_json @input }.should_not raise_error
18
- %w{first second third}.should == @coll
19
- @coll.continuation.should == 'examplecontinuation'
17
+ expect { @coll = Riak::IndexCollection.new_from_json @input }.not_to raise_error
18
+ expect(%w{first second third}).to eq(@coll)
19
+ expect(@coll.continuation).to eq('examplecontinuation')
20
20
  end
21
21
  it "should accept a list of results hashes" do
22
22
  @input = {
@@ -27,9 +27,9 @@ describe Riak::IndexCollection do
27
27
  ]
28
28
  }.to_json
29
29
 
30
- lambda { @coll = Riak::IndexCollection.new_from_json @input }.should_not raise_error
31
- %w{first second other}.should == @coll
32
- {'first' => %w{first}, 'second' => %w{second other}}.should == @coll.with_terms
30
+ expect { @coll = Riak::IndexCollection.new_from_json @input }.not_to raise_error
31
+ expect(%w{first second other}).to eq(@coll)
32
+ expect({'first' => %w{first}, 'second' => %w{second other}}).to eq(@coll.with_terms)
33
33
  end
34
34
  it "should accept a list of results hashes and a continuation" do
35
35
  @input = {
@@ -41,10 +41,10 @@ describe Riak::IndexCollection do
41
41
  'continuation' => 'examplecontinuation'
42
42
  }.to_json
43
43
 
44
- lambda { @coll = Riak::IndexCollection.new_from_json @input }.should_not raise_error
45
- %w{first second other}.should == @coll
46
- @coll.continuation.should == 'examplecontinuation'
47
- {'first' => %w{first}, 'second' => %w{second other}}.should == @coll.with_terms
44
+ expect { @coll = Riak::IndexCollection.new_from_json @input }.not_to raise_error
45
+ expect(%w{first second other}).to eq(@coll)
46
+ expect(@coll.continuation).to eq('examplecontinuation')
47
+ expect({'first' => %w{first}, 'second' => %w{second other}}).to eq(@coll.with_terms)
48
48
  end
49
49
  end
50
50
  end
@@ -4,82 +4,82 @@ describe Riak::Link do
4
4
  describe "parsing a link header" do
5
5
  it "should create Link objects from the data" do
6
6
  result = Riak::Link.parse('</riak/foo/bar>; rel="tag", </riak/foo>; rel="up"')
7
- result.should be_kind_of(Array)
8
- result.should be_all {|i| Riak::Link === i }
7
+ expect(result).to be_kind_of(Array)
8
+ expect(result).to be_all {|i| Riak::Link === i }
9
9
  end
10
10
 
11
11
  it "should set 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
- result[0].url.should == "/riak/foo/bar"
14
- result[0].bucket.should == "foo"
15
- result[0].key.should == "bar"
16
- result[0].rel.should == "tag"
17
- result[1].url.should == "/riak/foo"
18
- result[1].bucket.should == "foo"
19
- result[1].key.should == nil
20
- result[1].rel.should == "up"
13
+ expect(result[0].url).to eq("/riak/foo/bar")
14
+ expect(result[0].bucket).to eq("foo")
15
+ expect(result[0].key).to eq("bar")
16
+ expect(result[0].rel).to eq("tag")
17
+ expect(result[1].url).to eq("/riak/foo")
18
+ expect(result[1].bucket).to eq("foo")
19
+ expect(result[1].key).to eq(nil)
20
+ expect(result[1].rel).to eq("up")
21
21
  end
22
22
 
23
23
  it "should keep 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
- result[0].url.should == "/mapred"
26
- result[0].bucket.should be_nil
27
- result[0].key.should be_nil
25
+ expect(result[0].url).to eq("/mapred")
26
+ expect(result[0].bucket).to be_nil
27
+ expect(result[0].key).to be_nil
28
28
  end
29
29
 
30
30
  it "should parse the Riak 1.0 URL scheme" do
31
31
  result = Riak::Link.parse('</buckets/b/keys/k>; riaktag="tag"').first
32
- result.bucket.should == 'b'
33
- result.key.should == 'k'
34
- result.tag.should == 'tag'
32
+ expect(result.bucket).to eq('b')
33
+ expect(result.key).to eq('k')
34
+ expect(result.tag).to eq('tag')
35
35
  end
36
36
  end
37
37
 
38
38
  context "converting to a string" do
39
39
  it "should convert to a string appropriate for use in the Link header" do
40
- Riak::Link.new("/riak/foo", "up").to_s.should == '</riak/foo>; riaktag="up"'
41
- Riak::Link.new("/riak/foo/bar", "next").to_s.should == '</riak/foo/bar>; riaktag="next"'
42
- Riak::Link.new("/riak", "riak_kv_wm_raw").to_s.should == '</riak>; riaktag="riak_kv_wm_raw"'
40
+ expect(Riak::Link.new("/riak/foo", "up").to_s).to eq('</riak/foo>; riaktag="up"')
41
+ expect(Riak::Link.new("/riak/foo/bar", "next").to_s).to eq('</riak/foo/bar>; riaktag="next"')
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
45
  it "should convert to a string using the new URL scheme" do
46
- Riak::Link.new("bucket", "key", "tag").to_s(true).should == '</buckets/bucket/keys/key>; riaktag="tag"'
47
- Riak::Link.parse('</riak/bucket/key>; riaktag="tag"').first.to_s(true).should == '</buckets/bucket/keys/key>; riaktag="tag"'
46
+ expect(Riak::Link.new("bucket", "key", "tag").to_s(true)).to eq('</buckets/bucket/keys/key>; riaktag="tag"')
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
51
  it "should convert to a walk spec when pointing to an object" do
52
- Riak::Link.new("/riak/foo/bar", "next").to_walk_spec.to_s.should == "foo,next,_"
53
- lambda { Riak::Link.new("/riak/foo", "up").to_walk_spec }.should raise_error
52
+ expect(Riak::Link.new("/riak/foo/bar", "next").to_walk_spec.to_s).to eq("foo,next,_")
53
+ expect { Riak::Link.new("/riak/foo", "up").to_walk_spec }.to raise_error
54
54
  end
55
55
 
56
56
  it "should be 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
- one.should == two
60
- [one].should include(two)
61
- [two].should include(one)
59
+ expect(one).to eq(two)
60
+ expect([one]).to include(two)
61
+ expect([two]).to include(one)
62
62
  end
63
63
 
64
64
  it "should unescape the bucket name" do
65
- Riak::Link.new("/riak/bucket%20spaces/key", "foo").bucket.should == "bucket spaces"
65
+ expect(Riak::Link.new("/riak/bucket%20spaces/key", "foo").bucket).to eq("bucket spaces")
66
66
  end
67
67
 
68
68
  it "should unescape the key name" do
69
- Riak::Link.new("/riak/bucket/key%2Fname", "foo").key.should == "key/name"
69
+ expect(Riak::Link.new("/riak/bucket/key%2Fname", "foo").key).to eq("key/name")
70
70
  end
71
71
 
72
72
  it "should not 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
- link.bucket.should == "bucket"
75
- link.key.should == "key"
74
+ expect(link.bucket).to eq("bucket")
75
+ expect(link.key).to eq("key")
76
76
  end
77
77
 
78
78
  it "should construct from bucket, key and tag" do
79
79
  link = Riak::Link.new("bucket", "key", "tag")
80
- link.bucket.should == "bucket"
81
- link.key.should == "key"
82
- link.tag.should == "tag"
83
- link.url.should == "/riak/bucket/key"
80
+ expect(link.bucket).to eq("bucket")
81
+ expect(link.key).to eq("key")
82
+ expect(link.tag).to eq("tag")
83
+ expect(link.url).to eq("/riak/bucket/key")
84
84
  end
85
85
  end
@@ -2,12 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  describe Riak::ListBuckets do
4
4
  before :each do
5
- @client = Riak::Client.new protocol: 'pbc'
6
- @backend = mock 'backend'
7
- @fake_pool = mock 'connection pool'
8
- @fake_pool.stub(:take).and_yield(@backend)
5
+ @client = Riak::Client.new
6
+ @backend = double 'backend'
7
+ @fake_pool = double 'connection pool'
8
+ allow(@fake_pool).to receive(:take).and_yield(@backend)
9
9
 
10
- @expect_list = @backend.should_receive(:list_buckets)
10
+ @expect_list = expect(@backend).to receive(:list_buckets)
11
11
 
12
12
  @client.instance_variable_set :@protobuffs_pool, @fake_pool
13
13
  end
@@ -33,9 +33,9 @@ describe Riak::ListBuckets do
33
33
  end
34
34
 
35
35
  @yielded.each do |b|
36
- b.should be_a Riak::Bucket
36
+ expect(b).to be_a Riak::Bucket
37
37
  end
38
- @yielded.map(&:name).should == %w{abc abd abe bbb ccc ddd}
38
+ expect(@yielded.map(&:name)).to eq(%w{abc abd abe bbb ccc ddd})
39
39
  end
40
40
  end
41
41
  end
@@ -3,15 +3,15 @@ require 'spec_helper'
3
3
  describe Riak::MapReduce::FilterBuilder do
4
4
  subject { Riak::MapReduce::FilterBuilder.new }
5
5
  it "should evaluate the passed block on initialization" do
6
- subject.class.new do
6
+ expect(subject.class.new do
7
7
  matches "foo"
8
- end.to_a.should == [[:matches, "foo"]]
8
+ end.to_a).to eq([[:matches, "foo"]])
9
9
  end
10
10
 
11
11
  it "should add filters to the list" do
12
12
  subject.to_lower
13
13
  subject.similar_to("ripple", 3)
14
- subject.to_a.should == [[:to_lower],[:similar_to, "ripple", 3]]
14
+ expect(subject.to_a).to eq([[:to_lower],[:similar_to, "ripple", 3]])
15
15
  end
16
16
 
17
17
  it "should add a logical operation with a block" do
@@ -19,14 +19,14 @@ describe Riak::MapReduce::FilterBuilder do
19
19
  starts_with "foo"
20
20
  ends_with "bar"
21
21
  end
22
- subject.to_a.should == [[:or, [[:starts_with, "foo"],[:ends_with, "bar"]]]]
22
+ expect(subject.to_a).to eq([[:or, [[:starts_with, "foo"],[:ends_with, "bar"]]]])
23
23
  end
24
24
 
25
25
  it "should raise an error on a filter arity mismatch" do
26
- lambda { subject.less_than }.should raise_error(ArgumentError)
26
+ expect { subject.less_than }.to raise_error(ArgumentError)
27
27
  end
28
28
 
29
29
  it "should raise an error when a block is not given to a logical operation" do
30
- lambda { subject._or }.should raise_error(ArgumentError)
30
+ expect { subject._or }.to raise_error(ArgumentError)
31
31
  end
32
32
  end
@@ -8,52 +8,52 @@ describe Riak::MapReduce::Phase do
8
8
 
9
9
  it "should initialize with a type and a function" do
10
10
  phase = Riak::MapReduce::Phase.new(:type => :map, :function => @js_fun, :language => "javascript")
11
- phase.type.should == :map
12
- phase.function.should == @js_fun
13
- phase.language.should == "javascript"
11
+ expect(phase.type).to eq(:map)
12
+ expect(phase.function).to eq(@js_fun)
13
+ expect(phase.language).to eq("javascript")
14
14
  end
15
15
 
16
16
  it "should initialize with a type and an MF" do
17
17
  phase = Riak::MapReduce::Phase.new(:type => :map, :function => ["module", "function"], :language => "erlang")
18
- phase.type.should == :map
19
- phase.function.should == ["module", "function"]
20
- phase.language.should == "erlang"
18
+ expect(phase.type).to eq(:map)
19
+ expect(phase.function).to eq(["module", "function"])
20
+ expect(phase.language).to eq("erlang")
21
21
  end
22
22
 
23
23
  it "should initialize 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
- phase.type.should == :map
26
- phase.function.should == {:bucket => "funs", :key => "awesome_map"}
27
- phase.language.should == "javascript"
25
+ expect(phase.type).to eq(:map)
26
+ expect(phase.function).to eq({:bucket => "funs", :key => "awesome_map"})
27
+ expect(phase.language).to eq("javascript")
28
28
  end
29
29
 
30
30
  it "should assume the language is erlang when the function is an array" do
31
31
  phase = Riak::MapReduce::Phase.new(:type => :map, :function => ["module", "function"])
32
- phase.language.should == "erlang"
32
+ expect(phase.language).to eq("erlang")
33
33
  end
34
34
 
35
35
  it "should assume 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
- phase.language.should == "javascript"
37
+ expect(phase.language).to eq("javascript")
38
38
  end
39
39
 
40
40
  it "should assume 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
- phase.language.should == "erlang"
42
+ expect(phase.language).to eq("erlang")
43
43
  end
44
44
 
45
45
  it "should assume 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
- phase.language.should == "javascript"
47
+ expect(phase.language).to eq("javascript")
48
48
  end
49
49
 
50
50
  it "should accept a WalkSpec for the function when a link phase" do
51
51
  phase = Riak::MapReduce::Phase.new(:type => :link, :function => Riak::WalkSpec.new({}))
52
- phase.function.should be_kind_of(Riak::WalkSpec)
52
+ expect(phase.function).to be_kind_of(Riak::WalkSpec)
53
53
  end
54
54
 
55
55
  it "should raise an error if a WalkSpec is given for a phase type other than :link" do
56
- lambda { Riak::MapReduce::Phase.new(:type => :map, :function => Riak::WalkSpec.new({})) }.should raise_error(ArgumentError)
56
+ expect { Riak::MapReduce::Phase.new(:type => :map, :function => Riak::WalkSpec.new({})) }.to raise_error(ArgumentError)
57
57
  end
58
58
 
59
59
  describe "converting to JSON for the job" do
@@ -68,41 +68,41 @@ describe Riak::MapReduce::Phase do
68
68
  end
69
69
 
70
70
  it "should be an object with a single key of '#{type}'" do
71
- @phase.to_json.should =~ /^\{"#{type}":/
71
+ expect(@phase.to_json).to match(/^\{"#{type}":/)
72
72
  end
73
73
 
74
74
  it "should include the language" do
75
- @phase.to_json.should =~ /"language":/
75
+ expect(@phase.to_json).to match(/"language":/)
76
76
  end
77
77
 
78
78
  it "should include the keep value" do
79
- @phase.to_json.should =~ /"keep":false/
79
+ expect(@phase.to_json).to match(/"keep":false/)
80
80
  @phase.keep = true
81
- @phase.to_json.should =~ /"keep":true/
81
+ expect(@phase.to_json).to match(/"keep":true/)
82
82
  end
83
83
 
84
84
  it "should include the function source when the function is a source string" do
85
85
  @phase.function = "function(v,_,_){ return v; }"
86
- @phase.to_json.should include(@phase.function)
87
- @phase.to_json.should =~ /"source":/
86
+ expect(@phase.to_json).to include(@phase.function)
87
+ expect(@phase.to_json).to match(/"source":/)
88
88
  end
89
89
 
90
90
  it "should include the function name when the function is not a lambda" do
91
91
  @phase.function = "Riak.mapValues"
92
- @phase.to_json.should include('"name":"Riak.mapValues"')
93
- @phase.to_json.should_not include('"source"')
92
+ expect(@phase.to_json).to include('"name":"Riak.mapValues"')
93
+ expect(@phase.to_json).not_to include('"source"')
94
94
  end
95
95
 
96
96
  it "should include the bucket and key when referring to a stored function" do
97
97
  @phase.function = {:bucket => "design", :key => "wordcount_map"}
98
- @phase.to_json.should include('"bucket":"design"')
99
- @phase.to_json.should include('"key":"wordcount_map"')
98
+ expect(@phase.to_json).to include('"bucket":"design"')
99
+ expect(@phase.to_json).to include('"key":"wordcount_map"')
100
100
  end
101
101
 
102
102
  it "should include the module and function when invoking an Erlang function" do
103
103
  @phase.function = ["riak_mapreduce", "mapreduce_fun"]
104
- @phase.to_json.should include('"module":"riak_mapreduce"')
105
- @phase.to_json.should include('"function":"mapreduce_fun"')
104
+ expect(@phase.to_json).to include('"module":"riak_mapreduce"')
105
+ expect(@phase.to_json).to include('"function":"mapreduce_fun"')
106
106
  end
107
107
  end
108
108
  end
@@ -114,28 +114,28 @@ describe Riak::MapReduce::Phase do
114
114
  end
115
115
 
116
116
  it "should be an object of a single key 'link'" do
117
- @phase.to_json.should =~ /^\{"link":/
117
+ expect(@phase.to_json).to match(/^\{"link":/)
118
118
  end
119
119
 
120
120
  it "should include the bucket" do
121
- @phase.to_json.should =~ /"bucket":"_"/
121
+ expect(@phase.to_json).to match(/"bucket":"_"/)
122
122
  @phase.function[:bucket] = "foo"
123
- @phase.to_json.should =~ /"bucket":"foo"/
123
+ expect(@phase.to_json).to match(/"bucket":"foo"/)
124
124
  end
125
125
 
126
126
  it "should include the tag" do
127
- @phase.to_json.should =~ /"tag":"_"/
127
+ expect(@phase.to_json).to match(/"tag":"_"/)
128
128
  @phase.function[:tag] = "parent"
129
- @phase.to_json.should =~ /"tag":"parent"/
129
+ expect(@phase.to_json).to match(/"tag":"parent"/)
130
130
  end
131
131
 
132
132
  it "should include the keep value" do
133
- @phase.to_json.should =~ /"keep":false/
133
+ expect(@phase.to_json).to match(/"keep":false/)
134
134
  @phase.keep = true
135
- @phase.to_json.should =~ /"keep":true/
135
+ expect(@phase.to_json).to match(/"keep":true/)
136
136
  @phase.keep = false
137
137
  @phase.function[:keep] = true
138
- @phase.to_json.should =~ /"keep":true/
138
+ expect(@phase.to_json).to match(/"keep":true/)
139
139
  end
140
140
  end
141
141
  end
@@ -3,19 +3,19 @@ require 'spec_helper'
3
3
  describe Riak::MapReduce do
4
4
  before :each do
5
5
  @client = Riak::Client.new
6
- @backend = mock("Backend")
7
- @client.stub!(:backend).and_yield(@backend)
6
+ @backend = double("Backend")
7
+ allow(@client).to receive(:backend).and_yield(@backend)
8
8
  @mr = Riak::MapReduce.new(@client)
9
9
  end
10
10
 
11
11
  it "should require a client" do
12
- lambda { Riak::MapReduce.new }.should raise_error
13
- lambda { Riak::MapReduce.new(@client) }.should_not raise_error
12
+ expect { Riak::MapReduce.new }.to raise_error
13
+ expect { Riak::MapReduce.new(@client) }.not_to raise_error
14
14
  end
15
15
 
16
16
  it "should initialize the inputs and query to empty arrays" do
17
- @mr.inputs.should == []
18
- @mr.query.should == []
17
+ expect(@mr.inputs).to eq([])
18
+ expect(@mr.query).to eq([])
19
19
  end
20
20
 
21
21
  it "should yield itself when given a block on initializing" do
@@ -23,46 +23,46 @@ describe Riak::MapReduce do
23
23
  @mr = Riak::MapReduce.new(@client) do |mr|
24
24
  @mr2 = mr
25
25
  end
26
- @mr2.should == @mr
26
+ expect(@mr2).to eq(@mr)
27
27
  end
28
28
 
29
29
  describe "adding inputs" do
30
30
  it "should return self for chaining" do
31
- @mr.add("foo", "bar").should == @mr
31
+ expect(@mr.add("foo", "bar")).to eq(@mr)
32
32
  end
33
33
 
34
34
  it "should add bucket/key pairs to the inputs" do
35
35
  @mr.add("foo","bar")
36
- @mr.inputs.should == [["foo","bar"]]
36
+ expect(@mr.inputs).to eq([["foo","bar"]])
37
37
  end
38
38
 
39
39
  it "should add an array containing a bucket/key pair to the inputs" do
40
40
  @mr.add(["foo","bar"])
41
- @mr.inputs.should == [["foo","bar"]]
41
+ expect(@mr.inputs).to eq([["foo","bar"]])
42
42
  end
43
43
 
44
44
  it "should add an object to the inputs by its bucket and key" do
45
45
  bucket = Riak::Bucket.new(@client, "foo")
46
46
  obj = Riak::RObject.new(bucket, "bar")
47
47
  @mr.add(obj)
48
- @mr.inputs.should == [["foo", "bar"]]
48
+ expect(@mr.inputs).to eq([["foo", "bar"]])
49
49
  end
50
50
 
51
51
  it "should add an array containing a bucket/key/key-data triple to the inputs" do
52
52
  @mr.add(["foo","bar",1000])
53
- @mr.inputs.should == [["foo","bar",1000]]
53
+ expect(@mr.inputs).to eq([["foo","bar",1000]])
54
54
  end
55
55
 
56
56
  it "should use a bucket name as the single input" do
57
57
  @mr.add(Riak::Bucket.new(@client, "foo"))
58
- @mr.inputs.should == "foo"
58
+ expect(@mr.inputs).to eq("foo")
59
59
  @mr.add("docs")
60
- @mr.inputs.should == "docs"
60
+ expect(@mr.inputs).to eq("docs")
61
61
  end
62
62
 
63
63
  it "should accept a list of key-filters along with a bucket" do
64
64
  @mr.add("foo", [[:tokenize, "-", 3], [:string_to_int], [:between, 2009, 2010]])
65
- @mr.inputs.should == {:bucket => "foo", :key_filters => [[:tokenize, "-", 3], [:string_to_int], [:between, 2009, 2010]]}
65
+ expect(@mr.inputs).to eq({:bucket => "foo", :key_filters => [[:tokenize, "-", 3], [:string_to_int], [:between, 2009, 2010]]})
66
66
  end
67
67
 
68
68
  it "should add a bucket and filter list via a builder block" do
@@ -71,18 +71,18 @@ describe Riak::MapReduce do
71
71
  string_to_int
72
72
  between 2009, 2010
73
73
  end
74
- @mr.inputs.should == {:bucket => "foo", :key_filters => [[:tokenize, "-", 3], [:string_to_int], [:between, 2009, 2010]]}
74
+ expect(@mr.inputs).to eq({:bucket => "foo", :key_filters => [[:tokenize, "-", 3], [:string_to_int], [:between, 2009, 2010]]})
75
75
  end
76
76
 
77
77
  context "using secondary indexes as inputs" do
78
78
  it "should set the inputs for equality" do
79
- @mr.index("foo", "email_bin", "sean@basho.com").should == @mr
80
- @mr.inputs.should == {:bucket => "foo", :index => "email_bin", :key => "sean@basho.com"}
79
+ expect(@mr.index("foo", "email_bin", "sean@basho.com")).to eq(@mr)
80
+ expect(@mr.inputs).to eq({:bucket => "foo", :index => "email_bin", :key => "sean@basho.com"})
81
81
  end
82
82
 
83
83
  it "should set the inputs for a range" do
84
- @mr.index("foo", "rank_int", 10..20).should == @mr
85
- @mr.inputs.should == {:bucket => "foo", :index => "rank_int", :start => 10, :end => 20}
84
+ expect(@mr.index("foo", "rank_int", 10..20)).to eq(@mr)
85
+ expect(@mr.inputs).to eq({:bucket => "foo", :index => "rank_int", :start => 10, :end => 20})
86
86
  end
87
87
 
88
88
  it "should raise an error when given an invalid query" do
@@ -101,31 +101,31 @@ describe Riak::MapReduce do
101
101
 
102
102
  it "should add bucket/key pairs to the inputs with bucket and key escaped" do
103
103
  @mr.add("[foo]","(bar)")
104
- @mr.inputs.should == [["%5Bfoo%5D","%28bar%29"]]
104
+ expect(@mr.inputs).to eq([["%5Bfoo%5D","%28bar%29"]])
105
105
  end
106
106
 
107
107
  it "should add an escaped array containing a bucket/key pair to the inputs" do
108
108
  @mr.add(["[foo]","(bar)"])
109
- @mr.inputs.should == [["%5Bfoo%5D","%28bar%29"]]
109
+ expect(@mr.inputs).to eq([["%5Bfoo%5D","%28bar%29"]])
110
110
  end
111
111
 
112
112
  it "should add an object to the inputs by its escaped bucket and key" do
113
113
  bucket = Riak::Bucket.new(@client, "[foo]")
114
114
  obj = Riak::RObject.new(bucket, "(bar)")
115
115
  @mr.add(obj)
116
- @mr.inputs.should == [["%5Bfoo%5D", "%28bar%29"]]
116
+ expect(@mr.inputs).to eq([["%5Bfoo%5D", "%28bar%29"]])
117
117
  end
118
118
 
119
119
  it "should add an escaped array containing a bucket/key/key-data triple to the inputs" do
120
120
  @mr.add(["[foo]","(bar)","[]()"])
121
- @mr.inputs.should == [["%5Bfoo%5D", "%28bar%29","[]()"]]
121
+ expect(@mr.inputs).to eq([["%5Bfoo%5D", "%28bar%29","[]()"]])
122
122
  end
123
123
 
124
124
  it "should use an escaped bucket name as the single input" do
125
125
  @mr.add(Riak::Bucket.new(@client, "[foo]"))
126
- @mr.inputs.should == "%5Bfoo%5D"
126
+ expect(@mr.inputs).to eq("%5Bfoo%5D")
127
127
  @mr.add("docs")
128
- @mr.inputs.should == "docs"
128
+ expect(@mr.inputs).to eq("docs")
129
129
  end
130
130
  end
131
131
 
@@ -135,31 +135,31 @@ describe Riak::MapReduce do
135
135
 
136
136
  it "should add bucket/key pairs to the inputs with bucket and key unescaped" do
137
137
  @mr.add("[foo]","(bar)")
138
- @mr.inputs.should == [["[foo]","(bar)"]]
138
+ expect(@mr.inputs).to eq([["[foo]","(bar)"]])
139
139
  end
140
140
 
141
141
  it "should add an unescaped array containing a bucket/key pair to the inputs" do
142
142
  @mr.add(["[foo]","(bar)"])
143
- @mr.inputs.should == [["[foo]","(bar)"]]
143
+ expect(@mr.inputs).to eq([["[foo]","(bar)"]])
144
144
  end
145
145
 
146
146
  it "should add an object to the inputs by its unescaped bucket and key" do
147
147
  bucket = Riak::Bucket.new(@client, "[foo]")
148
148
  obj = Riak::RObject.new(bucket, "(bar)")
149
149
  @mr.add(obj)
150
- @mr.inputs.should == [["[foo]","(bar)"]]
150
+ expect(@mr.inputs).to eq([["[foo]","(bar)"]])
151
151
  end
152
152
 
153
153
  it "should add an unescaped array containing a bucket/key/key-data triple to the inputs" do
154
154
  @mr.add(["[foo]","(bar)","[]()"])
155
- @mr.inputs.should == [["[foo]","(bar)","[]()"]]
155
+ expect(@mr.inputs).to eq([["[foo]","(bar)","[]()"]])
156
156
  end
157
157
 
158
158
  it "should use an unescaped bucket name as the single input" do
159
159
  @mr.add(Riak::Bucket.new(@client, "[foo]"))
160
- @mr.inputs.should == "[foo]"
160
+ expect(@mr.inputs).to eq("[foo]")
161
161
  @mr.add("docs")
162
- @mr.inputs.should == "docs"
162
+ expect(@mr.inputs).to eq("docs")
163
163
  end
164
164
  end
165
165
  end
@@ -170,31 +170,31 @@ describe Riak::MapReduce do
170
170
 
171
171
  it "should add bucket/key pairs to the inputs with bucket and key escaped" do
172
172
  @mr.add("[foo]","(bar)")
173
- @mr.inputs.should == [["%5Bfoo%5D","%28bar%29"]]
173
+ expect(@mr.inputs).to eq([["%5Bfoo%5D","%28bar%29"]])
174
174
  end
175
175
 
176
176
  it "should add an escaped array containing a bucket/key pair to the inputs" do
177
177
  @mr.add(["[foo]","(bar)"])
178
- @mr.inputs.should == [["%5Bfoo%5D","%28bar%29"]]
178
+ expect(@mr.inputs).to eq([["%5Bfoo%5D","%28bar%29"]])
179
179
  end
180
180
 
181
181
  it "should add an object to the inputs by its escaped bucket and key" do
182
182
  bucket = Riak::Bucket.new(@client, "[foo]")
183
183
  obj = Riak::RObject.new(bucket, "(bar)")
184
184
  @mr.add(obj)
185
- @mr.inputs.should == [["%5Bfoo%5D", "%28bar%29"]]
185
+ expect(@mr.inputs).to eq([["%5Bfoo%5D", "%28bar%29"]])
186
186
  end
187
187
 
188
188
  it "should add an escaped array containing a bucket/key/key-data triple to the inputs" do
189
189
  @mr.add(["[foo]","(bar)","[]()"])
190
- @mr.inputs.should == [["%5Bfoo%5D", "%28bar%29","[]()"]]
190
+ expect(@mr.inputs).to eq([["%5Bfoo%5D", "%28bar%29","[]()"]])
191
191
  end
192
192
 
193
193
  it "should use an escaped bucket name as the single input" do
194
194
  @mr.add(Riak::Bucket.new(@client, "[foo]"))
195
- @mr.inputs.should == "%5Bfoo%5D"
195
+ expect(@mr.inputs).to eq("%5Bfoo%5D")
196
196
  @mr.add("docs")
197
- @mr.inputs.should == "docs"
197
+ expect(@mr.inputs).to eq("docs")
198
198
  end
199
199
  end
200
200
 
@@ -203,13 +203,13 @@ describe Riak::MapReduce do
203
203
  after { Riak.disable_list_keys_warnings = true }
204
204
 
205
205
  it "should warn about list-keys on buckets" do
206
- @mr.should_receive(:warn).twice
206
+ expect(@mr).to receive(:warn).twice
207
207
  @mr.add("foo")
208
208
  @mr.add(Riak::Bucket.new(@client, "foo"))
209
209
  end
210
210
 
211
211
  it "should warn about list-keys on key-filters" do
212
- @mr.should_receive(:warn)
212
+ expect(@mr).to receive(:warn)
213
213
  @mr.filter("foo") { matches "bar" }
214
214
  end
215
215
  end
@@ -218,111 +218,111 @@ describe Riak::MapReduce do
218
218
  [:map, :reduce].each do |type|
219
219
  describe "adding #{type} phases" do
220
220
  it "should return self for chaining" do
221
- @mr.send(type, "function(){}").should == @mr
221
+ expect(@mr.send(type, "function(){}")).to eq(@mr)
222
222
  end
223
223
 
224
224
  it "should accept a function string" do
225
225
  @mr.send(type, "function(){}")
226
- @mr.query.should have(1).items
226
+ expect(@mr.query.size).to eq(1)
227
227
  phase = @mr.query.first
228
- phase.function.should == "function(){}"
229
- phase.type.should == type
228
+ expect(phase.function).to eq("function(){}")
229
+ expect(phase.type).to eq(type)
230
230
  end
231
231
 
232
232
  it "should accept a function and options" do
233
233
  @mr.send(type, "function(){}", :keep => true)
234
- @mr.query.should have(1).items
234
+ expect(@mr.query.size).to eq(1)
235
235
  phase = @mr.query.first
236
- phase.function.should == "function(){}"
237
- phase.type.should == type
238
- phase.keep.should be_true
236
+ expect(phase.function).to eq("function(){}")
237
+ expect(phase.type).to eq(type)
238
+ expect(phase.keep).to be_truthy
239
239
  end
240
240
 
241
241
  it "should accept a module/function pair" do
242
242
  @mr.send(type, ["riak","mapsomething"])
243
- @mr.query.should have(1).items
243
+ expect(@mr.query.size).to eq(1)
244
244
  phase = @mr.query.first
245
- phase.function.should == ["riak", "mapsomething"]
246
- phase.type.should == type
247
- phase.language.should == "erlang"
245
+ expect(phase.function).to eq(["riak", "mapsomething"])
246
+ expect(phase.type).to eq(type)
247
+ expect(phase.language).to eq("erlang")
248
248
  end
249
249
 
250
250
  it "should accept a module/function pair with extra options" do
251
251
  @mr.send(type, ["riak", "mapsomething"], :arg => [1000])
252
- @mr.query.should have(1).items
252
+ expect(@mr.query.size).to eq(1)
253
253
  phase = @mr.query.first
254
- phase.function.should == ["riak", "mapsomething"]
255
- phase.type.should == type
256
- phase.language.should == "erlang"
257
- phase.arg.should == [1000]
254
+ expect(phase.function).to eq(["riak", "mapsomething"])
255
+ expect(phase.type).to eq(type)
256
+ expect(phase.language).to eq("erlang")
257
+ expect(phase.arg).to eq([1000])
258
258
  end
259
259
  end
260
260
  end
261
261
 
262
262
  describe "adding link phases" do
263
263
  it "should return self for chaining" do
264
- @mr.link({}).should == @mr
264
+ expect(@mr.link({})).to eq(@mr)
265
265
  end
266
266
 
267
267
  it "should accept a WalkSpec" do
268
268
  @mr.link(Riak::WalkSpec.new(:tag => "next"))
269
- @mr.query.should have(1).items
269
+ expect(@mr.query.size).to eq(1)
270
270
  phase = @mr.query.first
271
- phase.type.should == :link
272
- phase.function.should be_kind_of(Riak::WalkSpec)
273
- phase.function.tag.should == "next"
271
+ expect(phase.type).to eq(:link)
272
+ expect(phase.function).to be_kind_of(Riak::WalkSpec)
273
+ expect(phase.function.tag).to eq("next")
274
274
  end
275
275
 
276
276
  it "should accept a WalkSpec and a hash of options" do
277
277
  @mr.link(Riak::WalkSpec.new(:bucket => "foo"), :keep => true)
278
- @mr.query.should have(1).items
278
+ expect(@mr.query.size).to eq(1)
279
279
  phase = @mr.query.first
280
- phase.type.should == :link
281
- phase.function.should be_kind_of(Riak::WalkSpec)
282
- phase.function.bucket.should == "foo"
283
- phase.keep.should be_true
280
+ expect(phase.type).to eq(:link)
281
+ expect(phase.function).to be_kind_of(Riak::WalkSpec)
282
+ expect(phase.function.bucket).to eq("foo")
283
+ expect(phase.keep).to be_truthy
284
284
  end
285
285
 
286
286
  it "should accept a hash of options intermingled with the walk spec options" do
287
287
  @mr.link(:tag => "snakes", :arg => [1000])
288
- @mr.query.should have(1).items
288
+ expect(@mr.query.size).to eq(1)
289
289
  phase = @mr.query.first
290
- phase.arg.should == [1000]
291
- phase.function.should be_kind_of(Riak::WalkSpec)
292
- phase.function.tag.should == "snakes"
290
+ expect(phase.arg).to eq([1000])
291
+ expect(phase.function).to be_kind_of(Riak::WalkSpec)
292
+ expect(phase.function.tag).to eq("snakes")
293
293
  end
294
294
  end
295
295
 
296
296
  describe "converting to JSON for the job" do
297
297
  it "should include the inputs and query keys" do
298
- @mr.to_json.should =~ /"inputs":/
298
+ expect(@mr.to_json).to match(/"inputs":/)
299
299
  end
300
300
 
301
301
  it "should map phases to their JSON equivalents" do
302
302
  phase = Riak::MapReduce::Phase.new(:type => :map, :function => "function(){}")
303
303
  @mr.query << phase
304
- @mr.to_json.should include('"source":"function(){}"')
305
- @mr.to_json.should include('"query":[{"map":{')
304
+ expect(@mr.to_json).to include('"source":"function(){}"')
305
+ expect(@mr.to_json).to include('"query":[{"map":{')
306
306
  end
307
307
 
308
308
  it "should emit only the bucket name when the input is the whole bucket" do
309
309
  @mr.add("foo")
310
- @mr.to_json.should include('"inputs":"foo"')
310
+ expect(@mr.to_json).to include('"inputs":"foo"')
311
311
  end
312
312
 
313
313
  it "should emit an array of inputs when there are multiple inputs" do
314
314
  @mr.add("foo","bar",1000).add("foo","baz")
315
- @mr.to_json.should include('"inputs":[["foo","bar",1000],["foo","baz"]]')
315
+ expect(@mr.to_json).to include('"inputs":[["foo","bar",1000],["foo","baz"]]')
316
316
  end
317
317
 
318
318
  it "should add the timeout value when set" do
319
319
  @mr.timeout(50000)
320
- @mr.to_json.should include('"timeout":50000')
320
+ expect(@mr.to_json).to include('"timeout":50000')
321
321
  end
322
322
  end
323
323
 
324
324
  it "should return self from setting the timeout" do
325
- @mr.timeout(5000).should == @mr
325
+ expect(@mr.timeout(5000)).to eq(@mr)
326
326
  end
327
327
 
328
328
  describe "executing the map reduce job" do
@@ -331,32 +331,34 @@ describe Riak::MapReduce do
331
331
  end
332
332
 
333
333
  it "should submit the query to the backend" do
334
- @backend.should_receive(:mapred).with(@mr).and_return([])
335
- @mr.run.should == []
334
+ expect(@backend).to receive(:mapred).with(@mr).and_return([])
335
+ expect(@mr.run).to eq([])
336
336
  end
337
337
 
338
338
  it "should pass the given block to the backend for streaming" do
339
339
  arr = []
340
- @backend.should_receive(:mapred).with(@mr).and_yield("foo").and_yield("bar")
340
+ expect(@backend).to receive(:mapred).with(@mr).and_yield("foo").and_yield("bar")
341
341
  @mr.run {|v| arr << v }
342
- arr.should == ["foo", "bar"]
342
+ expect(arr).to eq(["foo", "bar"])
343
343
  end
344
344
 
345
345
  it "should interpret failed requests with JSON content-types as map reduce errors" do
346
- @backend.stub!(:mapred).and_raise(Riak::HTTPFailedRequest.new(:post, 200, 500, {"content-type" => ["application/json"]}, '{"error":"syntax error"}'))
347
- lambda { @mr.run }.should raise_error(Riak::MapReduceError)
346
+ allow(@backend).to receive(:mapred).
347
+ and_raise(Riak::ProtobuffsFailedRequest.new(:server_error, '{"error":"syntax error"}'))
348
+ expect{ @mr.run }.to raise_error(Riak::MapReduceError)
348
349
  begin
349
350
  @mr.run
350
351
  rescue Riak::MapReduceError => mre
351
- mre.message.should include('{"error":"syntax error"}')
352
+ expect(mre.message).to include('{"error":"syntax error"}')
352
353
  else
353
354
  fail "No exception raised!"
354
355
  end
355
356
  end
356
357
 
357
358
  it "should re-raise non-JSON error responses" do
358
- @backend.stub!(:mapred).and_raise(Riak::HTTPFailedRequest.new(:post, 200, 500, {"content-type" => ["text/plain"]}, 'Oops, you bwoke it.'))
359
- lambda { @mr.run }.should raise_error(Riak::FailedRequest)
359
+ allow(@backend).to receive(:mapred).
360
+ and_raise(Riak::ProtobuffsFailedRequest.new(:server_error, 'Oops, you bwoke it.'))
361
+ expect { @mr.run }.to raise_error(Riak::FailedRequest)
360
362
  end
361
363
  end
362
364
  end