Hi all,

We have a Rails 5.1 app and we recently wanted to use system tests. 
However, upon adding them I noticed various weird-behaving issues like 
segfaults and stuff.

I suspect that this has to do with the fact that in system tests, a Ruby 
server (i.e. puma) is spawned in a thread, that has access to the same code 
that our tests use. In that case, what happens if our app is not 
thread-safe? Do Rails apps (their code + the gems they use) have to be 
thread-safe in order to use the system tests feature?

For example, in our app we have the following pattern, which I believe is 
not threadsafe:

module Drivers
  # this method is used by all of our application code that needs to access 
elasticsearch, so that we maintain a single connection.
  # But it's also used inside our tests, so that we truncate data 
before/after specific test cases

  def self.elasticsearch
    @es ||= Elastic::Client.new
  end
end

So if the above method is accessed in a system test by both the server test 
(i.e. application code executed by puma) and the test code concurrently, it 
could result to subtle bugs. Is my understanding correct?

P.S. For the record, we use rspec with capybara and webrick as the server.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/c0114da9-1771-44a7-8d14-6450b6aac629%40googlegroups.com.

Reply via email to