before(:context) 范围界定是否进入儿童上下文? [英] Does before(:context) scoping go into children contexts?

查看:38
本文介绍了before(:context) 范围界定是否进入儿童上下文?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以下代码示例中,before 块 是否在父上下文和子上下文之前运行,因此运行了 3 次?

In the following code sample, is the before block run before both the parent and the subcontexts and therefore 3 times?

或者只是父母,因此是 1 次?

Or just the parent and therefore 1 time?

即范围有多深?

    describe "my spec class" do

       before(:context) do
           do stuff
       end



       context "parent context" do
          context "subcontext" do
            stuff...
          end 

         context "subcontext" do
            stuff.....
         end
       end

感谢您的帮助.

推荐答案

它应该在组中的所有示例之前运行一次.并可通过嵌套上下文访问.几个值得一看的链接:

It should run once before all examples in the group. And accessible by the nested contexts. A couple links worth checking out:

嵌套上下文

挂钩前后

这篇关于before(:context) 范围界定是否进入儿童上下文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆