Sha256: f35431d2ef1cc010b34c07ba59bc008c981c6be63f760abaf9f61b7e94fd2ec0
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
require "imap/backup/cli/accounts" describe Imap::Backup::CLI::Accounts do subject { described_class.new(required_accounts) } let(:required_accounts) { [] } let(:accounts) { [account1, account2] } let(:account1) do instance_double( Imap::Backup::Account, username: "a1@example.com" ) end let(:account2) do instance_double( Imap::Backup::Account, username: "a2@example.com" ) end let(:store) do instance_double(Imap::Backup::Configuration, accounts: accounts) end let(:exists) { true } before do allow(Imap::Backup::Configuration).to receive(:new) { store } allow(Imap::Backup::Configuration). to receive(:exist?) { exists } end describe "#each" do specify "calls the block with each account" do result = subject.map { |a| a } expect(result).to eq(accounts) end context "when the configuration file is missing" do let(:exists) { false } it "fails" do expect do subject.each {} end.to raise_error(Imap::Backup::ConfigurationNotFound, /not found/) end end context "when an account list is provided" do let(:required_accounts) { %w(a2@example.com) } specify "calls the block with each account" do result = subject.map { |a| a } expect(result).to eq([account2]) 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/accounts_spec.rb |