我正在使用rspec-given并继续收到此错误。
失败/错误:然后{
;WITH CTE AS
(
SELECT COLA,COLB
,','+CAST(COLA AS VARCHAR(MAX))+',' AS CHCK
, 1 as lvl FROM #Test WHERE COLA=1
UNION ALL
SELECT C1.COLA,C1.COLB ,C.CHCK+CAST(C1.cola AS VARCHAR(MAX))+','
, c.lvl+1
FROM CTE C INNER JOIN #Test C1 ON C.colb = C1.cola
WHERE CHARINDEX(','+CAST(C.colb AS VARCHAR(MAX))+',',C.CHCK)=0
),
cte2 as (
select * , ROW_NUMBER() over (partition by colb order by lvl)as rn From CTE
)
select cola,colb,lvl from cte2 where rn = 1
在示例(例如Then
块)中或在示例范围内运行的构造(例如it
,before
等)中不可用。它仅适用于示例组(例如let
或describe
块)。
context
答案 0 :(得分:3)
错误消息说明了一切:
Activity
请仔细阅读错误消息。并且您在错误消息本身中有解决方案。
您无法在Then is not available from within an example (e.g. an it block) or from constructs that run in the scope of an example (e.g. before, let, etc). It is only available on an example group (e.g. a describe or context block).
数据块中使用Then
,只能在it
或Then
数据块中使用describe
。
因此,要解决您的问题,只需使用context
代替context
:
it
查看更多examples here。