`wrong number of arguments (1 for 0)` error in tests
MarkDBlackwell opened this issue · comments
Currently, after cloning the example app, many Cucumber features emit this error (at this location):
wrong number of arguments (1 for 0) (ArgumentError)
./features/step_definitions/user_steps.rb:26:in `delete_user'
My versions:
$ bundle exec cucumber --version
1.2.3
$ bundle exec rails -v
Rails 3.2.13
$ bundle exec ruby -v
ruby 1.9.3p392 (2013-02-22 revision 39386) [i686-linux]
Solved!
In features/step_definitions/user_steps.rb, the invocation of method find:
@user ||= User.first conditions: {:email => @visitor[:email]}
is failing (here and here) only because we're using gem mongoid. Essentially this may be a Mongoid bug—their site mentions their intentions (overall).
The Mongoid find
method we're using might be here on GitHub. More information exists on the Mongoid site (by scrolling to 'Criteria#find').
Instead a working ActiveRecord compatible invocation that produces the desired effect is
@user ||= User.where('email' => @visitor[:email]).first
Hello Mark,
I have come across same issue as well. See below for more info
wrong number of arguments (1 for 0) (ArgumentError)
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.3/lib/cucumber/ast/location.rb:22:in file_colon_line' C:/RubyMine/RubyMine 5.0/rb/testing/patch/bdd/teamcity/cucumber/common.rb:126:in
tc_before_feature'
C:/Ruby193/bin/cucumber:23:in <top (required)>' -e:1:in
load'
-e:1:in `
Hi!
i have the same error when i run cucumber features in RubyMine, but i don't have error when i run features from console.
please help!
log:
/home/alex/.rvm/rubies/ruby-1.9.3-p374/bin/ruby -EUTF-8 -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /home/alex/.rvm/gems/ruby-1.9.3-p374@blog/bin/cucumber /home/alex/Ruby_task/my_project/test_app/blog/features/test.feature --format Teamcity::Cucumber::Formatter --expand --color -r features
Testing started at 9:58 ...
The current driver is: webkit
The default driver is: webkit
wrong number of arguments (1 for 0) (ArgumentError)
/home/alex/.rvm/gems/ruby-1.9.3-p374@blog/gems/cucumber-1.3.10/lib/cucumber/ast/location.rb:22:in file_colon_line' /home/alex/Install/RubyMine-5.0.2/rb/testing/patch/bdd/teamcity/cucumber/common.rb:126:in
tc_before_feature'
/home/alex/Install/RubyMine-5.0.2/rb/testing/patch/bdd/teamcity/cucumber/formatter_03103.rb:46:in before_feature' /home/alex/.rvm/gems/ruby-1.9.3-p374@blog/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:181:in
block in send_to_all'
/home/alex/.rvm/gems/ruby-1.9.3-p374@blog/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:179:in each' /home/alex/.rvm/gems/ruby-1.9.3-p374@blog/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:179:in
send_to_all'
/home/alex/.rvm/gems/ruby-1.9.3-p374@blog/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:169:in broadcast' /home/alex/.rvm/gems/ruby-1.9.3-p374@blog/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:26:in
visit_feature'
/home/alex/.rvm/gems/ruby-1.9.3-p374@blog/gems/cucumber-1.3.10/lib/cucumber/ast/features.rb:28:in block in accept' /home/alex/.rvm/gems/ruby-1.9.3-p374@blog/gems/cucumber-1.3.10/lib/cucumber/ast/features.rb:17:in
each'
/home/alex/.rvm/gems/ruby-1.9.3-p374@blog/gems/cucumber-1.3.10/lib/cucumber/ast/features.rb:17:in each' /home/alex/.rvm/gems/ruby-1.9.3-p374@blog/gems/cucumber-1.3.10/lib/cucumber/ast/features.rb:27:in
accept'
/home/alex/.rvm/gems/ruby-1.9.3-p374@blog/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:21:in block in visit_features' /home/alex/.rvm/gems/ruby-1.9.3-p374@blog/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:170:in
broadcast'
/home/alex/.rvm/gems/ruby-1.9.3-p374@blog/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:20:in visit_features' /home/alex/.rvm/gems/ruby-1.9.3-p374@blog/gems/cucumber-1.3.10/lib/cucumber/runtime.rb:49:in
run!'
/home/alex/.rvm/gems/ruby-1.9.3-p374@blog/gems/cucumber-1.3.10/lib/cucumber/cli/main.rb:47:in execute!' /home/alex/.rvm/gems/ruby-1.9.3-p374@blog/gems/cucumber-1.3.10/bin/cucumber:13:in
<top (required)>'
/home/alex/.rvm/gems/ruby-1.9.3-p374@blog/bin/cucumber:19:in load' /home/alex/.rvm/gems/ruby-1.9.3-p374@blog/bin/cucumber:19:in
<top (required)>'
-e:1:in load' -e:1:in