A better option would be to abstract away the direct use of ARGV for testing. Given your current design, you can make a module called something like CommandLineArguments and grant access this way:
 module CommandLineArguments def argv; ARGV; end end 
In your main code:
 class Build < Thor::Group include CommandLineArguments include Thor::Actions args = argv build = args.shift 
Finally, in your test, you can change the module or test class:
 def setup @myargs = nil end class MyApp::Commands::Build def argv; @myargs || ARGV; end end def test_html_is_built @myargs = %w(html) result = MyApp::Commands::Build.run end 
If this seems rather complicated, it is. You might be better off serving to extracting most of your code into the actual classes, and then use them in the Toror executable (instead of having all this code in the executable).
davetron5000 
source share