Skip to content

Commit

Permalink
add redundant require article
Browse files Browse the repository at this point in the history
  • Loading branch information
glaucocustodio committed Aug 6, 2024
1 parent 2bec6d2 commit 7c4597c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
5 changes: 4 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
title: Even Better Specs
description: Guidelines for readable and maintainable tests
description: Guidelines for maintainable tests
theme: just-the-docs

url: https://evenbetterspecs.github.io
Expand Down Expand Up @@ -42,6 +42,9 @@ nav_external_links:
- title: Expect vs should
url: "#expect-vs-should"
hide_icon: true
- title: Redundant require
url: "#redundant-require"
hide_icon: true
- title: Instance double over double
url: "#instance-double-over-double"
hide_icon: true
Expand Down
35 changes: 35 additions & 0 deletions _includes/redundant_require.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<article>
<h2 id="redundant-require">
<a href="#redundant-require">
Redundant require
</a>
</h2>

<p>Avoid redundant <code>require</code> in your spec files. Use <code>.rspec</code> file instead.</p>

<div class="bad">
{% highlight ruby %}
# spec/models/user_spec.rb
require 'rails_helper'

describe User do
end
{% endhighlight %}
</div>

<div class="good">
{% highlight ruby %}
# spec/models/user_spec.rb
describe User do
end
{% endhighlight %}
</div>

<div class="good">
{% highlight ruby %}
# .rspec
--require rails_helper
{% endhighlight %}
</div>

</article>
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ <h2>
{% include all_possible_cases.html %}
{% include request_vs_controller.html %}
{% include expect_vs_should.html %}
{% include redundant_require.html %}
{% include instance_double_over_double.html %}
{% include lets_not.html %}
{% include avoid_hooks.html %}
Expand Down

0 comments on commit 7c4597c

Please sign in to comment.