Module: Facon::Baconize::ShouldExtensions

Defined in:
lib/facon/baconize.rb

Overview

Mixin intended for Bacon’s Should class so that we can do mock.should.receive(:message) and mock.should.not.receive(:message).

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



58
59
60
61
62
63
64
65
66
# File 'lib/facon/baconize.rb', line 58

def self.included(base)
  # Remove Facon::Mockable methods we mixed in to Object, since we don't
  # need those in the Should class.
  base.class_eval do
    instance_methods.each do |method|
      undef_method(method) if Facon::Mockable.public_instance_methods.include?(method)
    end
  end
end

Instance Method Details

#receive(method, &block) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/facon/baconize.rb', line 68

def receive(method, &block)
  if @negated
    @object.mock_proxy.add_negative_expectation(caller(1)[0], method, &block)
  else
    @object.mock_proxy.add_expectation(caller(1)[0], method, &block)
  end
end