1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00
thoughtbot--shoulda-matchers/spec/warnings_spy/filesystem.rb
Elliot Winkler 12cc7aaace Remove all Ruby-emitted warnings
Run RSpec tests with warnings enabled so we stay on top of this better
in the future.
2014-07-18 18:00:08 -06:00

45 lines
811 B
Ruby

require 'fileutils'
class WarningsSpy
class Filesystem
PROJECT_DIR = File.expand_path('../../..', __FILE__)
TEMP_DIR = File.join(PROJECT_DIR, 'tmp')
def initialize
@files_by_name = Hash.new do |hash, name|
FileUtils.mkdir_p(TEMP_DIR)
hash[name] = file_for(name)
end
end
def warnings_file
files_by_name['all_warnings']
end
def irrelevant_warnings_file
files_by_name['irrelevant_warnings']
end
def relevant_warnings_file
files_by_name['relevant_warnings']
end
def project_dir
PROJECT_DIR
end
protected
attr_reader :files_by_name
private
def path_for(name)
File.join(TEMP_DIR, "#{name}.txt")
end
def file_for(name)
File.open(path_for(name), 'w+')
end
end
end