Is there any way to reduce the amount of output provided by Ruby when there's an error?
For example:
rspec bowling_spec.rb
/Users/snowcrash/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- bowling (LoadError)
from /Users/snowcrash/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/snowcrash/Developer/Code/Ruby/RSpec/bowling_spec.rb:2:in `<top (required)>'
from /Users/snowcrash/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.14.2/lib/rspec/core/configuration.rb:896:in `load'
from /Users/snowcrash/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.14.2/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
from /Users/snowcrash/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.14.2/lib/rspec/core/configuration.rb:896:in `each'
from /Users/snowcrash/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.14.2/lib/rspec/core/configuration.rb:896:in `load_spec_files'
from /Users/snowcrash/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.14.2/lib/rspec/core/command_line.rb:22:in `run'
from /Users/snowcrash/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.14.2/lib/rspec/core/runner.rb:80:in `run'
from /Users/snowcrash/.rvm/gems/ruby-2.0.0-p195/gems/rspec-core-2.14.2/lib/rspec/core/runner.rb:17:in `block in autorun'
All I'm interested in is the first line, cannot load such file -- bowling (LoadError)
. Ideally I'd like Ruby to not spit out the rest of the from
lines.
Is this possible?
Do something like this:
module Kernel
at_exit do
case $!
when nil, SystemExit, Interrupt
else puts $!.message, [email protected]
end
$stderr.reopen(IO::NULL)
$stdout.reopen(IO::NULL)
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With