Skip to content

Commit 3118840

Browse files
authored
Merge branch 'testdouble:main' into nw-rails-7-1
2 parents f25dd4d + 73db6b9 commit 3118840

6 files changed

Lines changed: 24 additions & 5 deletions

File tree

lib/test_data/config.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require_relative "./yaml_loader"
2+
13
module TestData
24
def self.config(pwd: Rails.root, &blk)
35
@configuration ||= Configuration.new(pwd: pwd)
@@ -95,7 +97,7 @@ def after_rails_fixture_load(callable = nil, &blk)
9597
end
9698

9799
def database_yaml
98-
YAML.load_file(database_yaml_full_path)
100+
YAMLLoader.load_file(database_yaml_full_path)
99101
end
100102

101103
def database_name

lib/test_data/configurators/cable_yaml.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require_relative "../yaml_loader"
2+
13
module TestData
24
module Configurators
35
class CableYaml
@@ -8,7 +10,7 @@ def initialize
810

911
def verify
1012
if !File.exist?(@config.cable_yaml_full_path) ||
11-
YAML.load_file(@config.cable_yaml_full_path).key?("test_data")
13+
YAMLLoader.load_file(@config.cable_yaml_full_path).key?("test_data")
1214
ConfigurationVerification.new(looks_good?: true)
1315
else
1416
ConfigurationVerification.new(problems: [

lib/test_data/configurators/secrets_yaml.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require_relative "../yaml_loader"
2+
13
module TestData
24
module Configurators
35
class SecretsYaml
@@ -8,7 +10,7 @@ def initialize
810

911
def verify
1012
if !File.exist?(@config.secrets_yaml_full_path) ||
11-
YAML.load_file(@config.secrets_yaml_full_path).key?("test_data")
13+
YAMLLoader.load_file(@config.secrets_yaml_full_path).key?("test_data")
1214
ConfigurationVerification.new(looks_good?: true)
1315
else
1416
ConfigurationVerification.new(problems: [

lib/test_data/dumps_database.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def prepend_set_replication_role!(data_dump_path)
8080

8181
def log_size_info_and_warnings(before_size:, after_size:)
8282
percent_change = percent_change(before_size, after_size)
83-
TestData.log.info " Size: #{to_size(after_size)}#{" (#{percent_change}% #{before_size > after_size ? "decrease" : "increase"})" if percent_change}"
83+
TestData.log.info " Size: #{to_size(after_size)}#{" (#{percent_change}% #{(before_size > after_size) ? "decrease" : "increase"})" if percent_change}"
8484
if after_size > 5242880
8585
TestData.log.warn " WARNING: file size exceeds 5MB. Be sure to only persist what data you need to sufficiently test your application"
8686
end

lib/test_data/wrap/webpacker_config.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require_relative "../yaml_loader"
2+
13
module TestData
24
module Wrap
35
class WebpackerConfig
@@ -34,7 +36,7 @@ def required_entries_missing_from_test_data_config
3436
private
3537

3638
def load_yaml(path)
37-
YAML.load_file(path)
39+
YAMLLoader.load_file(path)
3840
rescue
3941
end
4042
end

lib/test_data/yaml_loader.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module TestData
2+
module YAMLLoader
3+
def self.load_file(path)
4+
begin
5+
YAML.load_file(path, aliases: true)
6+
rescue ArgumentError
7+
YAML.load_file(path)
8+
end
9+
end
10+
end
11+
end

0 commit comments

Comments
 (0)