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: 7 additions & 0 deletions lib/dotenv/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ module Dotenv
class Rails < ::Rails::Railtie
delegate :files, :files=, :overwrite, :overwrite=, :autorestore, :autorestore=, :logger, to: "config.dotenv"

# The documented options are configured on the class, which Rails only supports through
# `Railtie.method_missing`. Define them explicitly so they show up in `.methods`, have a
# source location, and don't depend on that forwarding.
class << self
delegate :files, :files=, :overwrite, :overwrite=, :autorestore, :autorestore=, :logger, :logger=, to: :instance
end

def initialize
super
config.dotenv = ActiveSupport::OrderedOptions.new.update(
Expand Down
11 changes: 11 additions & 0 deletions spec/dotenv/rails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@
end
end

describe "options" do
it "are defined on the class and delegate to the instance" do
expect(Dotenv::Rails.singleton_class.instance_methods).to include(
:files, :files=, :overwrite, :overwrite=, :autorestore, :autorestore=, :logger, :logger=
)

Dotenv::Rails.overwrite = true
expect(Dotenv::Rails.instance.overwrite).to be(true)
end
end

it "watches other loaded files with Spring" do
stub_spring(load_watcher: true)
application.initialize!
Expand Down