I just hit a case which I think will interest the community at large.

Did you know it is possible to conditionnaly define methods ? Something like this is quite possible:

1 class Player < User
2   if 'test' == RAILS_ENV then
3     # Conditional method definition to ease testing
4     def play_in(tournament, final_score)
5       ...
6     end
7   end
8 end

Is that a code smell, or is it a really useful feature ? I can’t decide…

The method defined above removes three lines of code from each of the tests where my players play in a tournament. And since this is what the site is about, I think I just slashed a few hundred lines of code from my functional and integration tests. That is not trivial.


Your Host

A picture of me

I am François Beausoleil, a Ruby on Rails and Scala developer. During the day, I work on Seevibes, a platform to measure social interactions related to TV shows. At night, I am interested many things. Read my biography.

Top Tags

Books I read and recommend


Projects I work on

Projects I worked on