这是完全愚蠢和不重要的,但我只是好奇:使用RSpec,我可以以某种方式访问我在范围内的“深度”?这是...有没有办法在RSpec中获取当前的作用域级别?
describe SomeClass do
describe "#some_method" do
context "within some context" do
it "is possible, what I'm asking" do
# Actually, I'm not entirely sure what I'd expect this
# value to be... basically, whatever the RSpec designers
# felt made sense.
mysterious_method_to_get_depth.should == 3
end
end
end
end
实际上,我问,因为我要输出一些有用的信息,但以这样的方式,测试输出仍然是最大读取(即与适当的缩进)。
我不不认为它是直接的*可能的,但你可以检查这个'调用者'回溯并找出它。 – d11wtq