views:

23

answers:

1

Hey,

Ive got a simple Nunit runner for a rake script i have:

module NUnitRunner

    @NUnitPath = "#{RootDir}/tools/nunit/nunit-console.exe";

    def self.RunTests(testFile)
        system("\"#{@NUnitPath}\" ? \"#{testFile}\"")
    end

    def self.RunTests(testFile, runArgs)
        system("\"#{@NUnitPath}\" ? \"#{testFile}\" #{runArgs}")
    end

end

When im calling this module from within my task:

# Run Unit Tests
task :run_unit_tests do
    puts "Running Unit Tests"

    unitTestFile = "#{RootDir}/src/tests/unittests.dll"
    NUnitRunner.RunTests(unitTestFile)
end

It just keeps telling me "wrong number of arguments (1 for 2)", and if i remove the overloaded method which takes 2 arguments it works fine, so is there some quirk with ruby that i dont know about in this instance?

+2  A: 

Ruby doesn't support method overloading.

Reese Moore
Oh right, so can only 1 signature exist for a given method? I assume it gets round this with optional arguments or something?
Grofit
@Grofit: That is right. You need optional arguments.
elusive
Grofit: Correct, only one signature can exist per method. You can declare optional arguments (default parameters). In some situations, you can also choose to override the method to achieve the effect (though, for what you describe, default parameters appears to be the best bet).
Reese Moore
Ok thanks, will mark this as answer in 8 mins
Grofit