diff --git a/README.md b/README.md index 18ca676..4b66bc6 100644 --- a/README.md +++ b/README.md @@ -281,43 +281,46 @@ meant to be able to change with it. ## Example Structure - * - Use only one expectation per example. There are very few scenarios where two - or more expectations in a single `it` block should be used. So, general rule - of thumb is one expectation per `it` block. - [[link](#one-expectation)] + * + For examples two styles are considered acceptable. The first variant + is separate example for each expectation, which comes with a cost of + duplicated context initialization. The second variant is multiple + expectations per example with `aggregate_failures` tag set for a + group or example. Use your best judgement in each case, and apply + your strategy consistently. + [[link](#expectations-per-example)] ```ruby - # bad + # good - one expectation per example describe ArticlesController do #... describe 'GET new' do - it 'assigns new article and renders the new article template' do + it 'assigns a new article' do get :new expect(assigns[:article]).to be_a(Article) + end + + it 'renders the new article template' do + get :new expect(response).to render_template :new end end - - # ... end - # good + # good - multiple expectations with aggregated failures describe ArticlesController do #... - describe 'GET new' do - it 'assigns a new article' do + describe 'GET new', :aggregate_failures do + it 'assigns new article and renders the new article template' do get :new expect(assigns[:article]).to be_a(Article) - end - - it 'renders the new article template' do - get :new expect(response).to render_template :new end end + + # ... end ```