Skip to content

Commit

Permalink
Use safe load to test with ruby 3.1/newer psych
Browse files Browse the repository at this point in the history
  • Loading branch information
jrafanie committed Jan 12, 2024
1 parent 1a6f6b3 commit b3f5f86
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ namespace :spec do

def connection_spec
require 'yaml'
@connection_spec ||= YAML.load_file(File.join(__dir__, %w[config database.yml]))
@connection_spec ||= begin
if YAML.respond_to?(:safe_load)
YAML.safe_load(File.read(File.join(__dir__, %w[config database.yml])), :aliases => true)
else
YAML.load_file(File.join(__dir__, %w[config database.yml]))
end
end
end

def test_database_name
Expand Down
6 changes: 5 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,9 @@
puts "\e[93mUsing ActiveRecord #{ActiveRecord.version}\e[0m"

require 'yaml'
connection_spec = YAML.load_file(File.join(__dir__, %w[.. config database.yml]))
if YAML.respond_to?(:safe_load)
YAML.safe_load(File.read(File.join(__dir__, %w[.. config database.yml])), :aliases => true)
else
YAML.load_file(File.join(__dir__, %w[.. config database.yml]))
end
ActiveRecord::Base.establish_connection(connection_spec["test"])

0 comments on commit b3f5f86

Please sign in to comment.