From: tamouse mailing lists Date: 2013-01-05T11:21:48+09:00 Subject: Re: require "test/unit" On Fri, Jan 4, 2013 at 2:07 PM, Derrick B. wrote: > unknown wrote in post #1091069: >> Am 04.01.2013 19:48, schrieb Derrick B.: >>> So, I think (and I am guessing here) that your test files should only >>> include classes to be tested and the actual testing class. That would >> >> Defining the class to be tested in the test file does not make >> any sense, since you want to use your class elsewhere, and not only >> in tests. You would define it in a separate file and require it >> (with `require' or `require_relative'). > > You're right, I should not have stated that in that way, but my main > point was directly related to how I thought the OP was adding the test > class into the current code, and not separately. He was receiving an > error, which I also encountered, so I gave my solution. > > Thank you for the clarification on proper test class usage. It should > help me, and the OP, to steer away from such errors by separating the > code. There is a structure for building command-line applications that may be something you want to adopt. I'm going to point you to davetron1000's gems: methadone and GLI, both of which are builders for command-line apps (kind of like rails is for web apps). They provide some nifty things for making nice CLI apps, but possibly the tl;dr is that you implement the bare minimum in the part that does the part to take arguments from the command line, and then pass them to your classes/modules/etc, which are in separate files. Generally, a CLI app structure looks like this: my_cli_app/ Gemfile Rakefile bin/ my_cli_app # this contains the command line interaction part lib/ my_cli_app/ # these implement specific features of the module/class version.rb classOne.rb ... my_cli_app.rb # this implements the module/class my_cli_app.gemspec # describes how to build this gem README.rdoc # application documentation that gets bundled in rdoc spec/ # rspec tests for the app's classes test/ # Test::Unit tests for app's classes (and if you're awesome) feature/ # cucumber/aruba tests for the app