test/capture_warnings.rb in cheap_ams-0.10.5 vs test/capture_warnings.rb in cheap_ams-0.10.6
- old
+ new
@@ -1,17 +1,17 @@
# https://raw.githubusercontent.com/metric_fu/metric_fu/master/spec/capture_warnings.rb
-require "tempfile"
-require "fileutils"
+require 'tempfile'
+require 'fileutils'
class CaptureWarnings
def initialize(fail_on_warnings = true)
@fail_on_warnings = fail_on_warnings
- @stderr_file = Tempfile.new("app.stderr")
+ @stderr_file = Tempfile.new('app.stderr')
@app_root ||= Dir.pwd
- @output_dir = File.join(app_root, "tmp")
+ @output_dir = File.join(app_root, 'tmp')
FileUtils.mkdir_p(output_dir)
- @bundle_dir = File.join(app_root, "bundle")
+ @bundle_dir = File.join(app_root, 'bundle')
end
def before_tests
$stderr.reopen(stderr_file.path)
$VERBOSE = true
@@ -38,20 +38,21 @@
#{'-' * 75}
WARNINGS
end
if other_warnings.any?
- File.write(File.join(output_dir, "warnings.txt"), other_warnings.join("\n") << "\n")
+ File.write(File.join(output_dir, 'warnings.txt'), other_warnings.join("\n") << "\n")
puts
- puts "Non-app warnings written to tmp/warnings.txt"
+ puts 'Non-app warnings written to tmp/warnings.txt'
puts
end
# fail the build...
if fail_on_warnings && app_warnings.any?
abort "Failing build due to app warnings: #{app_warnings.inspect}"
end
end
private
+
attr_reader :stderr_file, :app_root, :output_dir, :bundle_dir, :fail_on_warnings
end