Sha256: a51f46d837be9d1c847638f2f0463189c770ab8550396ec53a0787f6e476ba1a

Contents?: true

Size: 977 Bytes

Versions: 1

Compression:

Stored size: 977 Bytes

Contents

module Imap::Backup
  describe CLI::Folders do
    subject { described_class.new({}) }

    let(:connection) do
      instance_double(
        Account::Connection, account: account, folder_names: folder_names
      )
    end
    let(:account) { instance_double(Account, username: "user") }
    let(:folder_names) { ["my-folder"] }

    before do
      allow(Kernel).to receive(:puts)
      allow(Kernel).to receive(:warn)
      # rubocop:disable RSpec/SubjectStub
      allow(subject).to receive(:each_connection).with([]).and_yield(connection)
      # rubocop:enable RSpec/SubjectStub

      subject.run
    end

    it "lists folders" do
      expect(Kernel).to have_received(:puts).with("\tmy-folder")
    end

    context "when the folder list is not fetched" do
      let(:folder_names) { nil }

      it "warns" do
        expect(Kernel).to have_received(:warn).with(/Unable to list/)
      end

      it "doesn't fail" do
        subject.run
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
imap-backup-6.0.0.rc2 spec/unit/imap/backup/cli/folders_spec.rb