method

assert_called

Importance_0
v5.0.0.1 - Show latest stable - 0 notes - Class: MethodCallAssertions
assert_called(object, method_name, message = nil, times: 1, returns: nil) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activesupport/lib/active_support/testing/method_call_assertions.rb, line 7
        def assert_called(object, method_name, message = nil, times: 1, returns: nil)
          times_called = 0

          object.stub(method_name, proc { times_called += 1; returns }) { yield }

          error = "Expected #{method_name} to be called #{times} times, "              "but was called #{times_called} times"
          error = "#{message}.\n#{error}" if message
          assert_equal times, times_called, error
        end
Register or log in to add new notes.