Sha256: c06e21a9507533392af57b01a42db92e90da0239a8b47746c44bfe0dea4710b2

Contents?: true

Size: 522 Bytes

Versions: 3

Compression:

Stored size: 522 Bytes

Contents

# http://blog.ardes.com/2006/12/11/testing-singletons-with-ruby
#
# Allows unit testing of a Singleton, resetting state between each test
# MySingleton.restart_instance
#
require 'singleton'
puts "SINGLETON TESTING"
class << Singleton
  def included_with_reset(klass)
    included_without_reset(klass)
    class << klass
      def reset_instance
        Singleton.send :__init__, self
        self
      end
    end
  end
  alias_method :included_without_reset, :included
  alias_method :included, :included_with_reset
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
itrigga-cache-1.1.0 support/singleton_reset.rb
itrigga-cache-0.3.0 support/singleton_reset.rb
itrigga-cache-0.2.1 support/singleton_reset.rb