mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
Test for aasm guard arguments (#485)
This commit is contained in:
parent
cc45d56773
commit
851dcc36fd
2 changed files with 26 additions and 0 deletions
17
spec/models/guard_arguments_check.rb
Normal file
17
spec/models/guard_arguments_check.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
class GuardArgumentsCheck
|
||||
include AASM
|
||||
|
||||
aasm do
|
||||
state :new, :reviewed, :finalized
|
||||
|
||||
event :mark_as_reviewed,
|
||||
:guard => proc { |*args| arguments_list(*args) } do
|
||||
transitions :from => :new, :to => :reviewed
|
||||
end
|
||||
end
|
||||
|
||||
def arguments_list(arg1, arg2)
|
||||
return false unless arg1.nil?
|
||||
true
|
||||
end
|
||||
end
|
9
spec/unit/guard_arguments_check_spec.rb
Normal file
9
spec/unit/guard_arguments_check_spec.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe "nil as first argument" do
|
||||
let(:guard) { GuardArgumentsCheck.new }
|
||||
|
||||
it 'does not raise errors' do
|
||||
expect { guard.mark_as_reviewed(nil, 'second arg') }.not_to raise_error
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue