therubyworkshop/stumble_score — pull request #3 by roryokane (2012-04-28 21:50:31+00:00)
Title: prevented reinitializing constants by setting LOADED variable

This fix is similar to how you fix this problem in C++. It’s probably not the best way. What I really want is something like PHP’s require_once, but I’m not sure how to do that in Ruby. Another similar existing tools is config/initializers in Rails, and sinatra-initializers (https://github.com/chadwpry/sinatra-initializers), but then it would initialize those constants outside of the tests, too, which is not ideal.

The possible future fix might also relate to the encapsulation of the `require File.expand_path` pattern into some kind of require_relative_path method.

A possible slight improvement would be to require ActiveSupport’s active_support/core_ext/kernel/reporting.rb and use suppress to suppress only a NameError, not any error.