Module Expectations::DelegateRecorder
In: lib/expectations/delegate_recorder.rb

Methods

Attributes

delegation_result  [RW] 

Public Instance methods

[Source]

    # File lib/expectations/delegate_recorder.rb, line 4
 4:   def delegate!(meth)
 5:     @meth = meth
 6:     recorder = self
 7:     mod = Module.new do
 8:       define_method meth do |*args|
 9:         recorder.delegation_result = super(*args)
10:       end
11:     end
12:     subject.extend mod
13:   end

[Source]

    # File lib/expectations/delegate_recorder.rb, line 31
31:   def failure_message
32:     "expected #{subject}.#{@meth} to return the value of #{subject}.#{@receiver}.#{@meth}; however, #{subject}.#{@meth} returned #{delegation_result.inspect}"
33:   end

[Source]

    # File lib/expectations/delegate_recorder.rb, line 35
35:   def mocha_error_message(ex)
36:     "expected #{subject} to delegate #{@meth} to #{@receiver}; however, #{subject}.#{@meth} was never called -- #{ex}"
37:   end

[Source]

    # File lib/expectations/delegate_recorder.rb, line 20
20:   def subject!
21:     @subject_mock = Object.new
22:     @subject_mock.expects(@meth).returns(:a_delegated_return_value)
23:     subject.stubs(@receiver).returns(@subject_mock)
24:     subject
25:   end

[Source]

    # File lib/expectations/delegate_recorder.rb, line 15
15:   def to(receiver)
16:     @receiver = receiver
17:     self
18:   end

[Source]

    # File lib/expectations/delegate_recorder.rb, line 27
27:   def verify
28:     :a_delegated_return_value == delegation_result
29:   end

[Validate]