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
7ab5e7a
commit 0a2cf09
Showing
4 changed files
with
51 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<article> | ||
<h2 id="instance-double-over-double"> | ||
<a href="#instance-double-over-double"> | ||
Instance double over double | ||
</a> | ||
</h2> | ||
|
||
<p>Instance double ensures the object responds to methods being called, which is not true for double.</p> | ||
|
||
<div class="example"> | ||
{% highlight ruby %} | ||
class User | ||
def full_name | ||
"#{first_name} #{last_name}" | ||
end | ||
end | ||
{% endhighlight %} | ||
</div> | ||
|
||
<div class="bad"> | ||
{% highlight ruby %} | ||
it "passes" do | ||
user = double(:user, name: "Ayrton Senna") | ||
puts user.name | ||
end | ||
{% endhighlight %} | ||
</div> | ||
|
||
<div class="good"> | ||
{% highlight ruby %} | ||
it "fails" do | ||
user = instance_double(User, name: "Ayrton Senna") | ||
puts user.name | ||
end | ||
{% endhighlight %} | ||
</div> | ||
|
||
<p>The above test will fail with the following message since the <code>name</code> method really doesn't exist.</p> | ||
|
||
<div class="output"> | ||
{% highlight text %} | ||
the User class does not implement the instance method: name. Perhaps you meant to use `class_double` instead? | ||
{% endhighlight %} | ||
</div> | ||
</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