# HG changeset patch # User Michael Granger # Date 1630620409 25200 # Thu Sep 02 15:06:49 2021 -0700 # Node ID cabd6c2a035b67453ccaa0b524deb6779b1c3482 # Parent 4db5211d848c92a783bbd30827d4731e338489ea Report operator arguments in the spec matcher failure output. diff --git a/lib/pushdown/spec_helpers.rb b/lib/pushdown/spec_helpers.rb --- a/lib/pushdown/spec_helpers.rb +++ b/lib/pushdown/spec_helpers.rb @@ -182,9 +182,9 @@ desc << " to %s" % [ self.target_state ] if self.target_state if self.callback - methname, arg = self.callback + methname, *args = self.callback desc << " when #%s is called" % [ methname ] - desc << " with %p" % [ arg ] if arg + desc << " with %s" % [ args.map(&:inspect).join(', ') ] if !args.empty? end desc << ', but ' diff --git a/spec/pushdown/spec_helpers_spec.rb b/spec/pushdown/spec_helpers_spec.rb --- a/spec/pushdown/spec_helpers_spec.rb +++ b/spec/pushdown/spec_helpers_spec.rb @@ -386,6 +386,19 @@ }.to fail_matching( /transition when #on_event is called with :foo/i ) end + + it "handles multiple callback arguments on failures" do + state_class.transition_push( :change, :other ) + + state = state_class.new + allow( state ).to receive( :on_event ).with( :foo, 18, "nebraska" ). + and_return( nil ) + + expect { + expect( state ).to transition.on_an_event( :foo, 18, "nebraska" ) + }.to fail_matching( /#on_event is called with :foo, 18, "nebraska"/i ) + end + end describe "negated matcher" do