Run ruby files through script

Alpha

I want to run all ruby files from specific folder(without using Rake gem)(I'm trying this only for learning purpose). In order to achieve that, I did following:

files = Dir[File.join(Dir.pwd, "tests/*.rb")]

files.each do |file|
  ruby file
end

when I run above script, it throw an error:

run.rb:13:in `block in <main>': undefined method `ruby' for main:Object (NoMethodError)

I've ruby installed on my machine. Please suggest change in my code to work it.

Damien MATHIEU

There is no ruby method inside ruby programs.
You're using ruby in your terminal because that's the name of the executable, not the name of a function.

You can use require to do what you're trying to achieve.

files = Dir[File.join(Dir.pwd, "tests/*.rb")]

files.each do |file|
  require file
end

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Run ruby files through script

From Dev

Run ruby script through vba

From Dev

Run python script through Java with files arguments

From Dev

How to run multiple config files through a script?

From Dev

Error running selenium ruby script through xvfb-run

From Dev

Unable to run R script through .bat files in Windows Server

From Dev

Run a Ruby Script with Python

From Dev

Run a Ruby Script with Python

From Dev

Renaming Files Through Script

From Dev

How to loop through all files in dir, run script, and write them into matching files in other dir

From Dev

Run script on multiple files

From Dev

Loop through two files Ruby

From Dev

Run ruby script on page refresh

From Dev

Run ruby script in terminal with parameters

From Dev

Ruby script being a pain to run

From Dev

Run shell script with parameter in Ruby

From Dev

Run ruby script in terminal with parameters

From Dev

Ruby script being a pain to run

From Dev

Script Loop through files in directory

From Dev

How to run files in parallel in Ruby?

From Dev

A ruby script to run other ruby scripts

From Dev

fdisk command run on terminal but not run with ruby script

From Dev

fdisk command run on terminal but not run with ruby script

From Dev

Run a script with different input files

From Dev

Run a script with different input files

From Dev

To run unix shell script through JAVA applications

From Dev

Run php script through Android app

From Dev

How to run a shell script through apache airflow

From Dev

Run perl script through Java using ProcessBuilder