Sha256: 1be19d2f0b71563986f38beaa0fdceccc30c955f10cc996fee8e4e52fd28e396

Contents?: true

Size: 1.3 KB

Versions: 6

Compression:

Stored size: 1.3 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe Imap::Backup::Configuration::ConnectionTester do
  context '.test' do
    it 'should try to connect' do
      Imap::Backup::Account::Connection.should_receive(:new).with('foo')

      Imap::Backup::Configuration::ConnectionTester.test('foo')
    end

    it 'should return success if the connection works' do
      Imap::Backup::Account::Connection.stub!(:new).
                                        with('foo')

      result = Imap::Backup::Configuration::ConnectionTester.test('foo')

      result.should =~ /successful/
    end

    it 'should handle no response' do
      e = Net::IMAP::NoResponseError.new(stub('o', :data => stub('foo', :text => 'bar')))
      Imap::Backup::Account::Connection.stub!(:new).
                                        with('foo').
                                        and_raise(e)

      result = Imap::Backup::Configuration::ConnectionTester.test('foo')

      result.should =~ /no response/i
    end

    it 'should handle other errors' do
      Imap::Backup::Account::Connection.stub!(:new).
                                        with('foo').
                                        and_raise('error')

      result = Imap::Backup::Configuration::ConnectionTester.test('foo')

      result.should =~ /unexpected error/i
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
imap-backup-1.0.5 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.0.4 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.0.3 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.0.2 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.0.1 spec/unit/configuration/connection_tester_spec.rb
imap-backup-1.0.0 spec/unit/configuration/connection_tester_spec.rb