generated from just-the-docs/just-the-docs-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7c4180
commit ac08109
Showing
15 changed files
with
146 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<article> | ||
<h2 id="leverage-described-class"> | ||
<a href="#leverage-described-class"> | ||
Leverage described class | ||
</a> | ||
</h2> | ||
|
||
<p>Tests are not supposed to be DRY, but that doesn't mean we need to repeat ourselves in vain. Leverage <code>described_class</code> to make your tests maintainable over time.</p> | ||
|
||
<div class="bad"> | ||
{% highlight ruby %} | ||
describe Pilot do | ||
describe '.most_successful' do | ||
it 'returns the most successful pilot' do | ||
senna = create(:pilot, name: 'Ayrton Senna') | ||
create(:pilot, name: 'Alain Prost') | ||
create(:race, winner: senna) | ||
|
||
most_successful_pilot = Pilot.most_successful | ||
|
||
expect(most_successful_pilot.name).to eq('Ayrton Senna') | ||
end | ||
end | ||
end | ||
{% endhighlight %} | ||
</div> | ||
|
||
|
||
<div class="good"> | ||
{% highlight ruby %} | ||
describe Pilot do | ||
describe '.most_successful' do | ||
it 'returns the most successful pilot' do | ||
senna = create(:pilot, name: 'Ayrton Senna') | ||
create(:pilot, name: 'Alain Prost') | ||
create(:race, winner: senna) | ||
|
||
most_successful_pilot = described_class.most_successful | ||
|
||
expect(most_successful_pilot.name).to eq('Ayrton Senna') | ||
end | ||
end | ||
end | ||
{% endhighlight %} | ||
</div> | ||
|
||
|
||
<p>If the class <code>Pilot</code> ever gets renamed, one just need to change it at the top level <code>describe</code>.</p> | ||
</article> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.