spec/compressor/gzip_spec.rb in backup-3.0.26 vs spec/compressor/gzip_spec.rb in backup-3.0.27
- old
+ new
@@ -69,24 +69,24 @@
describe 'deprecations' do
describe 'fast and best options' do
context 'when only the fast option is used' do
before do
- Backup::Logger.expects(:warn).with(
- instance_of(Backup::Errors::ConfigurationError)
- )
+ Backup::Logger.expects(:warn).with {|err|
+ err.should be_an_instance_of Backup::Errors::ConfigurationError
+ err.message.should match(
+ /Use Gzip#level instead/
+ )
+ }
end
context 'when set to true' do
it 'should log a warning and set `level` to 1' do
- Backup::Logger.expects(:warn).with(
- "Backup::Compressor::Gzip.level is being set to '1'"
- )
compressor = Backup::Compressor::Gzip.new do |c|
c.fast = true
end
- compressor.level.should be(1)
+ compressor.level.should == 1
end
end
context 'when set to false' do
it 'should only log a warning' do
@@ -98,24 +98,24 @@
end
end
context 'when only the best option is used' do
before do
- Backup::Logger.expects(:warn).with(
- instance_of(Backup::Errors::ConfigurationError)
- )
+ Backup::Logger.expects(:warn).with {|err|
+ err.should be_an_instance_of Backup::Errors::ConfigurationError
+ err.message.should match(
+ /Use Gzip#level instead/
+ )
+ }
end
context 'when set to true' do
it 'should log a warning and set `level` to 1' do
- Backup::Logger.expects(:warn).with(
- "Backup::Compressor::Gzip.level is being set to '9'"
- )
compressor = Backup::Compressor::Gzip.new do |c|
c.best = true
end
- compressor.level.should be(9)
+ compressor.level.should == 9
end
end
context 'when set to false' do
it 'should only log a warning' do
@@ -128,40 +128,31 @@
end
context 'when both fast and best options are used' do
before do
- Backup::Logger.expects(:warn).twice.with(
- instance_of(Backup::Errors::ConfigurationError)
- )
+ Backup::Logger.expects(:warn).twice.with {|err|
+ err.should be_an_instance_of Backup::Errors::ConfigurationError
+ err.message.should match(
+ /Use Gzip#level instead/
+ )
+ }
end
context 'when both are set true' do
context 'when fast is set first' do
it 'should cause the best option to be set' do
- Backup::Logger.expects(:warn).with(
- "Backup::Compressor::Gzip.level is being set to '1'"
- )
- Backup::Logger.expects(:warn).with(
- "Backup::Compressor::Gzip.level is being set to '9'"
- )
compressor = Backup::Compressor::Gzip.new do |c|
c.fast = true
c.best = true
end
compressor.level.should == 9
end
end
context 'when best is set first' do
it 'should cause the fast option to be set' do
- Backup::Logger.expects(:warn).with(
- "Backup::Compressor::Gzip.level is being set to '1'"
- )
- Backup::Logger.expects(:warn).with(
- "Backup::Compressor::Gzip.level is being set to '9'"
- )
compressor = Backup::Compressor::Gzip.new do |c|
c.best = true
c.fast = true
end
compressor.level.should == 1
@@ -170,51 +161,39 @@
end
context 'when only one is set true' do
context 'when fast is set true before best' do
it 'should cause the fast option to be set' do
- Backup::Logger.expects(:warn).with(
- "Backup::Compressor::Gzip.level is being set to '1'"
- )
compressor = Backup::Compressor::Gzip.new do |c|
c.fast = true
c.best = false
end
compressor.level.should == 1
end
end
context 'when fast is set true after best' do
it 'should cause the fast option to be set' do
- Backup::Logger.expects(:warn).with(
- "Backup::Compressor::Gzip.level is being set to '1'"
- )
compressor = Backup::Compressor::Gzip.new do |c|
c.best = false
c.fast = true
end
compressor.level.should == 1
end
end
context 'when best is set true before fast' do
it 'should cause the best option to be set' do
- Backup::Logger.expects(:warn).with(
- "Backup::Compressor::Gzip.level is being set to '9'"
- )
compressor = Backup::Compressor::Gzip.new do |c|
c.best = true
c.fast = false
end
compressor.level.should == 9
end
end
context 'when best is set true after fast' do
it 'should cause the best option to be set' do
- Backup::Logger.expects(:warn).with(
- "Backup::Compressor::Gzip.level is being set to '9'"
- )
compressor = Backup::Compressor::Gzip.new do |c|
c.fast = false
c.best = true
end
compressor.level.should == 9