Class: CodeDrivenDevelopment::Rule::InstanceMethod

Inherits:
AbstractRule
  • Object
show all
Defined in:
lib/code_driven_development/rule/instance_method.rb

Instance Method Summary collapse

Methods inherited from AbstractRule

#initialize

Constructor Details

This class inherits a constructor from CodeDrivenDevelopment::Rule::AbstractRule

Instance Method Details

#capable?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/code_driven_development/rule/instance_method.rb', line 4

def capable?
  code.sexp_type == :defn
end

#testObject



8
9
10
11
12
13
14
15
16
# File 'lib/code_driven_development/rule/instance_method.rb', line 8

def test
  new_context = TestComponent::Context.new(%Q("##{method_name}"))
  recurse(method_body, new_context)
  test_context << new_context

  # Do this last so that the method invocation is the last line in the before.
  new_context.subject = "obj.#{method_name}"
  new_context.lets << TestComponent::Let.new(:obj, "described_class.new")
end