Skip to content

Commit 84ecf47

Browse files
committed
skip mystery jruby error ... it works fine without expect
also removing thread_count check since it is impossible to reach this code because the client already checks it
1 parent c74cc50 commit 84ecf47

3 files changed

Lines changed: 12 additions & 16 deletions

File tree

lib/riak/multi.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ def initialize(client, keys)
3737
raise ArgumentError, t('array_type', :array => keys.inspect) unless keys.is_a? Array
3838

3939
self.thread_count = client.multi_threads
40-
unless thread_count.is_a?(Integer) && thread_count > 0
41-
raise ArgumentError, t("invalid_multiget_thread_count") # TODO: should be invalid_multi_thread_count
42-
end
43-
4440
validate_keys keys
4541
@client = client
4642
@keys = keys.uniq

spec/riak/multi_spec.rb

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
SingleCov.covered! if defined?(SingleCov)
44

55
describe Riak::Multi do
6-
let(:multi) { Riak::Multi.new(@client, @pairs) }
6+
class TestMulti < Riak::Multi
7+
def work(bucket, key)
8+
"value-#{bucket.name}-#{key}"
9+
end
10+
end
11+
12+
let(:multi) { TestMulti.new(@client, @pairs) }
713

814
before :each do
915
@client = Riak::Client.new
@@ -25,18 +31,15 @@
2531

2632
describe ".perform" do
2733
it "works" do
28-
expect_any_instance_of(Riak::Multi).to receive(:work).with(@bucket, 'key1')
29-
expect_any_instance_of(Riak::Multi).to receive(:work).with(@bucket, 'key2')
30-
expect(Riak::Multi.perform(@client, @pairs)).to eq([@bucket, 'key1'] => nil, [@bucket, 'key2'] => nil)
34+
expect(TestMulti.perform(@client, @pairs)).to eq([@bucket, 'key1'] => 'value-foo-key1', [@bucket, 'key2'] => 'value-foo-key2')
3135
end
3236
end
3337

3438
describe "#perform" do
3539
it "works on both keys from the bucket" do
36-
expect(multi).to receive(:work).with(@bucket, 'key1')
37-
expect(multi).to receive(:work).with(@bucket, 'key2')
3840
multi.perform
3941
multi.wait_for_finish
42+
expect(multi.results).to eq([@bucket, 'key1'] => "value-foo-key1", [@bucket, 'key2'] => "value-foo-key2")
4043
end
4144

4245
it "works asynchronously" do
@@ -91,18 +94,14 @@
9194

9295
describe "#results" do
9396
it "returns a hash of pairs to values" do
94-
expect(multi).to receive(:work).with(@bucket, 'key1')
95-
expect(multi).to receive(:work).with(@bucket, 'key2')
96-
9797
multi.perform
98-
9998
expect(multi.results).to be_a Hash
10099
end
101100
end
102101

103102
describe "#work" do
104103
it "needs to be implemented in the subclasses" do
105-
expect { multi.send(:work, 1, 2) }.to raise_error(NotImplementedError)
104+
expect { Riak::Multi.new(@client, @pairs).send(:work, 1, 2) }.to raise_error(NotImplementedError)
106105
end
107106
end
108107
end

spec/spec_helper.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'bundler/setup'
22

3-
if RUBY_VERSION >= "2."
3+
# ruby 1.9 and jruby without debug do not support single-cov
4+
if RUBY_VERSION >= "2." && (RUBY_ENGINE != 'jruby' || ENV['JRUBY_OPTS'].to_s.include?('--debug'))
45
require 'single_cov'
56
SingleCov.setup :rspec
67
end

0 commit comments

Comments
 (0)