🕷 software projects

by ryan davis



Drop into the ruby debugger on a failed assertion.

This is a stupid simple example of how easy it is to make a minitest plugin that does something useful. In this case it wraps assert so that failed assertions will drop into the ruby debugger.

Features & Problems

  • Failed assertions drop into the debugger.
  • Unhandled exceptions already drop into the debugger.


Add this to the top of your test file or helper:

require 'minitest/debugger' if ENV['DEBUG']

Then run your tests as normal but define DEBUG=1:

% DEBUG=1 rake test 
Emacs support available.

Run options: --seed 27343

# Running tests:

.Assertion Failed. Dropping into debugger now:
(rdb:1) up 2
#3 example.rb:18:in `test_assert_failure'
(rdb:1) l
[13, 22] in example.rb
   13    def wrong
   14      24
   15    end
   17    def test_assert_failure
=> 18      assert_equal 42, wrong
   19    end
   21    def bad
   22      raise "no"

Get The Code

If you just want to use minitest-debugger, you can install it via RubyGems:
gem install minitest-debugger
Fork me on GitHub If you want to hack on minitest-debugger, clone it from GitHub:
git clone git://github.com/seattlerb/minitest-debugger

Latest Activity