Module: Minitest::Moar::Assertions

Defined in:
lib/minitest/moar/assertions.rb

Instance Method Summary collapse

Instance Method Details

#assert_called(object, method, count = nil) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/minitest/moar/assertions.rb', line 2

def assert_called object, method, count = nil
  invoked = get_invocation_count(object, method)

  if count.nil?
    assert invoked > 0, "#{object} expected to call #{method} but did not."
  else
    assert_equal count, invoked, "#{object} expected to call #{method} #{count} times but it was only called #{invoked} times."
  end
end

#assert_instance_called(object, method, count = nil) ⇒ Object



12
13
14
# File 'lib/minitest/moar/assertions.rb', line 12

def assert_instance_called object, method, count = nil
  assert_called "Instance of #{object}", method, count
end

#refute_called(object, method, count = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/minitest/moar/assertions.rb', line 16

def refute_called object, method, count = nil
  invoked = get_invocation_count(object, method)

  if count.nil?
    refute invoked > 0, "#{object} expected to not call #{method} but did."
  else
    refute_equal count, invoked, "#{object} expected to not call #{method} #{count} times but it did."
  end
end

#refute_instance_called(object, method, count = nil) ⇒ Object



26
27
28
# File 'lib/minitest/moar/assertions.rb', line 26

def refute_instance_called object, method, count = nil
  refute_called "Instance of #{object}", method, count
end