Sha256: a5ed30315e250647d3b7851457ce9ba204143bf7ee97ae750bf3961ae4fd7836
Contents?: true
Size: 1.85 KB
Versions: 2
Compression:
Stored size: 1.85 KB
Contents
# encoding: utf-8 load File.expand_path( '../../spec_helper.rb', File.dirname(__FILE__) ) describe Imap::Backup::Configuration::List do before :each do @configuration_data = { :accounts => [ { :username => 'a1@example.com' }, { :username => 'a2@example.com', }, ] } @store = stub('Imap::Backup::Configuration::Store', :data => @configuration_data) Imap::Backup::Configuration::Store.stub!(:new => @store) end context '#initialize' do context 'with account parameter' do it 'should only create requested accounts' do configuration = Imap::Backup::Configuration::List.new(['a2@example.com']) configuration.accounts.should == @configuration_data[:accounts][1..1] end end end context 'instance methods' do before :each do @connection = stub('Imap::Backup::Account::Connection', :disconnect => nil) end subject { Imap::Backup::Configuration::List.new } context '#each_connection' do it 'should instantiate connections' do Imap::Backup::Account::Connection.should_receive(:new).with(@configuration_data[:accounts][0]).and_return(@connection) Imap::Backup::Account::Connection.should_receive(:new).with(@configuration_data[:accounts][1]).and_return(@connection) subject.each_connection{} end it 'should call the block' do Imap::Backup::Account::Connection.stub!(:new).and_return(@connection) calls = 0 subject.each_connection do |a| calls += 1 a.should == @connection end calls.should == 2 end it 'should disconnect connections' do Imap::Backup::Account::Connection.stub!(:new).and_return(@connection) @connection.should_receive(:disconnect) subject.each_connection {} end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
imap-backup-0.0.5 | spec/unit/configuration/list_spec.rb |
imap-backup-0.0.4 | spec/unit/configuration/list_spec.rb |