Module: Onceler::AmbitiousHelpers

Defined in:
lib/onceler/ambitious_helpers.rb

Instance Method Summary collapse

Instance Method Details

#before_once?(type) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/onceler/ambitious_helpers.rb', line 3

def before_once?(type)
  super || type == :each || type.nil?
end

#let(name, &block) ⇒ Object



7
8
9
# File 'lib/onceler/ambitious_helpers.rb', line 7

def let(name, &block)
  let_once(name, &block)
end

#let!(name, &block) ⇒ Object

remove auto-before’ing of ! methods, since we memoize our own way



17
18
19
# File 'lib/onceler/ambitious_helpers.rb', line 17

def let!(name, &block)
  let(name, &block)
end

#method_added(method_name) ⇒ Object

make sure we have access to subsequently added methods when recording (not just ‘lets’). note that this really only works for truly functional methods with no external dependencies. e.g. methods that add stubs or set instance variables will not work while recording



30
31
32
33
34
35
36
37
# File 'lib/onceler/ambitious_helpers.rb', line 30

def method_added(method_name)
  return if method_name == @current_let_once
  onceler = onceler(:create)
  proxy = onceler.helper_proxy ||= new
  onceler.helper_methods[method_name] ||= Proc.new do |*args|
    proxy.send method_name, *args
  end
end

#subject(name = nil, &block) ⇒ Object

TODO NamedSubjectPreventSuper



12
13
14
# File 'lib/onceler/ambitious_helpers.rb', line 12

def subject(name = nil, &block)
  subject_once(name, &block)
end

#subject!(name = nil, &block) ⇒ Object



21
22
23
# File 'lib/onceler/ambitious_helpers.rb', line 21

def subject!(name = nil, &block)
  subject(name, &block)
end