Replies: 2 comments 2 replies
-
Can you create a runnable reproduction script like in https://guides.rubyonrails.org/contributing_to_ruby_on_rails.html#create-an-executable-test-case ? |
Beta Was this translation helpful? Give feedback.
-
Sorry to hear you're running into an issue, transactions are controlled either by Rails or a 3rd party gem like database cleaner, we don't prevent system exit commands however, so you'd have to look at what the (presumedly Rails) hooks do in this scenario. Alternatively you could try raising or failing to quit rather than using exit, or you could catch it yourself in hooks and perform the right cleanup you want including exiting the transaction |
Beta Was this translation helpful? Give feedback.
-
Hi!
I'm using the latest v7.0.1 and running into trouble with records written to DB outside transaction (trying TestProf's AnyFixture).
If I exit RSpec from inside an example either with debugger's
exit
or Pry's!!!
, bothafter(:suite)
andat_exit
hooks report that they're executing inside a transaction -ActiveRecord::Base.connection.transaction_open? #=> true
. This breaks cleanup, because it will be run inside the example's transaction and will never get committed.Can anyone confirm this is indeed the case or maybe I've misconfigured something (other gems could be doing something weird with DB transactions).
Maybe there's a workaround besides not quitting examples? 😄
Edit: I've confirmed the problem to be present even on a vanilla Rails + RSpec project.
Beta Was this translation helpful? Give feedback.
All reactions