Sha256: 247f8e0d89e4b521dfccbc78f1e323f922a4eedc220665a45776301b416f3c85

Contents?: true

Size: 1.96 KB

Versions: 1

Compression:

Stored size: 1.96 KB

Contents

require "spec_helper"

describe Moped::Connection::Socket::Connectable do

  describe "#handle_socket_errors" do

    let(:object) do
      Class.new do
        include Moped::Connection::Socket::Connectable
        def host; "127.0.0.1"; end
        def port; 27017; end
      end.new
    end

    context "when a Errno::ECONNREFUSED is raised" do

      it "re-raises a ConnectionFailure" do
        expect{
          object.send(:handle_socket_errors) { raise Errno::ECONNREFUSED }
        }.to raise_error(
          Moped::Errors::ConnectionFailure
        )
      end
    end

    context "when a Errno::EHOSTUNREACH is raised" do

      it "re-raises a ConnectionFailure" do
        expect{
          object.send(:handle_socket_errors) { raise Errno::EHOSTUNREACH }
        }.to raise_error(
          Moped::Errors::ConnectionFailure
        )
      end
    end

    context "when a Errno::EPIPE is raised" do

      it "re-raises a ConnectionFailure" do
        expect{
          object.send(:handle_socket_errors) { raise Errno::EPIPE }
        }.to raise_error(
          Moped::Errors::ConnectionFailure
        )
      end
    end

    context "when a Errno::ECONNRESET is raised" do

      it "re-raises a ConnectionFailure" do
        expect{
          object.send(:handle_socket_errors) { raise Errno::ECONNRESET }
        }.to raise_error(
          Moped::Errors::ConnectionFailure
        )
      end
    end

    context "when a Errno::ETIMEDOUT is raised" do

      it "re-raises a ConnectionFailure" do
        expect{
          object.send(:handle_socket_errors) { raise Errno::ETIMEDOUT }
        }.to raise_error(
          Moped::Errors::ConnectionFailure
        )
      end
    end

    context "when a Errno::ENETUNREACH is raised" do

      it "re-raises a ConnectionFailure" do
        expect{
          object.send(:handle_socket_errors) { raise Errno::ENETUNREACH }
        }.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/connection/socket/connectable_spec.rb