Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rspec 如何访问正在描述的对象?_Rspec - Fatal编程技术网

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