Rspec 如何访问正在描述的对象?
如果我有如下示例:Rspec 如何访问正在描述的对象?,rspec,Rspec,如果我有如下示例: 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 如何访问所描述的字符串对象“通量电容器”? 我尝试了一些“描述类型”和“描述类”的排列 例如: 但这些总是一无所获。我做错了什么 谢谢, -Bill这可能不是最好的方法,但您可以尝试: ex
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
如何访问所描述的字符串对象“通量电容器”?
我尝试了一些“描述类型”和“描述类”的排列
例如:
但这些总是一无所获。我做错了什么
谢谢,
-Bill这可能不是最好的方法,但您可以尝试:
example\u group\u hierarchy.last.description
它应该返回“父”示例组的描述,作为字符串连接。当前示例的描述只是描述
如果要获取描述数组,请执行以下操作:
example\u group\u hierarchy.last.nested\u说明
我只是在控制台中玩了一下才发现这一点,所以使用时请自行承担风险
self.described_type.to_s