Browse files

Merge pull request #327 from burns/fix_cycler_keep

Cycler should typcast value of Storage#keep
  • Loading branch information...
2 parents 4ff1a01 + 58ec636 commit f23f9c84d256dce51d9021e3fc54b4e643f844c9 @mrrooijen mrrooijen committed Jul 23, 2012
Showing with 10 additions and 2 deletions.
  1. +1 −1 lib/backup/storage/cycler.rb
  2. +9 −1 spec/storage/cycler_spec.rb
View
2 lib/backup/storage/cycler.rb
@@ -25,7 +25,7 @@ def cycle!(storage, package)
# for the storage and sets the @packages_to_remove
def update_storage_file!
packages = yaml_load.unshift(@package)
- excess = packages.count - @storage.keep
+ excess = packages.count - @storage.keep.to_i
@packages_to_remove = (excess > 0) ? packages.pop(excess) : []
yaml_save(packages)
end
View
10 spec/storage/cycler_spec.rb
@@ -26,13 +26,21 @@
describe 'update_storage_file!' do
before do
- storage.stubs(:keep).returns(2)
cycler.instance_variable_set(:@storage, storage)
cycler.instance_variable_set(:@package, package)
cycler.instance_variable_set(:@storage_file, storage_file)
end
it 'should remove entries and set @packages_to_remove' do
+ storage.stubs(:keep).returns(2)
+ cycler.expects(:yaml_load).in_sequence(s).returns([pkg_a, pkg_b, pkg_c])
+ cycler.expects(:yaml_save).in_sequence(s).with([package, pkg_a])
+ cycler.send(:update_storage_file!)
+ cycler.instance_variable_get(:@packages_to_remove).should == [pkg_b, pkg_c]
+ end
+
+ it 'should typecast the value of keep' do
+ storage.stubs(:keep).returns('2')
cycler.expects(:yaml_load).in_sequence(s).returns([pkg_a, pkg_b, pkg_c])
cycler.expects(:yaml_save).in_sequence(s).with([package, pkg_a])
cycler.send(:update_storage_file!)

0 comments on commit f23f9c8

Please sign in to comment.