rubysherpas / paranoia

acts_as_paranoid for Rails 5, 6 and 7
Other
2.89k stars 529 forks source link

paranoia >= 2.5.1 assumes Rails constant is defined #528

Closed lionelchauvin closed 2 years ago

lionelchauvin commented 2 years ago

https://github.com/rubysherpas/paranoia/commit/35721293fe5bad93f31708237dd27cffd4c90a28#diff-a7b13874ca65cce80cfa49aa594d2cbb4a486019b334c831ce0bd5de605f2533R1

This commit checks if Rails.env.test? in order to add rspec matchers but rails is not a dependency of paranoia. Gems that are only dependent on activerecord (and paranoia) crash on this line.

lionelchauvin commented 2 years ago

It could be replaced by: if !(defined? Rails) || Rails.env.test?

or if ENV['RAILS_ENV'] == 'test'

or don't require 'paranoia/rspec' and let developpers do it.

mathieujobin commented 2 years ago

this is merged in core but still not tagged release https://github.com/rubysherpas/paranoia/pull/529