-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://expectations.rubyforge.org/svn/trunk@51 6f265639-962f-4d85-a13b-3090ac0aa348
- Loading branch information
jaycfields
committed
Mar 4, 2008
1 parent
98fa721
commit 3136f04
Showing
7 changed files
with
20 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
class Expectations::DelegateRecorder | ||
attr_reader :klass, :subject, :meth | ||
def initialize(klass, meth) | ||
@klass, @subject_mock, @meth = klass, Mocha::Mock.new, meth | ||
@subject_mock.expects(meth).returns(:the_subjects_response) | ||
module Expectations::DelegateRecorder | ||
def delegate!(meth) | ||
@subject_mock = Mocha::Mock.new | ||
@meth = meth | ||
@subject_mock.expects(meth) | ||
end | ||
|
||
def to(subject) | ||
@subject = subject | ||
def to(receiver) | ||
@receiver = receiver | ||
self | ||
end | ||
|
||
def mock | ||
@klass.stubs(@subject).returns(@subject_mock) | ||
@klass | ||
subject.stubs(@receiver).returns(@subject_mock) | ||
subject | ||
end | ||
|
||
def verify(actual) | ||
@subject_mock.verify | ||
actual == :the_subjects_response | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +0,0 @@ | ||
class Expectations::StateBasedRecorder | ||
attr_reader :subject | ||
def initialize(subject) | ||
@subject = subject | ||
@message_parts = [] | ||
end | ||
|
||
def have | ||
@message_parts << "have" | ||
self | ||
end | ||
|
||
def be | ||
@message_parts << "be" | ||
self | ||
end | ||
|
||
def method_stack | ||
@method_stack ||= [] | ||
end | ||
|
||
def method_missing(sym, *args) | ||
@message_parts << "#{sym}" | ||
args.each { |arg| @message_parts << arg.inspect } | ||
method_stack << [sym, args] | ||
self | ||
end | ||
|
||
end | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters