Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/dotenv/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,10 @@ def self.load
config.before_configuration { load }
end

Railtie = ActiveSupport::Deprecation::DeprecatedConstantProxy.new("Dotenv::Railtie", "Dotenv::Rails", Dotenv::Rails.deprecator)
def self.const_missing(name)
super unless name == :Railtie

Rails.deprecator.warn("Dotenv::Railtie is deprecated! Use Dotenv::Rails instead.")
Dotenv::Rails
end
end
16 changes: 16 additions & 0 deletions spec/dotenv/rails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,22 @@
end
end

describe "Dotenv::Railtie deprecation" do
it "returns Dotenv::Rails" do
allow(Dotenv::Rails.deprecator).to receive(:warn) # prevent deprecation warning from being printed in test output
expect(Dotenv::Railtie).to equal(Dotenv::Rails)
end

it "emits a deprecation warning" do
expect(Dotenv::Rails.deprecator).to receive(:warn).with(/Dotenv::Railtie is deprecated/)
Dotenv::Railtie
end

it "does not include :Railtie in Dotenv.constants" do
expect(Dotenv.constants).not_to include(:Railtie)
end
end

def stub_spring(load_watcher: true)
spring = Module.new do
if load_watcher
Expand Down