Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
floehopper committed Nov 7, 2024
1 parent 20595f5 commit 5a214c0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions foo.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require 'bundler/setup'
require 'minitest/autorun'
require 'mocha/minitest'

# rubocop:disable Style/CommentedKeyword
class TestMeme < Minitest::Test
class Klass
def self.foo; end
end

def test_foo_never_called # should fail, but doesn't
Klass.stubs(:foo)
Klass.expects(:foo).never
Klass.foo
end

def test_foo_called_once # correctly passes
Klass.stubs(:foo)
Klass.expects(:foo).once
Klass.foo
end

def test_no_stubs # correctly fails
Klass.expects(:foo).never
Klass.foo
end
end
# rubocop:enable Style/CommentedKeyword
2 changes: 1 addition & 1 deletion lib/mocha/mock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def handle_method_call(symbol, arguments, block)
check_expiry
check_responder_responds_to(symbol)
invocation = Invocation.new(self, symbol, arguments, block)
if (matching_expectation_allowing_invocation = all_expectations.match_allowing_invocation(invocation))
if (matching_expectation_allowing_invocation = all_expectations.match(invocation))
matching_expectation_allowing_invocation.invoke(invocation)
elsif (matching_expectation = all_expectations.match(invocation, ignoring_order: true)) || (!matching_expectation && !@everything_stubbed)
raise_unexpected_invocation_error(invocation, matching_expectation)
Expand Down

0 comments on commit 5a214c0

Please sign in to comment.