-
Notifications
You must be signed in to change notification settings - Fork 645
Open
Description
Describe the bug
Can't pass an empty hash as callback parameters to transition_from
since 5.5.0
To Reproduce
Reproduce script is here.
# frozen_string_literal: true
# bug_report_aasm.rb
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "aasm", "5.5.0"
gem "rspec"
end
class Job
include AASM
aasm do
state :sleeping, initial: true
state :running, :cleaning
event :run do
transitions from: :sleeping, to: :running, after: :prepare_run!
end
event :clean do
transitions from: :running, to: :cleaning
end
end
def prepare_run!(params)
puts params
end
end
require "aasm/rspec"
require "rspec/autorun"
RSpec.describe Job do
it "move to 'run' with parameters" do
job = Job.new
expect(job).to transition_from(:sleeping).to(:running).on_event(:run, {})
end
end
$ ruby bug_report_aasm.rb
F
Failures:
1) Job move to 'run' with parameters
Failure/Error:
def prepare_run!(params)
puts params
end
ArgumentError:
wrong number of arguments (given 0, expected 1)
# bug_report_aasm.rb:28:in `prepare_run!'
# bug_report_aasm.rb:39:in `block (2 levels) in <main>'
Finished in 0.00177 seconds (files took 0.05501 seconds to load)
1 example, 1 failure
Failed examples:
rspec bug_report_aasm.rb:37 # Job move to 'run' with parameters
Expected behavior
Allow to pass an empty hash as callback parameters via transition_from
Additional context
This has happened since #808.
thanh-an-andpad and sullerandras
Metadata
Metadata
Assignees
Labels
No labels