Berlin 2008

Manfred Stienstra, 30 Aug 2008, 21:44 in ruby on rails and events (edit).

Eloy and I will be in Berlin Monday through Thursday. We’re not attending RailsConf, but we are meeting up with a small detachment of European Caboosers to hack on projects and have a good time. We’ve rented a big apartment near the conference which we’re using as our HQ.

If you want to meet up or want to discuss anything related to projects we’re working on let us know and we’ll hook up.

5 comments

Aliasing dangerous methods in your tests

Manfred Stienstra, 21 Aug 2008, 11:29 in ruby on rails and testing (edit).

Lately we’ve been aliasing dangerous methods in our tests to make sure we don’t accidentally break something. It’s not very nice when tests delete your favorite episode of Sesame Street or add a MySQL user, so we had a lot of snippets like this laying around:


module Kernel
  mattr_accessor :allow_system
  self.allow_system = false

  alias original_system system

  def self.system(*args)
    if allow_system
      original_system(*args)
    else
      raise RuntimeError, "You're trying to do a system call, which is probably not a very good idea in a test."
    end
  end
end

We refactored it and now we specify the same thing like this:


ActiveResource::Connection.add_allow_switch :request
Kernel.add_allow_switch :system, :default => true

The code is currently included in on_test_spec, our plugin for writing Rails specs on test/spec.

No comments yet