Sha256: acabc34ef0b18435ffce5806ea4348fcb698ef6634b186e874e6c10011f479d9

Contents?: true

Size: 1015 Bytes

Versions: 16

Compression:

Stored size: 1015 Bytes

Contents

# This file is called when a cypress spec fails and allows for extra logging to be captured
filename = command_options.fetch('runnable_full_title', 'no title').gsub(/[^[:print:]]/, '')

# grab last lines until "APPCLEANED" (Make sure in clean.rb to log the text "APPCLEANED")
system "tail -n 10000 -r log/#{Rails.env}.log | sed \"/APPCLEANED/ q\" | sed 'x;1!H;$!d;x' > 'log/#{filename}.log'"

# create a json debug file for server debugging
json_result = {}
json_result['error'] = command_options.fetch('error_message', 'no error message')

if defined?(ActiveRecord::Base)
  json_result['records'] =
    ActiveRecord::Base.descendants.each_with_object({}) do |record_class, records|
      begin
        records[record_class.to_s] = record_class.limit(100).map(&:attributes)
      rescue
      end
    end
end

filename = command_options.fetch('runnable_full_title', 'no title').gsub(/[^[:print:]]/, '')
File.open("#{Rails.root}/log/#{filename}.json", "w+") do |file|
  file << JSON.pretty_generate(json_result)
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
cypress-on-rails-1.11.0 lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/log_fail.rb
cypress-on-rails-1.10.1 lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/log_fail.rb
cypress-on-rails-1.9.1 lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/log_fail.rb
cypress-on-rails-1.9.0 lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/log_fail.rb
cypress-on-rails-1.8.1 lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/log_fail.rb
cypress-on-rails-1.8.0 lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/log_fail.rb
cypress-on-rails-1.7.0 lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/log_fail.rb
cypress-on-rails-1.6.0 lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/log_fail.rb
cypress-on-rails-1.5.1 lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/log_fail.rb
cypress-on-rails-1.5.0 lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/log_fail.rb
cypress-on-rails-1.4.2 lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/log_fail.rb
cypress-on-rails-1.4.1 lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/log_fail.rb
cypress-on-rails-1.4.0 lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/log_fail.rb
cypress-on-rails-1.3.0 lib/generators/cypress_dev/templates/spec/cypress/app_commands/log_fail.rb
cypress-on-rails-1.2.1 lib/generators/cypress_dev/templates/spec/cypress/app_commands/log_fail.rb
cypress-on-rails-1.2.0 lib/generators/cypress_dev/templates/spec/cypress/app_commands/log_fail.rb