1
0
Fork 0
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:
werleo 2017-08-04 14:19:22 +02:00 committed by Anil Kumar Maurya
parent cc45d56773
commit 851dcc36fd
2 changed files with 26 additions and 0 deletions

View 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

View 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