class Pseudo

Pseudo a very simple test double that supports stubbing and spies

Constants

UNSTUBBED_ERROR_MESSAGE
VERSION
VERY_PRIVATE_METHOD_PREFIX

Public Class Methods

new() click to toggle source
# File lib/pseudo.rb, line 36
def initialize
  @stubs = {}
  @received = {}
end

Public Instance Methods

method_missing(symbol, *arguments, &block) click to toggle source
# File lib/pseudo.rb, line 45
def method_missing(symbol, *arguments, &block)
  if @stubs.key?(symbol)
    @received[symbol] = arguments
    @stubs[symbol].act(&block)
  else
    fail NoMethodError, Kernel.format(
      UNSTUBBED_ERROR_MESSAGE, symbol, @stubs.keys)
  end
end
received?(message) click to toggle source
# File lib/pseudo.rb, line 55
def received?(message)
  @received.include?(message)
end
received_with?(message, *arguments) click to toggle source
# File lib/pseudo.rb, line 59
def received_with?(message, *arguments)
  @received.fetch(message) { return false } == arguments
end
respond_to?(symbol, include_private = false) click to toggle source
Calls superclass method
# File lib/pseudo.rb, line 63
def respond_to?(symbol, include_private = false)
  return true if @stubs.key?(symbol)
  super
end
stub(name) click to toggle source
# File lib/pseudo.rb, line 41
def stub(name)
  @stubs[name] = Stub.new
end