Skip to content

Commit e416e5e

Browse files
committed
Change default to write yaml since json can't write some objects
I was seeing Infinity trying to be written to file...
1 parent 88f7972 commit e416e5e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

cypress/e2e/app_commands/log_fail.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
# Alternative command if the above does not work
77
# system "tail -n 10000 log/#{Rails.env}.log | tac | sed \"/APPCLEANED/ q\" | sed 'x;1!H;$!d;x' > 'log/#{filename}.log'"
88

9-
# create a json debug file for server debugging
10-
json_result = {}
11-
json_result['error'] = command_options.fetch('error_message', 'no error message')
9+
# create a yaml debug file for server debugging
10+
result = {}
11+
result['error'] = command_options.fetch('error_message', 'no error message')
1212

1313
if defined?(ActiveRecord::Base)
14-
json_result['records'] =
14+
result['records'] =
1515
ActiveRecord::Base.descendants.each_with_object({}) do |record_class, records|
1616
begin
1717
records[record_class.to_s] = record_class.limit(100).map(&:attributes)
@@ -21,6 +21,8 @@
2121
end
2222

2323
filename = command_options.fetch('runnable_full_title', 'no title').gsub(/[^[:print:]]/, '')
24-
File.open("#{Rails.root}/log/#{filename}.json", "w+") do |file|
25-
file << JSON.pretty_generate(json_result)
24+
yml_filename = Rails.root.join("log", "#{filename}.yml")
25+
File.open(yml_filename, "w+") do |file|
26+
file.write(Psych.dump(result))
2627
end
28+
$sterr.puts ("!!! Wrote #{yml_filename}")

0 commit comments

Comments
 (0)