Sha256: b9e0f5b57792edde871cdf77f99dd0e298647667d4eba4aec05f2acac0776484

Contents?: true

Size: 909 Bytes

Versions: 1

Compression:

Stored size: 909 Bytes

Contents

class ExceptionState
  attr_reader :description, :describe, :it, :exception

  def initialize(state, location, exception)
    @exception = exception

    @description = location ? "An exception occurred during: #{location}" : ""
    if state
      @description << "\n" unless @description.empty?
      @description << state.description
      @describe = state.describe
      @it = state.it
    else
      @describe = @it = ""
    end
  end

  def failure?
    @exception.is_a? ExpectationNotMetError
  end

  def message
    if @exception.message.empty?
      "<No message>"
    elsif @exception.class == ExpectationNotMetError
      @exception.message
    else
      "#{@exception.class}: #{@exception.message}"
    end
  end

  def backtrace
    begin
      return @exception.awesome_backtrace.show
    rescue Exception
      return @exception.backtrace && @exception.backtrace.join("\n")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mspec-1.2.0 lib/mspec/runner/exception.rb