Sha256: 2fdc0fc1399050d7fc54ce184d4ee521aa4b2f19fe63141f780e009f7d94bcd0
Contents?: true
Size: 800 Bytes
Versions: 3
Compression:
Stored size: 800 Bytes
Contents
# RSpec matcher to spec delegations. RSpec::Matchers.define :delegate do |method| match do |object| @method = method @via ||= method @object = object if !@object.respond_to?(@to) raise "#{@object} does not respond to ##{@to}!" end @object.stub(@to).and_return double('receiver') @object.send(@to).stub(@via).and_return :called @object.send(@method) == :called end description do "delegate ##{@method} to ##{@to}##{@via}" end failure_message_for_should do |text| "expected #{@object} to delegate ##{@method} to ##{@to}##{@via}" end failure_message_for_should_not do |text| "expected #{@object} not to delegate ##{@method} to ##{@to}##{@via}" end chain(:to) { |receiver| @to = receiver } chain(:via) { |via| @via = via } end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ndlib-on-rspec-0.0.3 | lib/ndlib-on-rspec/delegate_matcher.rb |
ndlib-on-rspec-0.0.2 | lib/ndlib-on-rspec/delegate_matcher.rb |
ndlib-on-rspec-0.0.1 | lib/ndlib-on-rspec/delegate_matcher.rb |