Sha256: 16afe782d187a2bdb6f94b6814c3453c7d0a5f26353fd606ce41592e40d9beb0

Contents?: true

Size: 1.18 KB

Versions: 9

Compression:

Stored size: 1.18 KB

Contents

describe Imap::Backup::Setup::ConnectionTester do
  describe "#test" do
    subject { described_class.new("foo") }

    let(:connection) do
      instance_double(Imap::Backup::Account::Connection, client: nil)
    end

    before do
      allow(Imap::Backup::Account::Connection).to receive(:new) { connection }
    end

    it "tries to connect" do
      expect(connection).to receive(:client)

      subject.test
    end

    describe "success" do
      it "returns success" do
        expect(subject.test).to match(/successful/)
      end
    end

    describe "failure" do
      before do
        allow(connection).to receive(:client).and_raise(error)
      end

      context "with no connection" do
        let(:error) do
          data = OpenStruct.new(text: "bar")
          response = OpenStruct.new(data: data)
          Net::IMAP::NoResponseError.new(response)
        end

        it "returns error" do
          expect(subject.test).to match(/no response/i)
        end
      end

      context "when caused by other errors" do
        let(:error) { "Error" }

        it "returns error" do
          expect(subject.test).to match(/unexpected error/i)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
imap-backup-6.0.0.rc2 spec/unit/imap/backup/setup/connection_tester_spec.rb
imap-backup-5.2.0 spec/unit/imap/backup/setup/connection_tester_spec.rb
imap-backup-5.1.0 spec/unit/imap/backup/setup/connection_tester_spec.rb
imap-backup-5.0.0 spec/unit/imap/backup/setup/connection_tester_spec.rb
imap-backup-4.2.2 spec/unit/imap/backup/setup/connection_tester_spec.rb
imap-backup-4.2.1 spec/unit/imap/backup/setup/connection_tester_spec.rb
imap-backup-4.2.0 spec/unit/imap/backup/setup/connection_tester_spec.rb
imap-backup-4.1.2 spec/unit/imap/backup/setup/connection_tester_spec.rb
imap-backup-4.1.1 spec/unit/imap/backup/setup/connection_tester_spec.rb