diff --git a/lib/aasm/core/invokers/literal_invoker.rb b/lib/aasm/core/invokers/literal_invoker.rb index c8bdffc9..5bb3d47b 100644 --- a/lib/aasm/core/invokers/literal_invoker.rb +++ b/lib/aasm/core/invokers/literal_invoker.rb @@ -31,7 +31,7 @@ def exec_subject return record.__send__(subject) if subject_arity.zero? return record.__send__(subject, *args) if subject_arity < 0 req_args = args[0..(subject_arity - 1)] - return record.__send__(subject, **req_args[0]) if req_args[0].is_a?(Hash) + return record.__send__(subject, **req_args[0]) if req_args[0].is_a?(Hash) && !req_args[0].empty? record.__send__(subject, *req_args) end # rubocop:enable Metrics/AbcSize diff --git a/spec/unit/rspec_matcher_spec.rb b/spec/unit/rspec_matcher_spec.rb index 8a651550..cc805fb5 100644 --- a/spec/unit/rspec_matcher_spec.rb +++ b/spec/unit/rspec_matcher_spec.rb @@ -72,6 +72,11 @@ expect(example).to_not allow_event(:fill_out_with_args).with(false) end + it "works with empty hash argument" do + pe = ParametrisedEvent.new + expect(pe).to transition_from(:sleeping).to(:showering).on_event(:shower, {}) + end + it "works for multiple state machines" do expect(multiple).to allow_event(:walk).on(:move) expect(multiple).to_not allow_event(:hold).on(:move)