Sha256: 47fd6fd172196e502b4bf96a4b178510f653937b73567d44c8cf1be04c93bffc
Contents?: true
Size: 838 Bytes
Versions: 1
Compression:
Stored size: 838 Bytes
Contents
require "spec_helper" require "tmpdir" require "daily_weekly_monthly/cleaner" describe DailyWeeklyMonthly::Cleaner do let(:backups_dir) { Dir.mktmpdir } let(:ext) { "txt" } subject { described_class.new backups_dir, ext } describe "#call" do before do FileUtils.mkdir_p(File.join backups_dir, "weekly") %w(2015 2016 2017 2016 2017 2018 2019 2020).each do |year| File.write File.join(backups_dir, "weekly", "#{year}-01-01.txt"), "some content" end end it "removes all files except the newest N from the target directory" do subject.call "weekly", 2 expect(Dir[File.join(backups_dir, "weekly", "*.#{ext}")].map { |f| File.basename(f) }).to match_array ["2020-01-01.txt", "2019-01-01.txt"] end end after do FileUtils.remove_entry backups_dir end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
daily_weekly_monthly-0.0.2 | spec/daily_weekly_monthly/cleaner_spec.rb |