bblimke / webmock

Library for stubbing and setting expectations on HTTP requests in Ruby.
MIT License
3.96k stars 555 forks source link

Patron name clash with business entity #1059

Open pedrocarmona opened 2 months ago

pedrocarmona commented 2 months ago

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 commented 2 months ago

maybe replace with?

if defined?(::Patron) && defined?(::Patron::Session) 
bblimke commented 2 months ago

@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)