if I have rspec like this
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
How can I get "Foo.Sub-Foo should Bar" inside the test context at // test go here?
It is similar to format with specdocs, but how to get it inside itself?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With