Skip to content

Instantly share code, notes, and snippets.

@garmoshka-mo
Created October 6, 2019 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garmoshka-mo/aab3ddce4d47faa0a5a7afa22587e8f8 to your computer and use it in GitHub Desktop.
Save garmoshka-mo/aab3ddce4d47faa0a5a7afa22587e8f8 to your computer and use it in GitHub Desktop.
def error(msg)
hide_from_stack = true
Print.error "😱 #{msg}"
binding.pry if $launched_specs_examples < 2
raise msg
end
def shit!(msg)
hide_from_stack = true
Print.error "💩 #{msg}"
raise msg if $launched_specs_examples > 1
binding.pry
nil
end
Object.class_eval do
def method_missing(method, *args)
debug_missing_methods = (
$launched_specs_examples <= 1 and
$debug_missing_methods and
not method.to_s.start_with?("to_") and
not [RubyVM::InstructionSequence].include?(self) and
not PryMoves.open? and
not caller[0].match PryMoves::Backtrace::filter
)
if debug_missing_methods
hide_from_stack = true
err = "😱 \e[31mMethod \e[1m#{method}\e[0m\e[31m "+
"missing for \e[1m#{self.class} #{self}\e[0m"
STDERR.puts err.ljust(80, ' ')
# HINT: when pry failed to start use: caller.reverse
binding.pry
raise err
end
super
end
def self.const_missing(name)
super
rescue => e
hide_from_stack = true
message = "😱 \e[31m#{e.to_s}\e[0m"
STDERR.puts message.ljust(80, ' ')
binding.pry
raise
end
end unless defined?(Rails) and Rails.env.production?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment