class FileSystemCleaner
Usage:
RSpec.configure do |config|
fs_cleaner = FileSystemCleaner.new( Rails.root.join("public", "system", "test", "files"), Rails.root.join("tmp", "files.bak") ) config.before(:each) { fs_cleaner.save_files!(example) } config.after(:each) { fs_cleaner.restore_files!(example) }
end
Attributes
backup_location[R]
filesystem_under_test[R]
Public Class Methods
new(filesystem_under_test, backup_location)
click to toggle source
# File lib/filesystem_cleaner.rb, line 19 def initialize filesystem_under_test, backup_location @filesystem_under_test = filesystem_under_test @backup_location = backup_location end
Public Instance Methods
restore_files!(example)
click to toggle source
# File lib/filesystem_cleaner.rb, line 29 def restore_files!(example) return unless should_perform?(example) `rsync -a --delete #{backup_location}/ #{filesystem_under_test}/` end
save_files!(example)
click to toggle source
# File lib/filesystem_cleaner.rb, line 24 def save_files!(example) return unless should_perform?(example) `rsync -a #{filesystem_under_test}/ #{backup_location}` end
Private Instance Methods
should_perform?(example)
click to toggle source
# File lib/filesystem_cleaner.rb, line 36 def should_perform?(example) example.metadata[:file] end