Flowdock
method

method_missing

Importance_0
Ruby latest stable (v1_9_3_392) - 0 notes - Class: Mock
method_missing(sym, *args) public

No documentation

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

Hide source
# File lib/minitest/mock.rb, line 78
    def method_missing(sym, *args) # :nodoc:
      expected = @expected_calls[sym]

      unless expected then
        raise NoMethodError, "unmocked method %p, expected one of %p" %
          [sym, @expected_calls.keys.sort_by(&:to_s)]
      end

      expected_args, retval = expected[:args], expected[:retval]

      unless expected_args.size == args.size
        raise ArgumentError, "mocked method %p expects %d arguments, got %d" %
          [sym, expected[:args].size, args.size]
      end

      @actual_calls[sym] << {
        :retval => retval,
        :args => expected_args.zip(args).map { |mod, a| mod if mod === a }
      }

      retval
    end
Register or log in to add new notes.