1
############################################################
2
# This file is imported from a different project.
3
# DO NOT make modifications in this repo.
4
# File a patch instead and assign it to Ryan Davis
5
############################################################
7
require 'minitest/mock'
8
require 'minitest/unit'
10
MiniTest::Unit.autorun
12
class TestMiniMock < MiniTest::Unit::TestCase
14
@mock = MiniTest::Mock.new.expect(:foo, nil)
15
@mock.expect(:meaning_of_life, 42)
18
def test_should_create_stub_method
22
def test_should_allow_return_value_specification
23
assert_equal 42, @mock.meaning_of_life
26
def test_should_blow_up_if_not_called
32
def test_should_not_blow_up_if_everything_called
39
def test_should_allow_expectations_to_be_added_after_creation
40
@mock.expect(:bar, true)
44
def test_should_not_verify_if_new_expected_method_is_not_called
47
@mock.expect(:bar, true)
52
def test_should_not_verify_if_unexpected_method_is_called
53
assert_raises NoMethodError do
58
def test_should_blow_up_on_wrong_number_of_arguments
61
@mock.expect(:sum, 3, [1, 2])
63
assert_raises ArgumentError do
68
def test_should_blow_up_on_wrong_arguments
71
@mock.expect(:sum, 3, [1, 2])
78
def test_no_method_error_on_unexpected_methods
79
assert_raises NoMethodError do
85
assert_raises MockExpectationError do