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.