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

ArgumentError: wrong number of arguments when first argument is nil #441

Closed
werleo opened this issue Mar 13, 2017 · 6 comments
Closed

ArgumentError: wrong number of arguments when first argument is nil #441

werleo opened this issue Mar 13, 2017 · 6 comments

Comments

@werleo
Copy link
Contributor

werleo commented Mar 13, 2017

When first argument to event is nil it is removed from argument list.
In consequence we get:

ArgumentError: wrong number of arguments (given 1, expected 2)

Test scenario:

werleo@354e05f

@h0jeZvgoxFepBQ2C
Copy link

I think i found the problem, working on a patch at the moment

@h0jeZvgoxFepBQ2C
Copy link

h0jeZvgoxFepBQ2C commented May 30, 2017

It looks like its this method definition which removes the first argument, because to_state is nil:

# Call starts here:
#aasm/lib/aasm/aasm.rb @ line 113
if may_fire_to = event.may_fire?(self, *args)

#which leads to following parameter conversion:
#aasm/lib/aasm/core/event.rb @ line 44 AASM::Core::Event#may_fire?


    43: def may_fire?(obj, to_state=nil, *args)
 => 44:   binding.pry if args.size == 1
    45:     puts "#{caller[0]}\t#{args.to_s}" # debug
    46:   _fire(obj, {:test_only => true}, to_state, *args) # true indicates test firing
    47: end

[1] pry(#<AASM::Core::Event>)> to_state
=> nil
[2] pry(#<AASM::Core::Event>)> args
=> ["yuppi"]

Don't know how to refactor this though...

@anilmaurya
Copy link
Member

@werleo Can you run your specs on master branch and let me know if this issue is resolved ?

@werleo
Copy link
Contributor Author

werleo commented Jul 27, 2017

@anilmaurya test is passing on master branch.
Thank you for fixing it.

Test is in PR https://github.com/aasm/aasm/pull/485/files
I made it by mistake so you may close it.

@anilmaurya
Copy link
Member

I would like to merge #485 , can you rename wrong_arguments_list to guard_arguments_check ?

@werleo
Copy link
Contributor Author

werleo commented Jul 27, 2017

Renamed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants