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

How to solve problem wrong number of arguments? #219

Closed
sdilshod opened this issue Feb 1, 2012 · 10 comments
Closed

How to solve problem wrong number of arguments? #219

sdilshod opened this issue Feb 1, 2012 · 10 comments

Comments

@sdilshod
Copy link

sdilshod commented Feb 1, 2012

Hi again!!

When run cucumber, I get this error(i will get full trace)

  wrong number of arguments (2 for 0) (ArgumentError)
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/gherkin-2.7.1/lib/gherkin/formatter/ansi_escapes.rb:78:in `block (2 levels) in <module:AnsiEscapes>'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.0/lib/action_view/helpers/form_tag_helper.rb:162:in `text_field_tag'
  /home/dilshod/webapp/wage_calculation/app/helpers/application_helper.rb:6:in `block in append_row_to_table_tag'
  /home/dilshod/webapp/wage_calculation/app/helpers/application_helper.rb:5:in `each'
  /home/dilshod/webapp/wage_calculation/app/helpers/application_helper.rb:5:in `append_row_to_table_tag'
  /home/dilshod/webapp/wage_calculation/features/step_definitions/fill_schedule_of_working_steps.rb:42:in `block in <top (required)>'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/core_ext/instance_exec.rb:48:in `instance_exec'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/core_ext/instance_exec.rb:48:in `block in cucumber_instance_exec'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/core_ext/instance_exec.rb:69:in `cucumber_run_with_backtrace_filtering'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/core_ext/instance_exec.rb:36:in `cucumber_instance_exec'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/rb_support/rb_step_definition.rb:62:in `invoke'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/step_match.rb:25:in `invoke'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/step_invocation.rb:59:in `invoke'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/step_invocation.rb:38:in `accept'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.rb:99:in `block in visit_step'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.rb:163:in `broadcast'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.rb:98:in `visit_step'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/step_collection.rb:15:in `block in accept'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/step_collection.rb:14:in `each'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/step_collection.rb:14:in `accept'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.rb:93:in `block in visit_steps'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.rb:163:in `broadcast'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.rb:92:in `visit_steps'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/scenario.rb:55:in `block (2 levels) in accept'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/runtime.rb:80:in `block (2 levels) in with_hooks'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/runtime.rb:96:in `before_and_after'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/runtime.rb:79:in `block in with_hooks'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/runtime/support_code.rb:120:in `call'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/runtime/support_code.rb:120:in `block (3 levels) in around'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/language_support/language_methods.rb:9:in `block in around'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/language_support/language_methods.rb:91:in `call'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/language_support/language_methods.rb:91:in `execute_around'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/language_support/language_methods.rb:8:in `around'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/runtime/support_code.rb:119:in `block (2 levels) in around'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/runtime/support_code.rb:117:in `call'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/runtime/support_code.rb:117:in `around'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/runtime.rb:91:in `around'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/runtime.rb:78:in `with_hooks'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/scenario.rb:53:in `block in accept'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/scenario.rb:108:in `with_visitor'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/scenario.rb:47:in `accept'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.rb:51:in `block in visit_feature_element'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.rb:163:in `broadcast'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.rb:50:in `visit_feature_element'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/feature.rb:43:in `block in accept'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/feature.rb:42:in `each'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/feature.rb:42:in `accept'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.rb:20:in `block in visit_feature'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.rb:163:in `broadcast'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.rb:19:in `visit_feature'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/features.rb:29:in `block in accept'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/features.rb:17:in `each'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/features.rb:17:in `each'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/features.rb:28:in `accept'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.rb:14:in `block in visit_features'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.rb:163:in `broadcast'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.rb:13:in `visit_features'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/runtime.rb:46:in `run!'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/cli/main.rb:43:in `execute!'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/cli/main.rb:20:in `execute'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/bin/cucumber:14:in `<top (required)>'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/bin/cucumber:19:in `load'
  /home/dilshod/.rvm/gems/ruby-1.9.2-p290/bin/cucumber:19:in `<main>'
  features/schedule/manage_fill_schedule_of_workings.feature:16:in `То в таб

My gemfile looks like this:

source 'http://rubygems.org'
#source 'file:///home/dilshod'

gem 'rails', '3.1.0'

# Bundle edge Rails instead:
# gem 'rails',     :git => 'git://github.com/rails/rails.git'

gem 'mysql2'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails', "  ~> 3.1.0"
  gem 'coffee-rails', "~> 3.1.0"
  gem 'uglifier'
end

gem 'jquery-rails'
gem 'haml-rails'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

group :development do
  gem 'rspec-rails'
  gem 'cucumber'
  gem 'gherkin', "<= 2.7.1"
  gem 'cucumber-rails'
  gem 'webrat'
end


group :test do

  gem 'capybara'
  gem 'selenium-webdriver'
  gem 'database_cleaner'
  gem 'factory_girl_rails'
  gem 'webrat'
 # gem "gherkin", "= 2.4.18"
  # Pretty printed test output
  #gem 'turn', :require => false
  gem 'turn', '< 0.8.3'
end
gem 'minitest'

How i can resolve this problem? Please help me. Google not get right result for me//

@aslakhellesoy
Copy link
Contributor

Rails' action_view/helpers/form_tag_helper.rb:162 is calling the tag method.

For some strange reason, this resolves to the tag method defined in gherkin/formatter/ansi_escapes.rb:77

This means that the Gherkin::Formatter::AnsiEscapes module (from gherkin - cucumber's parser) has been included into the same object as ActionView::Helpers::FormTagHelper.

The Gherkin::Formatter::AnsiEscapes module is included in your World (the self object that step definitions run in).
If you also include ActionView::Helpers::FormTagHelper in your World, this will inevitably cause this kind of problem.

If you remove that include the problem should go away.

@sdilshod
Copy link
Author

sdilshod commented Feb 1, 2012

I have a step
find('div#cycle_form table').should have_content(append_row_to_table_tag("day_num", "hour", "hour_night"))

which append_row_to_table_tag my custom helper method

def append_row_to_table_tag(*arg)
str=""
arg.each do |e|
st = text_field_tag("name").to_s
str << "" << st << ""
end
str << ""
end

what is to be done with this?

@aslakhellesoy
Copy link
Contributor

I have a fix for this:

diff --git a/lib/cucumber/rb_support/rb_world.rb b/lib/cucumber/rb_support/rb_world.rb
index 9cbc097..3ddae1c 100644
--- a/lib/cucumber/rb_support/rb_world.rb
+++ b/lib/cucumber/rb_support/rb_world.rb
@@ -1,10 +1,7 @@
-require 'gherkin/formatter/ansi_escapes'
-
 module Cucumber
   module RbSupport
     # All steps are run in the context of an object that extends this module.
     module RbWorld
-      include Gherkin::Formatter::AnsiEscapes

       class << self
         def alias_adverb(adverb)
@@ -21,7 +18,7 @@ module Cucumber
       attr_writer :__cucumber_step_mother, :__natural_language

       def __cucumber_invoke(name, multiline_argument=nil) #:nodoc:
-        STDERR.puts failed + "WARNING: Using 'Given/When/Then' in step definitions is deprecated, use 'step' to call other steps instead:" + caller[0] + reset
+        STDERR.puts "\e[31mWARNING: Using 'Given/When/Then' in step definitions is deprecated, use 'step' to call other steps instead:#{caller[0]}\e[0m"
         @__cucumber_step_mother.invoke(name, multiline_argument)
       end

@@ -46,7 +43,7 @@ module Cucumber
       end

       def announce(*messages)
-        STDERR.puts failed + "WARNING: #announce is deprecated. Use #puts instead:" + caller[0] + reset
+        STDERR.puts "\e[31mWARNING: #announce is deprecated. Use #puts instead:#{caller[0]}\e[0m"
         puts(*messages)
       end

@sdilshod
Copy link
Author

sdilshod commented Feb 1, 2012

I edit lib/cucumber/rb_support/rb_world.rb

#require 'gherkin/formatter/ansi_escapes'

module Cucumber
module RbSupport
# All steps are run in the context of an object that extends this module.
module RbWorld

include Gherkin::Formatter::AnsiEscapes

  class << self
    def alias_adverb(adverb)
      alias_method adverb, :__cucumber_invoke
    end
  end

  # Call a Transform with a string from another Transform definition
  def Transform(arg)
    rb = @__cucumber_step_mother.load_programming_language('rb')
    rb.execute_transforms([arg]).first
  end

  attr_writer :__cucumber_step_mother, :__natural_language

  # Call a step from within a step definition. This method is aliased to
  # the same i18n as RbDsl.
  def __cucumber_invoke(name, multiline_argument=nil) #:nodoc:
    STDERR.puts "\e[31mWARNING: Using 'Given/When/Then' in step definitions is deprecated, use 'step' to call other steps instead:#{caller[0]}\e[0m"

    @__cucumber_step_mother.invoke(name, multiline_argument)
  end

  # See StepMother#invoke_steps
  def steps(steps_text)
    @__cucumber_step_mother.invoke_steps(steps_text, @__natural_language, caller[0])
  end

  # See StepMother#table
  def table(text_or_table, file=nil, line_offset=0)
    @__cucumber_step_mother.table(text_or_table, file, line_offset)
  end

  # See StepMother#doc_string
  def doc_string(string_with_triple_quotes, file=nil, line_offset=0)
    @__cucumber_step_mother.doc_string(string_with_triple_quotes, file, line_offset)
  end

  def announce(*messages)

STDERR.puts failed + "WARNING: #announce is deprecated. Use #puts instead:" + caller[0] + reset

    STDERR.puts "\e[31mWARNING: #announce is deprecated. Use #puts instead:#{caller[0]}\e[0m"

    puts(*messages)
  end

  # See StepMother#puts
  def puts(*messages)
    @__cucumber_step_mother.puts(*messages)
  end

  # See StepMother#ask
  def ask(question, timeout_seconds=60)
    @__cucumber_step_mother.ask(question, timeout_seconds)
  end

  # See StepMother#embed
  def embed(file, mime_type, label='Screenshot')
    @__cucumber_step_mother.embed(file, mime_type, label)
  end

  # Mark the matched step as pending.
  def pending(message = "TODO")
    if block_given?
      begin
        yield
      rescue Exception => e
        raise Pending.new(message)
      end
      raise Pending.new("Expected pending '#{message}' to fail. No Error was raised. No longer pending?")
    else
      raise Pending.new(message)
    end
  end

  # The default implementation of Object#inspect recursively
  # traverses all instance variables and invokes inspect. 
  # This can be time consuming if the object graph is large.
  #
  # This can cause unnecessary delays when certain exceptions 
  # occur. For example, MRI internally invokes #inspect on an 
  # object that raises a NoMethodError. (JRuby does not do this).
  #
  # A World object can have many references created by the user
  # or frameworks (Rails), so to avoid long waiting times on
  # such errors in World we define it to just return a simple String.
  #
  def inspect #:nodoc:
    modules = [self.class]
    (class << self; self; end).instance_eval do
      modules += included_modules
    end
    sprintf("#<%s:0x%x>", modules.join('+'), self.object_id)
  end

  def to_s
    inspect
  end
end

end
end

But still get this error or may bei do not understand you?

@sdilshod
Copy link
Author

sdilshod commented Feb 2, 2012

Sorry, I edit wrong version of cucumber file. So, i correct right version and now gives that "tag" method not found.

undefined method tag' for #<Cucumber::Rails::World:0xb309020> (NoMethodError) ./app/helpers/application_helper.rb:6:inblock in append_row_to_table_tag'
./app/helpers/application_helper.rb:5:in each' ./app/helpers/application_helper.rb:5:inappend_row_to_table_tag'
./features/step_definitions/fill_schedule_of_working_steps.rb:42:in

I don't know what do!

@aslakhellesoy
Copy link
Contributor

If you don't know how to apply the changes yourself I'm afraid you have to wait for the next release.

@sdilshod
Copy link
Author

sdilshod commented Feb 2, 2012

May be prompt me where too need change? I am able to get around of problem, but i wanted in competent way.

OK, I will attempt something else..

Thanks for help!!

@sdilshod
Copy link
Author

sdilshod commented Feb 2, 2012

This is normally if i include ActionView::Helpers::FormTagHelper
to Cucumber::Rails::World

@aslakhellesoy
Copy link
Contributor

The diff I added above was just a quick reminder to myself about how to fix this - I didn't have git access on the machine I tried it out on...

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants