开发者

How do I get access to object being described?

If I have an example such as the following:

describe "A flux capacitor" do
  it "should flux a lot" do
  # how can I access the string object "A flux capacitor" in here???
  ...
  end
end

How can I access the described string object "A flux capacitor"? I've tried a few permutations of 'described_type' and 'described_class' Such as:

self.described_type.to_s

But these always return nothing. What am I doing wron开发者_StackOverflow社区g?

Thanks, -Bill


This may not be the best way, but you can try:

example_group_hierarchy.last.description

which should return the descriptions of the "parent" example groups, concatenated as a string. The current example's description is just description.

If you want to get an array of descriptions:

example_group_hierarchy.last.nested_descriptions

I just found this by playing around in the console, so use at your own risk.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜