Skip to content

Commit

Permalink
Add Expectation#invocations_never_allowed?
Browse files Browse the repository at this point in the history
I'm planning to use this in a subsequent commit.
  • Loading branch information
floehopper committed Nov 13, 2024
1 parent b24bd4e commit 471b996
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/mocha/expectation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,11 @@ def invocations_allowed?
@cardinality.invocations_allowed?
end

# @private
def invocations_never_allowed?
@cardinality.invocations_never_allowed?
end

# @private
def satisfied?
@cardinality.satisfied?
Expand Down
7 changes: 7 additions & 0 deletions test/unit/expectation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ def test_should_allow_invocations_until_expected_invocation_count_is_a_range_fro
assert !expectation.invocations_allowed?
end

def test_should_never_allow_invocations
expectation = new_expectation.never
assert expectation.invocations_never_allowed?
invoke(expectation)
assert expectation.invocations_never_allowed?
end

def test_should_store_provided_backtrace
backtrace = Object.new
assert_equal backtrace, Expectation.new(nil, :expected_method, backtrace).backtrace
Expand Down

0 comments on commit 471b996

Please sign in to comment.