Sha256: 3a63db79316ef2a05c3fdf74727814626b4a8f5edd2ff0499dd53334eaab0c91

Contents?: true

Size: 1.25 KB

Versions: 16

Compression:

Stored size: 1.25 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe Imap::Backup::Configuration::ConnectionTester do
  context '.test' do
    let(:connection) { double('Imap::Backup::Account::Connection', :imap => nil) }

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

    context 'call' do
      before { @result = subject.test('foo') }

      it 'tries to connect' do
        expect(connection).to have_received(:imap)
      end
    end

    context 'success' do
      before { @result = subject.test('foo') }

      it 'returns success' do
        expect(@result).to match(/successful/)
      end
    end

    context 'failure' do
      before do
        allow(connection).to receive(:imap).and_raise(error)
        @result = subject.test('foo')
      end

      context 'no connection' do
        let(:error) do
          data = double('foo', :text => 'bar')
          Net::IMAP::NoResponseError.new(double('o', :data => data))
        end

        it 'returns success' do
          expect(@result).to match(/no response/i)
        end
      end

      context 'other' do
        let(:error) { 'Error' }
        it 'returns success' do
          expect(@result).to match(/unexpected error/i)
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
imap-backup-1.2.2 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.2.1 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.2.0 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.1.0 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.0.17 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.0.16 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.0.15 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.0.14 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.0.13 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.0.12 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.0.11 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.0.10 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.0.9 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.0.8 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.0.7 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.0.6 spec/unit/configuration/connection_tester_spec.rb