问题
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?
回答1:
describe 'Foo' do
describe 'Sub-Foo' do
it "should Bar" do |example|
puts "#{self.class.description} #{example.description}"
end
end
end
The above code prints out "Foo Sub-Foo should Bar".
来源:https://stackoverflow.com/questions/1518264/how-to-get-current-context-name-of-rspec