module Rogue::Support::MockMethods

Public Instance Methods

expect_chained_call(mock, chain_call, ret_val, args = []) { |var_args| ... } click to toggle source

Chained method calls in the form of mock.first.second.third can be made on a mock with this auxillary method

# File lib/rogue/support/mock_methods.rb, line 8
def expect_chained_call(mock, chain_call, ret_val, args = [])
  calls = chain_call.split('.')
  calls[0, calls.length - 1].each do |each|
    mock.expect(each.to_sym, mock)
  end
  mock.expect(calls.last, ret_val, args) unless block_given?
  if block_given?
    mock.expect(calls.last, ret_val) do |*var_args|
      yield var_args
    end
  end
end
with_new_mock(&block) click to toggle source
# File lib/rogue/support/mock_methods.rb, line 34
def with_new_mock(&block)
  MockContext.new(block)
end