M lib/pushdown/spec_helpers.rb +2 -2
@@ 182,9 182,9 @@ module Pushdown::SpecHelpers
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 '
M spec/pushdown/spec_helpers_spec.rb +13 -0
@@ 386,6 386,19 @@ RSpec.describe( Pushdown::SpecHelpers )
}.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