Today I've stumbled upon a tricky issue with Ruby constants. In our team someone created a module, which is included into multiple models. In our (spec) test output this results into warning messages such as:
/home/ayrton/project/lib/life_cycle.rb:5: warning: already initialized constant RESET
One way to solve this is, is to declare your constants like this:
module LifeCycle
unless (const_defined?(:RESET))
RESET = 'reset'
end
#...
end
I've also read a blog post, written by Avdi Grimm, which provides an alternative solution, I was wondering what your opinions are, regarding this matter.