Sha256: 7ec7211e8561cd802be1a21617edb368d8d12defe177dffadb1155d842a4bffa
Contents?: true
Size: 1.83 KB
Versions: 1
Compression:
Stored size: 1.83 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Imap::Backup::Account::Folder do include InputOutputTestHelpers context 'with instance' do before :each do @imap = stub('Net::IMAP') @connection = stub('Imap::Backup::Account::Connection', :imap => @imap) end subject { Imap::Backup::Account::Folder.new(@connection, 'my_folder') } context '#uids' do it 'should list available messages' do @imap.should_receive(:examine).with('my_folder') @imap.should_receive(:uid_search).with(['ALL']).and_return([5678, 123]) subject.uids.should == [123, 5678] end it 'returns an empty array for missing mailboxes' do data = stub('Data', :text => 'Unknown Mailbox: my_folder') response = stub('Response', :data => data) error = Net::IMAP::NoResponseError.new(response) @imap. should_receive(:examine). with('my_folder'). and_raise(error) capturing_output do expect(subject.uids).to eq([]) end end end context '#fetch' do before :each do @message_body = 'the body' @message = { 'RFC822' => @message_body, 'other' => 'xxx' } end it 'should request the message, the flags and the date' do @imap.should_receive(:examine).with('my_folder') @imap.should_receive(:uid_fetch). with([123], ['RFC822', 'FLAGS', 'INTERNALDATE']). and_return([[nil, @message]]) subject.fetch(123) end if RUBY_VERSION > '1.9' it 'should set the encoding on the message' do @imap.stub!(:examine => nil, :uid_fetch => [[nil, @message]]) @message_body.should_receive(:force_encoding).with('utf-8') subject.fetch(123) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
imap-backup-1.0.2 | spec/unit/account/folder_spec.rb |