From 5c9f4fcc71c4ad760fd7dbc13b43c71fcdca69e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Glauco=20Cust=C3=B3dio?= Date: Thu, 17 Oct 2024 10:01:07 +0100 Subject: [PATCH] improve shared example guideline --- _includes/dont_use_shared_examples.html | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/_includes/dont_use_shared_examples.html b/_includes/dont_use_shared_examples.html index 8700a52..40bc1f4 100644 --- a/_includes/dont_use_shared_examples.html +++ b/_includes/dont_use_shared_examples.html @@ -9,13 +9,18 @@

{% highlight ruby %} -shared_examples 'a normal dog' do +shared_examples 'a barking animal' do it { is_expected.to be_able_to_bark } end describe Dog do - subject { described_class.new(able_to_bark?: true) } - it_behaves_like 'a normal dog' + subject { described_class.new(able_to_bark: true) } + it_behaves_like 'a barking animal' +end + +describe Fox do + subject { described_class.new(able_to_bark: true) } + it_behaves_like 'a barking animal' end {% endhighlight %}
@@ -25,7 +30,17 @@

describe Dog do describe '#able_to_bark?' do it 'barks' do - subject = described_class.new(able_to_bark?: true) + subject = described_class.new(able_to_bark: true) + + expect(subject.able_to_bark?).to eq(true) + end + end +end + +describe Fox do + describe '#able_to_bark?' do + it 'barks' do + subject = described_class.new(able_to_bark: true) expect(subject.able_to_bark?).to eq(true) end