Sha256: 153ccf13691f46de68ac5a76b3e7c9e66c2b149b398ef6305c4d1fb887083a90

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

# https://raw.githubusercontent.com/metric_fu/metric_fu/master/spec/capture_warnings.rb
require 'rubygems' if RUBY_VERSION =~ /^1\.8/
require 'bundler/setup'
require 'rspec/core'
require 'rspec/expectations'
require 'tempfile'

stderr_file = Tempfile.new("metric_fu.stderr")
current_dir = Dir.pwd

RSpec.configure do |config|

  config.before(:suite) do
    $stderr.reopen(stderr_file.path)
    $VERBOSE = true
  end

  config.after(:suite) do
    stderr_file.rewind
    lines = stderr_file.read.split("\n").uniq
    stderr_file.close!

    $stderr.reopen(STDERR)

    metric_fu_warnings, other_warnings = lines.partition { |line| line.include?(current_dir) }

    if metric_fu_warnings.any?
      puts
      puts "-" * 30 + " metric_fu warnings: " + "-" * 30
      puts
      puts metric_fu_warnings.join("\n")
      puts
      puts "-" * 75
      puts
    end

    if other_warnings.any?
      File.open('tmp/warnings.txt', 'w') { |f| f.write(other_warnings.join("\n")) }
      puts
      puts "Non-metric_fu warnings written to tmp/warnings.txt"
      puts
    end

    # fail the build...
    raise "Failing build due to metric_fu warnings" if metric_fu_warnings.any?
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
metric_fu-4.11.2 spec/capture_warnings.rb
metric_fu-4.11.1 spec/capture_warnings.rb
metric_fu-4.11.0 spec/capture_warnings.rb