Rspec Before/After All/Each order of operation

I’m using Rspec for testing. I’m seeking confirmation of the
following, that the way it is laid out is how it is supposed to
function. Rspec is supposed to test the inner describe Before(:all)
before it tests the outer describe before(:each). I can see how it
should be that way, in that the inner Before(:all) is probably more
important to the inner describe function than the outer
before(:each). It just feels a little un-intuitive that way. I just
want to make sure that is exactly as planned. Thanks for your time.

describe ClassNameHere,‘Outer test wrapper’ do

before(:all) do # (01)
puts ‘(1) First in operation’
end

before(:each) do
puts ‘(3) Third in operation’
end

after(:each) do
puts ‘(4) Fourth in operation’
end

after(:all) do
puts ‘(5) Last in operation - cleanup my mess’
end

describe ‘Inner test wrapper #1’ do
before(:all) do
puts ‘(2a) Second operation’
end
end

describe ‘Inner test wrapper #2’ do
before(:all) do
puts ‘(2b) I got here - no tmp’
end
end

end

maybe repost to the rspec group? They’re usually quite responsive.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs