Sha256: 2030d922d242bacdcccc7b8e4442cc7f45147a79f27348a9ab13cb8a7798412e

Contents?: true

Size: 784 Bytes

Versions: 15

Compression:

Stored size: 784 Bytes

Contents

if ENV["RSPEC_REPORT_EXCEPTIONS"]
  class Exception
    alias_method :old_initialize, :initialize

    def self.exceptions_seen
      @@seen ||= {}
    end

    def self.see args
      stack = caller[1..-1]
      # Don't show expected exceptions or RSpec internal ones
      return if caller.detect{|s| s =~ %r{rspec/matchers/raise_error}} or
	self.name =~ /^RSpec::/
      stack.reject!{|s| s =~ %r{/rspec/}}
      key = stack[0,4]+[self.name]
      return if exceptions_seen[key]

      exceptions_seen[key] = show = stack
      args[0] = args[0].to_str if args[0].class.name == "NameError::message"
      puts "#{self.name}#{args.inspect}:\n\t#{show*"\n\t"}"
    end

    def initialize *args, &b
      self.class.see args

      send(:old_initialize, *args, &b)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
activefacts-api-1.8.1 spec/support/reduce_exceptions_helper.rb
activefacts-api-1.8.0 spec/support/reduce_exceptions_helper.rb
activefacts-api-1.7.1 spec/support/reduce_exceptions_helper.rb
activefacts-api-1.7.0 spec/support/reduce_exceptions_helper.rb
activefacts-api-1.6.0 spec/support/reduce_exceptions_helper.rb
activefacts-api-1.5.0 spec/support/reduce_exceptions_helper.rb
activefacts-api-1.4.0 spec/support/reduce_exceptions_helper.rb
activefacts-api-1.3.1 spec/support/reduce_exceptions_helper.rb
activefacts-api-1.3.0 spec/support/reduce_exceptions_helper.rb
activefacts-api-1.1.0 spec/support/reduce_exceptions_helper.rb
activefacts-api-1.0.0 spec/support/reduce_exceptions_helper.rb
activefacts-api-0.9.9 spec/support/reduce_exceptions_helper.rb
activefacts-api-0.9.8 spec/support/reduce_exceptions_helper.rb
activefacts-api-0.9.7 spec/support/reduce_exceptions_helper.rb
activefacts-api-0.9.6 spec/support/reduce_exceptions_helper.rb