如果我有这样的 rspec
describe 'Foo' do
# init go here
describe 'Sub-Foo' do
it "should Bar" do
# test go here
# puts ... <-- need "Foo.Sub-Foo should Bar" here
end
end
end
如何在 // test go here 的测试上下文中获取“Foo.Sub-Foo should Bar”?
它与specdocs 的格式类似,但如何将其放入自身内部?
RSpec.describe 'Foo' do
describe 'Sub-Foo' do
# NOTE: `self.` context is also available within subject { } block
it 'should Bar' do |example|
expect(self.class.description).to eq('Sub-Foo')
expect(example.description).to eq('should Bar')
expect(self.class.top_level_description).to eq('Foo')
end
end
end
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)