From my understanding of AAA - arrange act assert, it is important to make it clear what code is for arranging, acting and asserting.
When testing a complex scenario, I am used to having multiple times the same action, every test. The arranging changes, and so does the assertion. But the action remains the same.
Recently I have encountered this code:
before do
post 'somewhere'
end
it 'creates something' do
expect 'something'.to be true
end
And I am not sure if this is a good practice. Arranging code gets in the middle of action and assertion when, for instance, we add contexts.
before do
post 'somewhere'
end
[ some tests ]
context 'when a more complex scenario applies' do
before do
[more complex arrangements]
end
it 'creates something more complex' do
expect 'something'.to be true
end
end
Is it a good practice to DRY these actions?