Sha256: 06abd493f6deaa9c4f78ffa099e53725f52828dc562d67500bc2ecdd04cd613a

Contents?: true

Size: 886 Bytes

Versions: 4

Compression:

Stored size: 886 Bytes

Contents

require "busted/profiler"

module Busted
  extend self

  def run(options = {}, &block)
    Profiler.run options, &block
  end

  def start(options = {})
    Profiler.run({ profiler: :sandwich, action: :start }.merge options)
  end

  def finish(options = {})
    Profiler.run({ profiler: :sandwich, action: :finish }.merge options)
  end

  def method_cache_invalidations(&block)
    run(&block)[:invalidations][:method]
  end

  def constant_cache_invalidations(&block)
    run(&block)[:invalidations][:constant]
  end

  def cache?(counter = nil, &block)
    total = if counter
              send :"#{counter}_cache_invalidations", &block
            else
              run(&block)[:invalidations].values.inject :+
            end
    total > 0
  end

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
busted-0.2.3 lib/busted.rb
busted-0.2.2 lib/busted.rb
busted-0.2.1 lib/busted.rb
busted-0.2.0 lib/busted.rb