Module: Stump::Baconize::ContextExtensions

Defined in:
lib/motion/stump_spec_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
# File 'lib/motion/stump_spec_helper.rb', line 4

def self.included(base)
  base.class_eval do
    alias_method :it_without_mock_verification, :it
    alias_method :it, :it_with_mock_verification
  end
end

Instance Method Details

#it_with_mock_verification(description, &block) ⇒ Object



22
23
24
25
# File 'lib/motion/stump_spec_helper.rb', line 22

def it_with_mock_verification(description, &block)
  @after << proc { verify_mocks }
  it_without_mock_verification(description, &block)
end

#verify_mocksObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/motion/stump_spec_helper.rb', line 11

def verify_mocks
  begin
    if !Stump::Mocks.failures.nil? && !Stump::Mocks.failures.empty?
      fails = Stump::Mocks.failures.map {|object, method| "#{object.inspect} expected #{method}"}.join(", ")
      should.flunk "Unmet expectations: #{fails}"
    end
  ensure
    Stump::Mocks.clear!
  end
end