我正在我的Rails应用程序中测试电子邮件的文本部分,并且有一个测试文本的工具。夹具不是UPDATE TABLE_A A SET
A.COL1 = (
SELECT B.COL_BX
FROM TABLE_B B
WHERE B.P1 = A.P1 -- Reference back to the updating table's column
),
A.COL2 = (
SELECT D.COL_DY
FROM TABLE_C C INNER JOIN TABLE_D D
ON C.H1 = D.H1
WHERE C.P1 = A.P1 -- Reference back to the updating table's column
-- Would this act as a join between A and C (not implementation-wise but rather functionality)?
),
A.COL3 = (
SELECT G.COL_GZ
FROM TABLE_E E INNER JOIN TABLE_F F
ON E.N1 = F.N1
OUTER JOIN TABLE_G G
ON G.M1 = F.M1
WHERE E.P1 = A.P1
AND E.P2 = A.P2
-- AND (bunch of other predicate for G columns)
); -- There are more columns to be updated but omitted for brevity
文件,因为它只是要测试的文本。但是,电子邮件包含当年(例如2010-2018),我试图查看是否可以在该文本固定装置中使用erb,以便可以测试电子邮件而不必每年进行更新。
这是我当前使用文本文件的方式:
文本文件
.yml
测试文件:
...
Copyright 2006-2018
答案 0 :(得分:2)
使用rails固定装置时,可以将ERB与YAML固定装置混合使用(无需在文件名中添加“ erb”扩展名):
# fixtere_name.yml
one:
column: <%= DateTime.now %>
使用自己的灯具或类似文件时,可以手动执行红宝石零件。例如:
# fixtere.txt
some text <%= DateTime.now.year %>
# load this fixture
fixture = ERB.new File.read("path/to/fixture.txt"), nil, "%"
fixture.result(binding) # => "some text 2018\n"