Skip to content

Commit

Permalink
Fix spec for older rails versions
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeepers committed Feb 26, 2024
1 parent a2e4d91 commit a24f235
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions spec/dotenv/rails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
require "dotenv/rails"

describe Dotenv::Rails do
let(:log_io) { StringIO.new }
let(:log_output) { StringIO.new }
let(:application) do
log_io = self.log_io
log_output = self.log_output
Class.new(Rails::Application) do
config.load_defaults Rails::VERSION::STRING.to_f
config.eager_load = false
config.logger = ActiveSupport::Logger.new(log_io)
config.logger = ActiveSupport::Logger.new(log_output)
config.root = fixture_path

# Remove method fails since app is reloaded for each test
Expand Down Expand Up @@ -201,16 +201,14 @@
end

describe "logger" do
it "defaults to ReplayLogger" do
expect(Dotenv::Rails.logger).to be_a(Dotenv::ReplayLogger)
application.initialize!
expect(Dotenv::Rails.logger).to be_a(ActiveSupport::BroadcastLogger)
end

it "replays to Rails.logger" do
expect(Dotenv::Rails.logger).to be_a(Dotenv::ReplayLogger)
Dotenv::Rails.logger.debug("test")

application.initialize!
expect(log_io.string).to include("test")

expect(Dotenv::Rails.logger).not_to be_a(Dotenv::ReplayLogger)
expect(log_output.string).to include("test")
end
end
end

0 comments on commit a24f235

Please sign in to comment.