forked from freerange/mocha
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mock#expects,#stubs should return last expectation
Even when passed a hash of method names vs return values. This is the same behaviour as for ObjectMethods#expects & #stubs and the behaviour described by the documentation for Mock#expects & #stubs. Fixes freerange#524.
- Loading branch information
1 parent
d446657
commit b6b637d
Showing
2 changed files
with
39 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require File.expand_path('../acceptance_test_helper', __FILE__) | ||
|
||
class Issue524Test < Mocha::TestCase | ||
include AcceptanceTest | ||
|
||
def setup | ||
setup_acceptance_test | ||
end | ||
|
||
def teardown | ||
teardown_acceptance_test | ||
end | ||
|
||
def test_expects_returns_last_expectation | ||
test_result = run_as_test do | ||
object = mock | ||
object.expects(:method_1 => 1, :method_2 => 2).twice | ||
object.method_1 | ||
object.method_2 | ||
object.method_2 | ||
end | ||
assert_passed(test_result) | ||
end | ||
|
||
def test_stubs_returns_last_expectation | ||
test_result = run_as_test do | ||
object = mock | ||
object.stubs(:method_1 => 1, :method_2 => 2).twice | ||
object.method_1 | ||
object.method_2 | ||
object.method_2 | ||
end | ||
assert_passed(test_result) | ||
end | ||
end |