Class: CodeDrivenDevelopment::Rule::ConstantMethodCall

Inherits:
AbstractRule
  • Object
show all
Defined in:
lib/code_driven_development/rule/constant_method_call.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
7
8
# File 'lib/code_driven_development/rule/constant_method_call.rb', line 4

def capable?
  code.sexp_type == :call &&
    method_name != :validate &&
    receiver_type == :const
end

#testObject



10
11
12
13
14
# File 'lib/code_driven_development/rule/constant_method_call.rb', line 10

def test
  test_context.befores << "allow(#{receiver_value}).to receive :#{method_name}"
  body = ["expect(#{receiver_value}).to have_received :#{method_name}"]
  test_context << TestComponent::Test.new("calls #{receiver_value}.#{method_name}", body)
end