Sha256: 8ce03b48fe6f080b5870d2eeef2cfc292153364421c1d5e8359bddc18753ad4f
Contents?: true
Size: 708 Bytes
Versions: 39
Compression:
Stored size: 708 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
39 entries across 39 versions & 1 rubygems