6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/test_bench/session/controls/exception/raise.rb', line 6
def self.call(exception_class, exception_message, relative: nil)
apex_directory = Path::ApexDirectory::Create.()
if Exception.const_defined?(:SomeNamespace)
Exception.send(:remove_const, :SomeNamespace)
end
file_1 = Controls::Path::File::Create.(" \#{Controls::Exception}::SomeNamespace.module_exec { def self.some_method = raise \#{exception_class}, \#{exception_message.inspect}, caller_locations(0, 4) }\n RUBY\n\n file_2 = Controls::Path::File::Create.(<<~RUBY, basename: 'some-file', apex_directory:, relative:)\n module \#{Controls::Exception}::SomeNamespace\n def self.some_other_method = some_method\n end\n RUBY\n\n file_3 = Controls::Path::File::Create.(<<~RUBY, basename: 'some-other-file', apex_directory:, relative:)\n module \#{Controls::Exception}\n module SomeNamespace\n def self.yet_another_method = some_other_method\n end\n end\n RUBY\n\n file_4 = Controls::Path::File::Create.(<<~RUBY, basename: 'some-other-file', subdirectory: :none, apex_directory:, relative:)\n \#{[file_3, file_2, file_1].inspect}.each { |file| load file }\n\n module \#{Controls::Exception}::SomeNamespace\n def self.origin = yet_another_method; origin\n end\n RUBY\n\n ::Dir.chdir(apex_directory) do\n load file_4\n end\n\nensure\n Path::ApexDirectory::Remove.(apex_directory)\nend\n", subdirectory: :none, apex_directory:, relative:)
|