Sha256: 6f2099bed8ee715c8fdbed1fc528c2b51571667b1ac4b033bb06db810bdf60e1

Contents?: true

Size: 640 Bytes

Versions: 1

Compression:

Stored size: 640 Bytes

Contents

require "busted/version"

module Busted
  extend self

  def cache?(serial = nil, &blk)
    starting = count serial
    yield
    ending = count serial
    ending > starting
  end

  def method_cache?(&blk)
    cache? :method, &blk
  end

  def constant_cache?(&blk)
    cache? :constant, &blk
  end

  def class_cache?(&blk)
    cache? :class, &blk
  end

  private

  def count(serial)
    stat = RubyVM.stat
    case serial
    when :method
      stat[:method_serial]
    when :constant
      stat[:constant_serial]
    when :class
      stat[:class_serial]
    else
      stat[:method_serial] + stat[:constant_serial]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
busted-0.0.1 lib/busted.rb