Exception: TestBench::Controls::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/test_bench/controls/error.rb

Defined Under Namespace

Classes: BacktraceLocation

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(backtrace_locations) ⇒ Error

Returns a new instance of Error.



50
51
52
# File 'lib/test_bench/controls/error.rb', line 50

def initialize backtrace_locations
  @backtrace_locations = backtrace_locations
end

Instance Attribute Details

#backtrace_locationsObject (readonly)

Returns the value of attribute backtrace_locations.



48
49
50
# File 'lib/test_bench/controls/error.rb', line 48

def backtrace_locations
  @backtrace_locations
end

Class Method Details

.backtrace_locationsObject



24
25
26
27
28
29
30
# File 'lib/test_bench/controls/error.rb', line 24

def self.backtrace_locations
  [
    BacktraceLocation.new(file, line, method_name),
    BacktraceLocation.new(file, line + 1, method_name),
    BacktraceLocation.new(file, line + 2, method_name),
  ]
end

.exampleObject



4
5
6
# File 'lib/test_bench/controls/error.rb', line 4

def self.example
  new backtrace_locations
end

.fileObject



8
9
10
# File 'lib/test_bench/controls/error.rb', line 8

def self.file
  Path.example
end

.lineObject



12
13
14
# File 'lib/test_bench/controls/error.rb', line 12

def self.line
  1
end

.messageObject



16
17
18
# File 'lib/test_bench/controls/error.rb', line 16

def self.message
  'Some error'
end

.method_nameObject



20
21
22
# File 'lib/test_bench/controls/error.rb', line 20

def self.method_name
  'some_method'
end

Instance Method Details

#backtraceObject



54
55
56
# File 'lib/test_bench/controls/error.rb', line 54

def backtrace
  backtrace_locations.map(&:to_s)
end

#to_sObject



58
59
60
# File 'lib/test_bench/controls/error.rb', line 58

def to_s
  self.class.message
end