webmock icon indicating copy to clipboard operation
webmock copied to clipboard

Patron name clash with business entity

Open pedrocarmona opened this issue 1 year ago • 2 comments

If an application has a table patrons and a model Patron, then it causes webmock not to work, because it checks if Patron is defined. Because Patron is defined, it fails with uninitialized constant Patron::Session

# lib/webmock/http_lib_adapters/patron_adapter.rb
begin
  require 'patron'
rescue LoadError
  # patron not found
end

if defined?(::Patron) # <<<--- replace this?

pedrocarmona avatar Jun 20 '24 13:06 pedrocarmona

maybe replace with?

if defined?(::Patron) && defined?(::Patron::Session) 

pedrocarmona avatar Jun 20 '24 13:06 pedrocarmona

@pedrocarmona thanks for explaining the issue.

I believe if defined?(::Patron::Session) should be enough, there is no need to check for if defined?(::Patron) && defined?(::Patron::Session)

bblimke avatar Jun 21 '24 20:06 bblimke