Sha256: 612eb4f43e3a3c28c392ee046762673d80db0ba28fe14f8bb417b647fbcfa14b
Contents?: true
Size: 710 Bytes
Versions: 14
Compression:
Stored size: 710 Bytes
Contents
RSpec::Matchers.define :delegate do |method| match do |delegator| @method = method @delegator = delegator return false unless @delegator.respond_to?(@to) return false unless @delegator.respond_to?(@method) target = double allow(@delegator).to receive(@to).and_return(target) allow(target).to receive(@method).and_return(:called) @delegator.send(@method) == :called end description do "delegate :#{@method} to :#{@to}" end failure_message do "expected #{@delegator} to delegate :#{@method} to :#{@to}" end failure_message_when_negated do "expected #{@delegator} not to delegate :#{@method} to :#{@to}" end chain(:to) { |to| @to = to } end
Version data entries
14 entries across 14 versions & 1 rubygems