class FileLoadError
Represents an error that occurred while loading a test file.
Definitions
def self.build(parent, path, error)
Build a new FileLoadError.
Signature
-
parameter
parentObject The parent context.
-
parameter
pathString The path to the file that failed to load.
-
parameter
errorException The error that occurred.
-
returns
FileLoadError A new FileLoadError instance.
Implementation
def self.build(parent, path, error)
identity = Identity.file(parent.identity, path)
# This is a mess.
if error.is_a?(SyntaxError) and error.path == path
identity = identity.with_line(error.lineno)
else
identity = identity.scoped(error.backtrace_locations)
end
self.new(identity, path, error)
end
def initialize(identity, path, error)
Initialize a new FileLoadError.
Signature
-
parameter
identityIdentity The identity where the error occurred.
-
parameter
pathString The path to the file.
-
parameter
errorException The error that occurred.
Implementation
def initialize(identity, path, error)
@identity = identity
@path = path
@error = error
end
attr :identity
Signature
-
attribute
Identity The identity where the error occurred.
attr :error
Signature
-
attribute
Exception The error that occurred.
def leaf?
Signature
-
returns
Boolean Always returns true, as errors are leaf nodes.
Implementation
def leaf?
true
end
EMPTY = Hash.new.freeze
An empty hash used for children.
def children
Signature
-
returns
Hash Always returns an empty hash.
Implementation
def children
EMPTY
end
def description
Signature
-
returns
String The file path.
Implementation
def description
@path
end
def print(output)
Print a representation of this error.
Signature
-
parameter
outputOutput The output target.
Implementation
def print(output)
output.write("file ", :path, @identity)
end
def call(assertions)
Execute this error, recording it in assertions.
Signature
-
parameter
assertionsAssertions The assertions instance.
Implementation
def call(assertions)
assertions.nested(self, identity: @identity, isolated: true) do |assertions|
assertions.error!(@error)
end
end