Sha256: 0b5c28fdb6f880f55f2aa4f07cb55cba9947a9c36eed7aad16d3923e5d240f2c

Contents?: true

Size: 742 Bytes

Versions: 62

Compression:

Stored size: 742 Bytes

Contents

##############################################################################
#                            Singleton Plugin
##############################################################################

RSpec.configure do |config|
  config.around(:each, :singletons => lambda { |v| !!v }) do |example|
    require 'singleton'

    options             = example.metadata[:singletons]
    options             = options.is_a?(TrueClass) ? subject.class : options
    singletons_to_reset = options.respond_to?(:each) ? options : [options]

    singletons_to_reset.each do |singleton|
      Singleton.__init__(singleton)
    end

    example.run

    singletons_to_reset.each do |singleton|
      Singleton.__init__(singleton)
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
rspectacular-0.62.0 lib/rspectacular/plugins/singleton.rb
rspectacular-0.61.0 lib/rspectacular/plugins/singleton.rb
rspectacular-0.60.0 lib/rspectacular/plugins/singleton.rb
rspectacular-0.59.0 lib/rspectacular/plugins/singleton.rb
rspectacular-0.58.0 lib/rspectacular/plugins/singleton.rb
rspectacular-0.57.0 lib/rspectacular/plugins/singleton.rb
rspectacular-0.56.0 lib/rspectacular/plugins/singleton.rb
rspectacular-0.55.0 lib/rspectacular/plugins/singleton.rb
rspectacular-0.54.0 lib/rspectacular/plugins/singleton.rb
rspectacular-0.53.1 lib/rspectacular/plugins/singleton.rb
rspectacular-0.53.0 lib/rspectacular/plugins/singleton.rb
rspectacular-0.52.0 lib/rspectacular/plugins/singleton.rb
rspectacular-0.51.0 lib/rspectacular/plugins/singleton.rb
rspectacular-0.50.0 lib/rspectacular/plugins/singleton.rb
rspectacular-0.49.0 lib/rspectacular/plugins/singleton.rb
rspectacular-0.48.0 lib/rspectacular/plugins/singleton.rb
rspectacular-0.47.0 lib/rspectacular/plugins/singleton.rb
rspectacular-0.46.0 lib/rspectacular/plugins/singleton.rb
rspectacular-0.45.0 lib/rspectacular/plugins/singleton.rb
rspectacular-0.44.0 lib/rspectacular/plugins/singleton.rb