通过 Shoulda 单元测试使整个上下文失败
将 shoulda
与 unit/test
结合使用,我有一个上下文,要求在尝试其他测试之前先通过一个测试。
我是否可以调用一种方法,该方法将使当前上下文中的所有后续测试失败?或者甚至不运行它们?
我正在想象这样的事情:(
context "My thing" do
setup do
my_variable = false
end
should "have my_variable as true" do
assert_or_contextflunk my_variable
end
end
显然这是一个毫无意义的例子,但你知道我正在尝试做什么)
Using shoulda
with unit/test
I have a context which requires one test to pass before the others are even tried.
Is there a method I can invoke which will fail all following tests in the current context? Or not even run them?
I'm imagining something like:
context "My thing" do
setup do
my_variable = false
end
should "have my_variable as true" do
assert_or_contextflunk my_variable
end
end
(Obviously this is a pointless example, but you see what I'm trying to do)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将待处理块添加到您的设置方法中。
有关更多信息,请参阅 http://rspec.info/documentation/ 的待处理示例部分。
Add a pending block to your setup method.
See the Pending Examples section of http://rspec.info/documentation/ for further.