A new bug is discovered by a customer, but you have no idea when it was introduced into the codebase. Wouldn't it be cool to be able to write a test and see when the bug was first introduced?
RubySuperBlame takes your failing test and steps back through git commits until your test is passing. It then tells you the commit that broke it and the diff of the changes. Now you have cause and effect and should be able to fix it more easily!
Currently supports git and rspec. Very proof of concept, very pre-ALPHA, be CAREFUL!
Not intended to be bundled with an app, just install it:
$ gem install ruby_super_blame
In the directory of your ruby codebase, create an encapsulated test in a gitignored directory. It'd be a good idea to make sure you're on master and have no pending changes.
$ git checkout master $ ruby_super_blame run -t tmp/fib_temp_spec.rb
It will quickly spin through commits until it finds the one which first broke that test. Then it spits out:
Running.... Initially broken on commit: cd46921fefefa5163846c46ca5b863fb091dcf30, by some of these changes: diff --git a/fibonacci.rb b/fibonacci.rb index 4260e15..15fb306 100644 --- a/fibonacci.rb +++ b/fibonacci.rb @@ -3,7 +3,7 @@ class Fibonacci def fib(n) if n == 0 - return 0 + return 10 elsif n == 1 return 1 else
Showing when I intentionally broke my fibonacci function.
Normally in a spec I'd write:
But this causes a caching issue where even though your files are changing from the git checkouts, they are not seen by the test. For now, you can instead write:
I'll find a systematic way around this, but for now it's necessary.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request