rspec给出的错误`Then`在示例中不可用(例如``it`块)

时间:2015-10-06 05:11:48

标签: ruby-on-rails ruby ruby-on-rails-4 rspec rspec-rails

我正在使用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块)中或在示例范围内运行的构造(例如itbefore等)中不可用。它仅适用于示例组(例如letdescribe块)。

context

1 个答案:

答案 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,只能在itThen数据块中使用describe

因此,要解决您的问题,只需使用context代替context

it

查看更多examples here