Sha256: 4551ea17b5421d9800d0ccd40fcff8618b9e756a8a97715e56f6d450d9cba813

Contents?: true

Size: 1.08 KB

Versions: 17

Compression:

Stored size: 1.08 KB

Contents

describe Imap::Backup::Downloader do
  describe "#run" do
    subject { described_class.new(folder, serializer) }

    let(:message) { {"RFC822" => "blah"} }
    let(:folder) do
      instance_double(
        Imap::Backup::Account::Folder,
        fetch: message,
        name: "folder",
        uids: folder_uids
      )
    end
    let(:folder_uids) { %w(111 222 333) }
    let(:serializer) do
      instance_double(Imap::Backup::Serializer::Mbox, save: nil, uids: ["222"])
    end

    context "with fetched messages" do
      specify "are saved" do
        expect(serializer).to receive(:save).with("111", message)

        subject.run
      end
    end

    context "with messages which are already present" do
      specify "are skipped" do
        expect(serializer).to_not receive(:save).with("222", anything)

        subject.run
      end
    end

    context "with failed fetches" do
      specify "are skipped" do
        allow(folder).to receive(:fetch).with("333") { nil }
        expect(serializer).to_not receive(:save).with("333", anything)

        subject.run
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
imap-backup-4.0.0.rc5 spec/unit/imap/backup/downloader_spec.rb
imap-backup-4.0.0.rc4 spec/unit/imap/backup/downloader_spec.rb
imap-backup-4.0.0.rc3 spec/unit/imap/backup/downloader_spec.rb
imap-backup-4.0.0.rc2 spec/unit/imap/backup/downloader_spec.rb
imap-backup-4.0.0.rc1 spec/unit/imap/backup/downloader_spec.rb
imap-backup-3.4.1 spec/unit/imap/backup/downloader_spec.rb
imap-backup-3.4.0 spec/unit/imap/backup/downloader_spec.rb
imap-backup-3.3.1 spec/unit/imap/backup/downloader_spec.rb
imap-backup-3.3.0 spec/unit/imap/backup/downloader_spec.rb
imap-backup-3.2.1 spec/unit/imap/backup/downloader_spec.rb
imap-backup-3.2.0 spec/unit/imap/backup/downloader_spec.rb
imap-backup-3.1.0 spec/unit/imap/backup/downloader_spec.rb
imap-backup-3.0.0 spec/unit/imap/backup/downloader_spec.rb
imap-backup-3.0.0.rc1 spec/unit/imap/backup/downloader_spec.rb
imap-backup-2.2.2 spec/unit/imap/backup/downloader_spec.rb
imap-backup-2.2.1 spec/unit/imap/backup/downloader_spec.rb
imap-backup-2.2.0 spec/unit/imap/backup/downloader_spec.rb