Skip to content

Commit

Permalink
Pick "only needed data" rule from betterspecs
Browse files Browse the repository at this point in the history
  • Loading branch information
andreareginato authored and pirj committed Nov 7, 2018
1 parent 35ed5e0 commit da28811
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,23 @@ meant to be able to change with it.
subject(:article) { FactoryBot.create(:some_article) }
```
* <a name="needed-data"></a>
Do not load more data than needed to test your code.
<sup>[[link](#needed-data)]</sup>
```ruby
# good
RSpec.describe User do
describe ".top" do
subject { described_class.top(2) }
before { FactoryBot.create_list(:user, 3) }
it { is_expected.to have(2).items }
end
end
```
* <a name="doubles"></a>
Use mocks and stubs with caution. While they help to improve the performance
of the test suite, you can mock/stub yourself into a false-positive state very
Expand Down

0 comments on commit da28811

Please sign in to comment.