Sha256: 67ca3d30d692d604fe2e133307a3070b3e7f9cd3f5723a56cadd294c80dde8a6

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require "pathname"

# Load stuff.
[
  "lib/**/*.rb",
].each do |fmask|
  Dir["./#{fmask}"].each do |fn|
    ##puts "-- req '#{fn}'"
    require fn
  end
end

# TODO: When this becomes a gem, use gem instead of direct copy.
module RSpec
  module PrintOnFailure
    module Helpers
      # Output <tt>message</tt> before the failed tests in <tt>block</tt>. Useful when input and expected data
      # are defined as collections.
      #
      #   sets = [
      #     ["hello", "HELLO"],
      #     ["123", "456"],
      #   ]
      #
      #   sets.each do |input, expected|
      #     print_on_failure("-- input:'#{input}'") do
      #       input.upcase.should == expected
      #     end
      #   end
      def print_on_failure(message, &block)
        begin
          yield
        rescue Exception
          # Catch just everything, report and then re-run. The test may fail due to an exception, not necessarily unmatched expectation.
          puts message
          yield
        end
      end
    end
  end
end

begin
  # 2.x.
  RSpec.configure do |config|
    config.include ::RSpec::PrintOnFailure::Helpers
  end
rescue NameError
  # 1.3.
  Spec::Runner.configure do |config|
    config.include ::RSpec::PrintOnFailure::Helpers
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hack_tree-0.1.0 spec/spec_helper.rb