-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed an error in Ruby 3 when specifying a method that takes keyword …
…arguments, such as event's before hook. (#777) * Reproduction case added * Allow keyword arguments to be passed to event before, etc. in Ruby 2.7.1 and above. * refactoring
- Loading branch information
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class EventWithKeywordArguments | ||
include AASM | ||
|
||
aasm do | ||
state :open, :initial => true, :column => :status | ||
state :closed | ||
|
||
event :close do | ||
before :_before_close | ||
transitions from: :open, to: :closed | ||
end | ||
end | ||
|
||
def _before_close(key:) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require 'spec_helper' | ||
|
||
describe EventWithKeywordArguments do | ||
let(:example) { EventWithKeywordArguments.new } | ||
describe 'enable keyword arguments' do | ||
it 'should be executed correctly that method registered by "before hooks" for events with keyword arguments.' do | ||
expect(example.close(key: 1)).to be_truthy | ||
end | ||
end | ||
end |