spec/rdiff_simple_spec.rb in rdiff-simple-0.0.4 vs spec/rdiff_simple_spec.rb in rdiff-simple-0.0.5

- old
+ new

@@ -1,56 +1,45 @@ require 'spec_helper' describe RdiffSimple do describe '#execute' do - context 'when no arguments are given' do - it 'should return false' do - subject.execute.should be_false + context 'when rdiff-backup is installed' do + before { mock_rdiff_installed :yes } + + context 'when no arguments are given' do + before { mock_rdiff_command '', :failed } + subject { RdiffSimple.execute } + + it { should be_false } end - end - context 'when arguments are given' do - it 'should return true' do - subject.execute('--version').should be_true + context 'when arguments are given' do + before { mock_rdiff_command '--version', :succeeded } + subject { RdiffSimple.execute('--version') } + + it { should be_true } end end context 'when rdiff-backup is not installed' do - before(:each) do - mock_rdiff_installed(false) - end + before { mock_rdiff_installed false } - it 'should be false' do - expect { subject.execute('--version') }.should raise_error(RdiffSimple::NotInstalledError) + it 'should raise an exception' do + expect { subject.execute('--version') }.to raise_error(RdiffSimple::NotInstalledError) end end end describe '#installed?' do context 'when rdiff-backup is installed' do - before(:each) do - mock_rdiff_installed(true) - end + before { mock_rdiff_installed :yes } - it 'should be true' do - subject.installed?.should be_true - end + it { should be_installed } end context 'when rdiff-backup is not installed' do - before(:each) do - mock_rdiff_installed(false) - end + before { mock_rdiff_installed :no } - it 'should be false' do - subject.installed?.should be_false - end + it { should_not be_installed } end - end - - def mock_rdiff_installed(value) - subject - .should_receive(:system) - .with('which rdiff-backup') - .and_return(value) end end