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
|
# File 'lacci/lib/scarpe/niente/shoes_spec.rb', line 9
def self.run_shoes_spec_test_code(code, class_name: nil, test_name: nil)
if @shoes_spec_init
raise Shoes::Errors::MultipleShoesSpecRunsError, "Niente can only run a single Shoes spec per process!"
end
@shoes_spec_init = true
require "scarpe/components/minitest_export_reporter"
Minitest::Reporters::ShoesExportReporter.activate!
class_name ||= ENV["SHOES_MINITEST_CLASS_NAME"] || "TestShoesSpecCode"
test_name ||= ENV["SHOES_MINITEST_METHOD_NAME"] || "test_shoes_spec"
Shoes::DisplayService.subscribe_to_event("heartbeat", nil) do
unless @hb_init
Minitest.run []
Shoes.APPS.each(&:destroy)
end
@hb_init = true
end
test_class = Class.new(Niente::ShoesSpecTest)
Object.const_set(Scarpe::Components::StringHelpers.camelize(class_name), test_class)
test_name = "test_" + test_name unless test_name.start_with?("test_")
test_class.define_method(test_name) do
eval(code)
end
end
|