12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/quote_sql/test.rb', line 12
def run(name, all = false)
name = name.to_s.sub(/^test_/, "")
rv = ["๐งช #{name}"]
@expected = nil
@test = send("test_#{name}")
if sql.gsub(/\s+/, "")&.downcase&.strip == expected&.gsub(/\s+/, "")&.downcase&.strip
tables = @test.tables.to_h { [[_1, "table"].compact.join("_"), _2] }
columns = @test.instance_variable_get(:@columns).to_h { [[_1, "columns"].compact.join("_"), _2] }
rv += [@test.original, { **tables, **columns, **@test.quotes }.inspect, "๐ฏ #{expected}", "โ
#{sql}"]
@success << rv if @success
else
rv += [@test.inspect, "๐ฏ #{expected}", "โ #{sql}"]
@fail << rv if @fail
end
rescue => exc
rv += [@test.inspect, "๐ฏ #{expected}", "โ #{sql}", exc.message]
@fail << rv if @fail
ensure
STDOUT.puts(*rv) unless @fail or @success
end
|