Sha256: 4fd0965ebd6960907c5a36faf159de8e5133fccd6228f7120829ac126d523a21
Contents?: true
Size: 1020 Bytes
Versions: 1
Compression:
Stored size: 1020 Bytes
Contents
require "spec_helper" describe Moped::ReadPreference::Nearest do describe "#name" do let(:preference) do described_class.new end it "returns nearest" do expect(preference.name).to eq(:nearest) end end describe "#with_node", replica_set: true do let(:preference) do described_class.new end context "when primary or secondaries are available" do let(:cluster) do Moped::Cluster.new([ @primary.address ], {}) end let(:nearest) do cluster.nodes.sort_by(&:latency).first end it "returns the nearest node" do preference.with_node(cluster) do |node| expect(node).to eq(nearest) end end end context "when no nodes are available" do let(:cluster) do Moped::Cluster.new([], {}) end it "raises an error" do expect { preference.with_node(cluster) {} }.to raise_error(Moped::Errors::ConnectionFailure) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ish_lib_manager-0.0.1 | test/dummy/vendor/bundle/ruby/2.3.0/bundler/gems/moped-cf817ca58a85/spec/moped/read_preference/nearest_spec.rb |