Skip to content

Instantly share code, notes, and snippets.

@chriskottom
Last active August 29, 2015 14:21
Show Gist options
  • Save chriskottom/b9a73eaffb2c5b5b6676 to your computer and use it in GitHub Desktop.
Save chriskottom/b9a73eaffb2c5b5b6676 to your computer and use it in GitHub Desktop.
require "minitest/autorun"
class MinitestMockTest < Minitest::Test
def test_method_called_more_times_than_expected
mock = Minitest::Mock.new
3.times { mock.expect :some_method, true }
assert mock.some_method # OK
assert mock.some_method # OK
assert mock.some_method # still OK
assert mock.some_method # MockExpectationError
end
end
$ ruby minitest_mock_test.rb
Run options: --seed 25695
# Running:
E
Finished in 0.000932s, 1072.6138 runs/s, 3217.8414 assertions/s.
1) Error:
MinitestMockTest#test_method_called_more_times_than_expected:
MockExpectationError: No more expects available for :some_method: []
minitest_mock_test.rb:11:in `test_method_called_more_times_than_expected'
1 runs, 3 assertions, 0 failures, 1 errors, 0 skips
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment