2009-10-05 12 views
18

wenn ich rspec wie dieseWie erhält man den aktuellen Kontextnamen von 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 

Wie kann ich hier bei // Test innerhalb der Test Kontext "Foo.Sub-Foo sollte Bar" gehen?

Es ähnelt dem Format mit specdocs, aber wie bekommt man es in sich?

Antwort

22
describe 'Foo' do 
    describe 'Sub-Foo' do 
     it "should Bar" do 
     puts "#{self.class.description} #{description}" 
     end 
    end 
end 

Der obige Code druckt "Foo Sub-Foo sollte Bar".

+0

Es ist was ich suche. Danke – Jirapong

+3

# {Beschreibung) funktioniert nicht für mich. –

Verwandte Themen