Skip to content

Commit

Permalink
Better example of teardown method in test guide
Browse files Browse the repository at this point in the history
rails#18305, thanks for @dhh suggestion
  • Loading branch information
kirs committed Jan 3, 2015
1 parent cf87cfe commit ef7274b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions guides/source/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -753,10 +753,8 @@ class ArticlesControllerTest < ActionController::TestCase

# called after every single test
def teardown
# as we are re-initializing @article before every test
# setting it to nil here is not essential but I hope
# you understand how you can use the teardown method
@article = nil
# when controller is using cache it may be a good idea to reset it afterwards
Rails.cache.clear
end

test "should show article" do
Expand Down

0 comments on commit ef7274b

Please sign in to comment.