Skip to content

Commit

Permalink
improve shared example guideline
Browse files Browse the repository at this point in the history
  • Loading branch information
glaucocustodio committed Oct 17, 2024
1 parent 72c1f60 commit 7cfb941
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions _includes/dont_use_shared_examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ <h2 id="dont-use-shared-examples">

<div class="bad">
{% highlight ruby %}
shared_examples 'a normal dog' do
it { is_expected.to be_able_to_bark }
shared_examples 'a barking animal' do
it 'barks' do
expect(animal.able_to_bark?).to eq(true)
end
end

describe Dog do
subject { described_class.new(able_to_bark?: true) }
it_behaves_like 'a normal dog'
let(:animal) { described_class.new(able_to_bark: true) }
it_behaves_like 'a barking animal'
end

describe Fox do
let(:animal) { described_class.new(able_to_bark: true) }
it_behaves_like 'a barking animal'
end
{% endhighlight %}
</div>
Expand All @@ -25,7 +32,17 @@ <h2 id="dont-use-shared-examples">
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
Expand Down

0 comments on commit 7cfb941

Please sign in to comment.