Sha256: 4a99612df737fa313d7ebae44bb63e6c3be275b58646db7f3ce7c79130960cdf

Contents?: true

Size: 1022 Bytes

Versions: 5

Compression:

Stored size: 1022 Bytes

Contents

require 'net/imap'

require 'spec_helper'


describe Redimap::ImapConn do
  
  before(:each) do
    @fake_net_imap = double(Net::IMAP)
    
    Net::IMAP.stub(:new).and_return(@fake_net_imap)
    
    @fake_net_imap.stub(:login)
  end
  
  context "#initialize" do
    it "should set imap as Net::IMAP" do
      Redimap::ImapConn.new.instance_variable_get('@imap').should == @fake_net_imap
    end
    
    it "should #close when block" do
      Redimap::ImapConn.new do |imap|
        imap.should_receive(:close)
      end
    end
  end
  
  context "#close" do
    before(:each) do
      @imap = Redimap::ImapConn.new
      
      @imap_imap = @imap.instance_variable_get('@imap')
    end
    
    it "should disconnect from IMAP" do
      @imap_imap.stub(:logout)
      
      @imap_imap.should_receive(:disconnect)
      
      @imap.close
    end
    
    it "should logout from IMAP" do
      @imap_imap.stub(:disconnect)
      
      @imap_imap.should_receive(:logout)
      
      @imap.close
    end
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
redimap-0.5.0 spec/lib/redimap/imap_conn_spec.rb
redimap-0.4.0 spec/lib/redimap/imap_conn_spec.rb
redimap-0.3.1 spec/lib/redimap/imap_conn_spec.rb
redimap-0.3.0 spec/lib/redimap/imap_conn_spec.rb
redimap-0.2.0 spec/lib/redimap/imap_conn_spec.rb