🕷 zenspider.com

by ryan davis



sitemap
Looking for the Ruby Quickref?

Before You Monkeypatch... Communicate!

Published 2012-07-11 @ 14:25

Tagged thoughts, minitest

I semi-recently found a CI system that has … shall we say… dubious integration. I came across it because a co-worker of mine was trying to do something similar for an in-house project:

co-worker: I was trying to make something similar to this:
           http://caldersphere.rubyforge.org/ci_reporter/
zenspider: unfamiliar... sec
zenspider: oh god
zenspider: that integration is crazy

But you see… there’s already a huge difference. My co-worker had submitted a pull request to minitest trying to make his life easier. His proposed changes were the wrong way to go, but it got the ball rolling. In other words, he was communicating. This gave us the chance to reach some clarity:

zenspider: let's back up
zenspider: just list me the data you want to record
co-worker: [suite name, method name, assertion count, test time, result]
co-worker: it's basically an output formatter
zenspider: for every test, regardless of result?
co-worker: yes
zenspider: *nod* ... ok. lemme poke

In the end, I made a small change to minitest, and as a result his code looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
  class CiUnit < Unit
    after_tests do
      MiniTest::Ci.finish self.output
    end

    def record suite, method, assertions, time, error
      MiniTest::Ci.push suite, method, assertions, time, error
      super
    end
  end

# ...

MiniTest::Unit.runner = MiniTest::CiUnit.new

See how easy it is to make your own code cleaner and more maintainable? You just have to communicate.