spec/unit/configuration/account_spec.rb in imap-backup-0.0.5 vs spec/unit/configuration/account_spec.rb in imap-backup-1.0.0

- old
+ new

@@ -1,10 +1,9 @@ # encoding: utf-8 -load File.expand_path( '../../spec_helper.rb', File.dirname(__FILE__) ) +require 'spec_helper' describe Imap::Backup::Configuration::Account do - include HighLineTestHelpers include InputOutputTestHelpers def choose_menu_item(item) @state = :initial @@ -18,11 +17,10 @@ end end end context '#run' do - before :each do @account1_path = '/backup/path' @account1 = { :username => 'user@example.com', :password => 'secret', @@ -43,11 +41,10 @@ end subject { Imap::Backup::Configuration::Account.new(@store, @account1) } context 'menu' do - it 'should show a menu' do subject.run @output.string.should =~ /modify email/ @output.string.should =~ /modify password/ @@ -76,11 +73,10 @@ end end context 'email' do - it 'should modify the email address' do Imap::Backup::Configuration::Asker.should_receive(:email).once.and_return('new@example.com') choose_menu_item 'modify email' @@ -97,15 +93,13 @@ capturing_output do subject.run end.should =~ /there is already an account set up with that email address/i end - end context 'password' do - it 'should update the password' do Imap::Backup::Configuration::Asker.should_receive(:password).once.and_return('new_pwd') choose_menu_item 'modify password' @@ -121,15 +115,13 @@ subject.run @account1[:password].should == 'secret' end - end context 'backup_path' do - it 'should update the path' do Imap::Backup::Configuration::Asker.should_receive(:backup_path).once do |default, validator| validator.call('new/path') '/new/path' end @@ -151,11 +143,10 @@ capturing_output do subject.run end.should =~ %r{The path '/existing/path' is used to backup the account 'existing@example.com'} end - end it 'should add/remove folders' do @chooser = stub('Imap::Backup::Configuration::FolderChooser') Imap::Backup::Configuration::FolderChooser.should_receive(:new).with(@account1).and_return(@chooser) @@ -175,11 +166,10 @@ subject.run end.should == "All fine\n" end context 'deletion' do - it 'should confirm deletion' do Imap::Backup::Configuration::Setup.highline.should_receive(:agree).with("Are you sure? (y/n) ").and_return(true) choose_menu_item 'delete' @@ -203,22 +193,17 @@ subject.run @data[:accounts].should include(@account1) end - end context 'return to main menu' do - it 'should return' do @input.stub!(:gets).with().and_return("return\n") subject.run.should be_nil end - end - end - end