Exception: Spectre::Failure

Inherits:
StandardError
  • Object
show all
Defined in:
lib/spectre.rb

Overview

The failure class containing information about spec failures created by assert and expect.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, call_stack = nil) ⇒ Failure

Constructs a new Failure instance with the given message and determines the file and line from the given call stack



132
133
134
135
136
137
# File 'lib/spectre.rb', line 132

def initialize message, call_stack = nil
  super(message)

  @file, @line = get_call_location(call_stack || caller_locations)
  @message = message
end

Instance Attribute Details

#fileObject (readonly)

The file path where the failure occured



125
126
127
# File 'lib/spectre.rb', line 125

def file
  @file
end

#lineObject (readonly)

The line where the failure occured



127
128
129
# File 'lib/spectre.rb', line 127

def line
  @line
end

#messageObject (readonly)

A message describing the failure



123
124
125
# File 'lib/spectre.rb', line 123

def message
  @message
end

Instance Method Details

#to_sObject

:nodoc:



140
141
142
# File 'lib/spectre.rb', line 140

def to_s
  "#{@message} - in #{@file}:#{@line}"
end