ruby - Rake namespace not recognizing a local task -


i learning ruby , trying experiment parsing arguments , having trouble example made. rake namespace not recognizing local task. :example task works fine. :examplealt task not working.

the error is:

$ rake myapp:examplealt rake aborted! nameerror: undefined local variable or method `runtests' main:object c:/ctemp/rubytest/rakefile:19:in `block (2 levels) in <top (required)>' tasks: top => myapp:examplealt 

and here code:

require 'rake' require 'rake/testtask'  # uses '--' args format because 'optparse' lib use wants way # runs myapp tests args client, env, , application namespace :myapp |args|    desc "runs tests."   task :runtests, [:client, :env, :app] |t, args|         puts "args: #{args}"   end    desc "runs example."   task :example         rake.application.invoke_task("myapp:runtests[--client=example, --env=staging, --app=myapp]")   end    desc "runs example alternate."   task :examplealt         rake::task[myapp:runtests].invoke('--client=example', '--env=staging', '--app=myappalt')   end    desc "runs tests default values."   task :defaults, :client, :env, :app |t, args|         args.with_defaults(:default_client => '--client=example', :default_env => '--env=staging', :default_app => '--app=myapp')     puts "args: #{args}"   end  end 

you have problem in line 20:

rake::task[myapp:runtests].invoke('--client=example', '--env=staging', '--app=myappalt') 

the myapp:runtests no symbol , no string. if make string, task run:

      rake::task['myapp:runtests'].invoke('--client=example', '--env=staging', '--app=myappalt') 

with rake::task[...].invoke don't work inside namespace, call task on global level.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

php - Find a regex to take part of Email -

javascript - Function overwritting -