Sha256: 1752f7d398f776a369c04120968c8a072589d7a5f0f1aa395a86ae651093b4e4

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

require "spec_helper"

describe Moped::Failover do

  describe ".get" do

    context "when providing an unregistered exception" do

      let(:failover) do
        described_class.get(RuntimeError.new)
      end

      it "returns disconnect" do
        expect(failover).to be_a(Moped::Failover::Disconnect)
      end
    end

    context "when providing a registered exception" do

      context "when providing an operation failure" do

        let(:failover) do
          described_class.get(Moped::Errors::OperationFailure.new({}, {}))
        end

        it "returns a reconfigure" do
          expect(failover).to be_a(Moped::Failover::Reconfigure)
        end
      end

      context "when providing a query failure" do

        let(:failover) do
          described_class.get(Moped::Errors::QueryFailure.new({}, {}))
        end

        it "returns a reconfigure" do
          expect(failover).to be_a(Moped::Failover::Reconfigure)
        end
      end

      context "when providing a cursor not found" do

        let(:failover) do
          described_class.get(Moped::Errors::CursorNotFound.new({}, 123))
        end

        it "returns an ignore" do
          expect(failover).to be_a(Moped::Failover::Ignore)
        end
      end

      context "when providing an authentication failure" do

        let(:failover) do
          described_class.get(Moped::Errors::AuthenticationFailure.new({}, {}))
        end

        it "returns an ignore" do
          expect(failover).to be_a(Moped::Failover::Ignore)
        end
      end

      context "when providing a connection failure" do

        let(:failover) do
          described_class.get(Moped::Errors::ConnectionFailure.new({}))
        end

        it "returns a retry" do
          expect(failover).to be_a(Moped::Failover::Retry)
        end
      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/failover_spec.rb