Skip to content

Commit

Permalink
[users_spec.rb] Fix test order failures
Browse files Browse the repository at this point in the history
If the `authentication_spec.rb` is run before the `user_spec.rb`, it can
set the `TokenStore.token_caches` to a particular value ("sql" in
particular) that doesn't match what is required for the test (based on
the `session_store` value), and causes the tests to fail.

By clearing the `TokenStore.token_caches` value before an after each
test, we avoid this failure.

The test failures can be reproduced in the previous commit with the
following rspec command:

  $ bundle exec rspec --order defined spec/requests/authentication_spec.rb:253 spec/requests/users_spec.rb:633
  • Loading branch information
NickLaMuro committed Jul 16, 2021
1 parent cdb9cc2 commit e5bc44c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions spec/requests/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,11 @@
# Keep this outside of the loop below with the `let` providing the value
# for the stub, otherwise it will not work as expected
stub_settings_merge(:server => {:session_store => session_store_value})
TokenStore.token_caches.clear
end

after { TokenStore.token_caches.clear }

%w[cache sql memory].each do |session_store|
let(:session_store_value) { session_store }

Expand Down

0 comments on commit e5bc44c

Please sign in to comment.