Allow hiding satisfied expectations in test output
It's often not important to see satisfied stubs in test output, and in some test suites the noise can be difficult to parse. This commit introduces an Expectation#quietly method which allows the suppression of test output for satisfied expectations on a case-by-case basis.
Example
setup do
SomeGlobal.stubs(:foo).with(any_of(*SomeGlobal::THINGS)).quietly
AnotherGlobal.stubs(:connection).quietly
end
test "foo" do
Foo.stubs(:bar)
Bar.expects(:baz)
end
Without #quietly |
With #quietly |
|---|---|
![]() |
![]() |
Alternatives
One alternative might be to treat stubs and expectations differently, such that satisfied stubs are never reported. Or maybe satisfied expectations with a cardinality of 0 needn't be reported. Or maybe it's already possible to hook into Mockery somehow to override the reporting behaviour?
At the moment, we're monkey patching to achieve something similar but thought others might be interested in this change – no worries if not!
@thomasmarshall Thanks for the PR. At first glance doing something about this sounds sensible. I wonder whether a configuration option might be more appropriate. I'm on leave at the moment, but I'll try to have a proper look at it when I'm back next week.
@thomasmarshall I'm sorry I haven't got round to doing anything about this. I've opened #587 to capture the idea, because I still think it's a good one!

