Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing an empty hash to :after transition methods #833

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/aasm/core/invokers/literal_invoker.rb
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions spec/unit/rspec_matcher_spec.rb
Expand Up @@ -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)
Expand Down