Module: Busted

Extended by:
Busted
Included in:
Busted
Defined in:
lib/busted.rb,
lib/busted/stack.rb,
lib/busted/tracer.rb,
lib/busted/counter.rb,
lib/busted/version.rb,
lib/busted/profiler.rb,
lib/busted/countable.rb,
lib/busted/traceable.rb,
lib/busted/current_process.rb,
lib/busted/profiler/default.rb,
lib/busted/profiler/sandwich.rb

Defined Under Namespace

Modules: Countable, CurrentProcess, Profiler, Traceable Classes: Counter, Stack, Tracer

Constant Summary collapse

VERSION =
"0.2.3"

Instance Method Summary collapse

Instance Method Details

#cache?(counter = nil, &block) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
33
# File 'lib/busted.rb', line 26

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

#constant_cache?(&block) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/busted.rb', line 39

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

#constant_cache_invalidations(&block) ⇒ Object



22
23
24
# File 'lib/busted.rb', line 22

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

#finish(options = {}) ⇒ Object



14
15
16
# File 'lib/busted.rb', line 14

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

#method_cache?(&block) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/busted.rb', line 35

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

#method_cache_invalidations(&block) ⇒ Object



18
19
20
# File 'lib/busted.rb', line 18

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

#run(options = {}, &block) ⇒ Object



6
7
8
# File 'lib/busted.rb', line 6

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

#start(options = {}) ⇒ Object



10
11
12
# File 'lib/busted.rb', line 10

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