Skip to content

Commit

Permalink
Fix leaky test
Browse files Browse the repository at this point in the history
This test was changing the user of Person and affecting other tests.
We need to reset the user after the test has run.
  • Loading branch information
rafaelfranca committed Jan 7, 2022
1 parent a0ddb80 commit 640b538
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Expand Up @@ -15,6 +15,8 @@ gem "rubocop-packaging"
gem "rubocop-performance"
gem "rubocop-rails"

gem "minitest-bisect"

gemspec

platform :mri do
Expand Down
3 changes: 3 additions & 0 deletions test/cases/base_test.rb
Expand Up @@ -306,6 +306,7 @@ def test_user_reader_uses_superclass_user_until_written
# Superclass is Object so returns nil.
assert_nil ActiveResource::Base.user
assert_nil Class.new(ActiveResource::Base).user
person_user = Person.user
Person.user = "anonymous".dup

# Subclass uses superclass user.
Expand Down Expand Up @@ -338,6 +339,8 @@ def test_user_reader_uses_superclass_user_until_written

fruit.user = "client"
assert_equal fruit.user, apple.user, "subclass did not adopt changes from parent class"
ensure
Person.user = person_user
end

def test_password_reader_uses_superclass_password_until_written
Expand Down

0 comments on commit 640b538

Please sign in to comment.