]> git.donarmstrong.com Git - biopieces.git/commitdiff
ruby unit tests refactored
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 27 May 2010 15:33:44 +0000 (15:33 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 27 May 2010 15:33:44 +0000 (15:33 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@974 74ccb610-7750-0410-82ae-013aeee3265d

code_python/Cjung/Args.pyc
code_ruby/Maasha/lib/biopieces.rb
code_ruby/Maasha/test/test_biopieces.rb

index 8d4a9b2279db062dfba6af022399e8fac2311731..4c39c4a68733e7fdac49e939fe26d08e98449439 100644 (file)
Binary files a/code_python/Cjung/Args.pyc and b/code_python/Cjung/Args.pyc differ
index 2828a4211f1c487f3aa5c1a59a5d8e91f81b7e35..b739ee7d4c1a1ea6d78368e6ce50e8b36f42d419 100644 (file)
@@ -6,17 +6,15 @@ require 'pp'
 class CastError < StandardError
 end
 
-# Class using for handling Biopieces the parsing and emitting of Biopiece records,
-# which are ASCII text records consisting of lines with a key/value pair seperated
-# by a colon and a white space ': '. Each record is separated by a line with three
-# dashes '---'.
-# 
 # Biopieces are command line scripts and uses OptionParser to parse command line
 # options according to a list of casts. Each cast prescribes the long and short
 # name of the option, the type, if it is mandatory, the default value, and allowed
 # and disallowed values. An optional list of extra casts can be supplied, and the
 # integrity of the casts are checked. Following the command line parsing, the
-# options are checked according to the casts.
+# options are checked according to the casts. Methods are also included for handling
+# the parsing and emitting of Biopiece records, which are ASCII text records consisting
+# of lines with a key/value pair seperated by a colon and a white space ': '.
+# Each record is separated by a line with three dashes '---'.
 class Biopieces
   TYPES        = %w[flag string list int uint float file file! files files! dir dir! genome]
   MANDATORY    = %w[long short type mandatory default allowed disallowed]
@@ -25,8 +23,8 @@ class Biopieces
   REGEX_STRING = /^(string|file|file!|dir|dir!|genome)$/
 
   # Initialize a Biopiece and write the status to file.
-  def initialize
-    status_set
+  def initialize(no_status=nil)
+    status_set unless no_status
   end
 
   # Check the integrity of a list of casts, followed by parsion options from argv
index 14a83c8b80f80e1f732a11e107737db778c2f634..7a2ae14e1d40f4ac2481344f19030ffc84f0ab49 100755 (executable)
@@ -11,167 +11,182 @@ SCRIPT_PATH = "write_fasta.rb"
 
 class OptionTest < Test::Unit::TestCase
 
-  # >>>>>>>>>>>>>>>>>>>> Testing Options.new <<<<<<<<<<<<<<<<<<<<
-
-  test "Options.new with no argument don't raise" do
-    assert_nothing_raised { Options.new }
-  end
-
-  test "Options.new with empty list don't raise" do
-    assert_nothing_raised { Options.new([]) }
-  end
-  
-  test "Options.new with non-array argument raises" do
-    %w[ "foo", 1, 1.2, {}, nil, false, true ].each do |arg|
-      assert_raise(TypeError) { Options.new(arg) }
-    end
+  def setup
+    @bp = Biopieces.new(true)
   end
 
-  test "Options.new with missing cast key raises" do
-    assert_raise(CastError) { Options.new([{}]) }
-  end
+  # >>>>>>>>>>>>>>>>>>>> Testing Options.new <<<<<<<<<<<<<<<<<<<<
 
-  test "Options.new with all cast keys don't raise" do
+  test "Biopieces#parse with all cast keys don't raise" do
+    argv  = []
     casts = [{:long=>"foo", :short=>"f", :type=>"int", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-    assert_nothing_raised(CastError) { Options.new(casts) }
+    @bp.expects(:print_usage_and_exit).with()
+    assert_nothing_raised(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
   end
 
-  test "Options.new with illegal long cast values raises" do
+  test "Biopieces#parse with illegal long cast values raises" do
     [nil, true, false, 1, 0, "a"].each do |long|
+      argv  = []
       casts = [{:long=>long, :short=>"f", :type=>"int", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-      assert_raise(CastError) { Options.new(casts) }
+      assert_raise(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 
-  test "Options.new with legal long cast values don't raise" do
+  test "Biopieces#parse with legal long cast values don't raise" do
     ["foo", "!!", "0123"].each do |long|
+      argv  = []
       casts = [{:long=>long, :short=>"f", :type=>"int", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-      assert_nothing_raised(CastError) { Options.new(casts) }
+      @bp.expects(:print_usage_and_exit).with()
+      assert_nothing_raised(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 
-  test "Options.new with illegal short cast values raises" do
+  test "Biopieces#parse with illegal short cast values raises" do
     [nil, true, false, "foo"].each do |short|
+      argv  = []
       casts = [{:long=>"foo", :short=>short, :type=>"int", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-      assert_raise(CastError) { Options.new(casts) }
+      assert_raise(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 
-  test "Options.new with legal short cast values don't raise" do
+  test "Biopieces#parse with legal short cast values don't raise" do
     ["!", "1", "a"].each do |short|
+      argv  = []
       casts = [{:long=>"foo", :short=>short, :type=>"int", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-      assert_nothing_raised(CastError) { Options.new(casts) }
+      @bp.expects(:print_usage_and_exit).with()
+      assert_nothing_raised(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 
-  test "Options.new with illegal type cast values raises" do
+  test "Biopieces#parse with illegal type cast values raises" do
     [nil, true, false, "foo", 12, 0].each do |type|
+      argv  = []
       casts = [{:long=>"foo", :short=>"f", :type=>type, :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-      assert_raise(CastError) { Options.new(casts) }
+      assert_raise(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 
-  test "Options.new with legal type cast values don't raise" do
+  test "Biopieces#parse with legal type cast values don't raise" do
     TYPES.each do |type|
+      argv  = []
       casts = [{:long=>"foo", :short=>"f", :type=>type, :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-      assert_nothing_raised(CastError) { Options.new(casts) }
+      @bp.expects(:print_usage_and_exit).with()
+      assert_nothing_raised(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 
-  test "Options.new with illegal mandatory cast values raises" do
+  test "Biopieces#parse with illegal mandatory cast values raises" do
     ["yes", 12, 0, nil].each do |mandatory|
+      argv  = []
       casts = [{:long=>"foo", :short=>"f", :type=>"int", :mandatory=>mandatory, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-      assert_raise(CastError) {Options.new(casts) }
+      assert_raise(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 
-  test "Options.new with legal mandatory cast values don't raise" do
+  test "Biopieces#parse with legal mandatory cast values don't raise" do
     [true, false].each do |mandatory|
+      argv  = []
       casts = [{:long=>"foo", :short=>"f", :type=>"int", :mandatory=>mandatory, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-      assert_nothing_raised(CastError) {Options.new(casts) }
+      @bp.expects(:print_usage_and_exit).with()
+      assert_nothing_raised(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 
-  test "Options.new with illegal default cast values raises" do
+  test "Biopieces#parse with illegal default cast values raises" do
     [true, false, [], {}].each do |default|
+      argv  = []
       casts = [{:long=>"foo", :short=>"f", :type=>"int", :mandatory=>false, :default=>default, :allowed=>nil, :disallowed=>nil}]
-      assert_raise(CastError) { Options.new(casts) }
+      assert_raise(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 
-  test "Options.new with legal default cast values don't raise" do
+  test "Biopieces#parse with legal default cast values don't raise" do
     ["foo", nil, 0, 0.0, 1, 1.2].each do |default|
+      argv  = []
       casts = [{:long=>"foo", :short=>"f", :type=>"int", :mandatory=>false, :default=>default, :allowed=>nil, :disallowed=>nil}]
-      assert_nothing_raised(CastError) { Options.new(casts) }
+      @bp.expects(:print_usage_and_exit).with()
+      assert_nothing_raised(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 
-  test "Options.new with illegal allowed cast values raises" do
+  test "Biopieces#parse with illegal allowed cast values raises" do
     [true, false, {}, [], 0, 0.1].each do |allowed|
+      argv  = []
       casts = [{:long=>"foo", :short=>"f", :type=>"int", :mandatory=>false, :default=>nil, :allowed=>allowed, :disallowed=>nil}]
-      assert_raise(CastError) { Options.new(casts) }
+      assert_raise(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 
-  test "Options.new with legal allowed cast values don't raise" do
+  test "Biopieces#parse with legal allowed cast values don't raise" do
     ["foo,bar",nil].each do |allowed|
+      argv  = []
       casts = [{:long=>"foo", :short=>"f", :type=>"int", :mandatory=>false, :default=>nil, :allowed=>allowed, :disallowed=>nil}]
-      assert_nothing_raised(CastError) { Options.new(casts) }
+      @bp.expects(:print_usage_and_exit).with()
+      assert_nothing_raised(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 
-  test "Options.new with illegal disallowed cast values raises" do
+  test "Biopieces#parse with illegal disallowed cast values raises" do
     [true, false, {}, [], 0, 0.1].each do |disallowed|
+      argv  = []
       casts = [{:long=>"foo", :short=>"f", :type=>"int", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>disallowed}]
-      assert_raise(CastError) { Options.new(casts) }
+      assert_raise(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 
-  test "Options.new with legal disallowed cast values don't raise" do
+  test "Biopieces#parse with legal disallowed cast values don't raise" do
     ["foo,bar",nil].each do |disallowed|
+      argv  = []
       casts = [{:long=>"foo", :short=>"f", :type=>"int", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>disallowed}]
-      assert_nothing_raised(CastError) { Options.new(casts) }
+      @bp.expects(:print_usage_and_exit).with()
+      assert_nothing_raised(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 
-  test "Options.new with duplicate long cast values raises" do
+  test "Biopieces#parse with duplicate long cast values raises" do
+    argv  = []
     casts = []
     casts << {:long=>"foo", :short=>"f", :type=>"int", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
     casts << {:long=>"foo", :short=>"b", :type=>"int", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
-    assert_raise(CastError) { Options.new(casts) }
+    assert_raise(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
   end
 
-  test "Options.new with duplicate short cast values raises" do
+  test "Biopieces#parse with duplicate short cast values raises" do
+    argv  = []
     casts = []
     casts << {:long=>"foo", :short=>"f", :type=>"int", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
     casts << {:long=>"bar", :short=>"f", :type=>"int", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
-    assert_raise(CastError) { Options.new(casts) }
+    assert_raise(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
   end
 
-  test "Options.new without duplicate long and short cast values don't raise" do
+  test "Biopieces#parse without duplicate long and short cast values don't raise" do
+    argv  = []
     casts = []
     casts << {:long=>"foo", :short=>"f", :type=>"int", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
     casts << {:long=>"bar", :short=>"b", :type=>"int", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
-    assert_nothing_raised(CastError) { Options.new(casts) }
+    @bp.expects(:print_usage_and_exit).with()
+    assert_nothing_raised(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
   end
 
   # >>>>>>>>>>>>>>>>>>>> Testing Options.parse <<<<<<<<<<<<<<<<<<<<
 
-  test "Options.parse with empty argv and missing wiki file raises" do
-    opt_parser = Options.new
-    assert_raise() { opt_parser.parse([], "foo") }
+  test "Biopieces#parse with empty argv and missing wiki file raises" do
+    argv  = []
+    casts = []
+    assert_raise() { @bp.parse(argv,casts, "foo") }
   end
 
-  test "Options.parse with empty argv and existing wiki file don't raise" do
-    opt_parser = Options.new
-    opt_parser.expects(:print_usage_and_exit).with()
-    assert_nothing_raised { opt_parser.parse([], SCRIPT_PATH) }
+  test "Biopieces#parse with empty argv and existing wiki file don't raise" do
+    argv  = []
+    casts = []
+    @bp.expects(:print_usage_and_exit).with()
+    assert_nothing_raised { @bp.parse(argv, casts, SCRIPT_PATH) }
   end
 
-   test "Options.parse with --help in argv and existing wiki output long usage" do
-     opt_parser = Options.new
-     opt_parser.expects(:print_usage_and_exit).with(true)
-     assert_nothing_raised { opt_parser.parse(["--help"],SCRIPT_PATH) }
+   test "Biopieces#parse with --help in argv and existing wiki output long usage" do
+     argv = ["--help"]
+     @bp.expects(:print_usage_and_exit).with(true)
+     assert_nothing_raised { @bp.parse(argv,[],SCRIPT_PATH) }
    end
 
 #  # FIXME This one fails because any argument to a flag is ignored and the flag value is set to true. Should it raise?
@@ -181,42 +196,43 @@ class OptionTest < Test::Unit::TestCase
 #    assert_raise(ArgumentError) { opt_parser.parse(["--foo", "bar"],SCRIPT_PATH) }
 #   end
 
-  test "Options.parse with --stream_in <arg> returns options['stream_in']=>[<arg>]" do
-    opt_parser = Options.new
-    options = opt_parser.parse(["--stream_in", __FILE__],SCRIPT_PATH)
+  test "Biopieces#parse with --stream_in <arg> returns options['stream_in']=>[<arg>]" do
+    argv = ["--stream_in", __FILE__]
+    options = @bp.parse(argv,[],SCRIPT_PATH)
     assert_equal([__FILE__], options["stream_in"])
   end
 
-  test "Options.parse with -I <arg> returns options['stream_in']=>[<arg>]" do
-    opt_parser = Options.new
-    options = opt_parser.parse(["-I", __FILE__],SCRIPT_PATH)
+  test "Biopieces#parse with -I <arg> returns options['stream_in']=>[<arg>]" do
+    argv    = ["-I", __FILE__]
+    casts   = []
+    options = @bp.parse(argv, casts, SCRIPT_PATH)
     assert_equal([__FILE__], options["stream_in"])
   end
 
-  test "Options.parse use cast default value if no argument given" do
-    casts = [{:long=>"foo", :short=>"f", :type=>"string", :mandatory=>false, :default=>"bar", :allowed=>nil, :disallowed=>nil}]
-    opt_parser = Options.new(casts)
-    options = opt_parser.parse(["-I", __FILE__],SCRIPT_PATH)
+  test "Biopieces#parse use cast default value if no argument given" do
+    argv    = ["-I", __FILE__]
+    casts   = [{:long=>"foo", :short=>"f", :type=>"string", :mandatory=>false, :default=>"bar", :allowed=>nil, :disallowed=>nil}]
+    options = @bp.parse(argv, casts, SCRIPT_PATH)
     assert_equal(options["foo"], "bar")
   end
 
-  test "Options.parse don't use default value if argument given" do
-    casts = [{:long=>"foo", :short=>"f", :type=>"string", :mandatory=>false, :default=>"bar", :allowed=>nil, :disallowed=>nil}]
-    opt_parser = Options.new(casts)
-    options = opt_parser.parse(["--foo", "bleh", "-I", __FILE__],SCRIPT_PATH)
+  test "Biopieces#parse don't use default value if argument given" do
+    argv    = ["--foo", "bleh", "-I", __FILE__]
+    casts   = [{:long=>"foo", :short=>"f", :type=>"string", :mandatory=>false, :default=>"bar", :allowed=>nil, :disallowed=>nil}]
+    options = @bp.parse(argv, casts, SCRIPT_PATH)
     assert_equal(options["foo"], "bleh")
   end
 
-  test "Options.parse with mandatory cast and no argument raises" do
+  test "Biopieces#parse with mandatory cast and no argument raises" do
+    argv  = ["-I", __FILE__]
     casts = [{:long=>"foo", :short=>"f", :type=>"string", :mandatory=>true, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-    opt_parser = Options.new(casts)
-    assert_raise(ArgumentError) { opt_parser.parse(["-I", __FILE__],SCRIPT_PATH) }
+    assert_raise(ArgumentError) { @bp.parse(argv,casts,SCRIPT_PATH) }
   end
 
-  test "Options.parse with mandatory cast and argument don't raise" do
+  test "Biopieces#parse with mandatory cast and argument don't raise" do
+    argv  = ["--foo", "bar", "-I", __FILE__]
     casts = [{:long=>"foo", :short=>"f", :type=>"string", :mandatory=>true, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-    opt_parser = Options.new(casts)
-    assert_nothing_raised(ArgumentError) { opt_parser.parse(["--foo", "bar", "-I", __FILE__],SCRIPT_PATH) }
+    assert_nothing_raised(ArgumentError) { @bp.parse(argv,casts,SCRIPT_PATH) }
   end
 
 #  # This one results in an error: "OptionParser::InvalidArgument: invalid argument: --foo bar"
@@ -229,98 +245,97 @@ class OptionTest < Test::Unit::TestCase
 #    end
 #  end
 
-  test "Options.parse with type cast int don't raise" do
+  test "Biopieces#parse with type cast int don't raise" do
     [0,-1,1,327649123746293746374276347824].each do |val|
+      argv  = ["--foo", "#{val}", "-I", __FILE__]
       casts = [{:long=>"foo", :short=>"f", :type=>"int", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-      opt_parser = Options.new(casts)
-      assert_nothing_raised(ArgumentError) { opt_parser.parse(["--foo", "#{val}", "-I", __FILE__],SCRIPT_PATH) }
+      assert_nothing_raised(ArgumentError) { @bp.parse(argv,casts,SCRIPT_PATH) }
     end
   end
 
   # TODO similar test for uint as "test "Options.parse with type cast int and non-int value raises" do"
 
-  test "Options.parse with type cast uint don't raise" do
+  test "Biopieces#parse with type cast uint don't raise" do
     [0,1,327649123746293746374276347824].each do |val|
+      argv  = ["--foo", "#{val}", "-I", __FILE__]
       casts = [{:long=>"foo", :short=>"f", :type=>"uint", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-      opt_parser = Options.new(casts)
-      assert_nothing_raised(ArgumentError) { opt_parser.parse(["--foo", "#{val}", "-I", __FILE__],SCRIPT_PATH) }
+      assert_nothing_raised(ArgumentError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 
-  test "Options.parse with file! cast and file don't exists raises" do
+  test "Biopieces#parse with file! cast and file don't exists raises" do
+    argv  = ["--foo", "bleh", "-I", __FILE__]
     casts = [{:long=>"foo", :short=>"f", :type=>"file!", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-    opt_parser = Options.new(casts)
-    assert_raise(ArgumentError) { opt_parser.parse(["--foo", "bleh", "-I", __FILE__],SCRIPT_PATH) }
+    assert_raise(ArgumentError) { @bp.parse(argv, casts, SCRIPT_PATH) }
   end
 
-  test "Options.parse with file! cast and existing file don't raise" do
+  test "Biopieces#parse with file! cast and existing file don't raise" do
+    argv  = ["--foo", __FILE__, "-I", __FILE__]
     casts = [{:long=>"foo", :short=>"f", :type=>"file!", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-    opt_parser = Options.new(casts)
-    assert_nothing_raised(ArgumentError) { opt_parser.parse(["--foo", __FILE__, "-I", __FILE__],SCRIPT_PATH) }
+    assert_nothing_raised(ArgumentError) { @bp.parse(argv, casts, SCRIPT_PATH) }
   end
 
-  test "Options.parse with files! cast and a file don't exists raises" do
+  test "Biopieces#parse with files! cast and a file don't exists raises" do
+    argv  = ["--foo", __FILE__ + ",bleh", "-I", __FILE__]
     casts = [{:long=>"foo", :short=>"f", :type=>"files!", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-    opt_parser = Options.new(casts)
-    assert_raise(ArgumentError) { opt_parser.parse(["--foo", __FILE__ + ",bleh", "-I", __FILE__],SCRIPT_PATH) }
+    assert_raise(ArgumentError) { @bp.parse(argv, casts, SCRIPT_PATH) }
   end
 
-  test "Options.parse with files! cast and files exists don't raise" do
+  test "Biopieces#parse with files! cast and files exists don't raise" do
+    argv  = ["--foo", __FILE__ + "," + __FILE__, "-I", __FILE__]
     casts = [{:long=>"foo", :short=>"f", :type=>"files!", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-    opt_parser = Options.new(casts)
-    assert_nothing_raised(ArgumentError) { opt_parser.parse(["--foo", __FILE__ + "," + __FILE__, "-I", __FILE__],SCRIPT_PATH) }
+    assert_nothing_raised(ArgumentError) { @bp.parse(argv, casts, SCRIPT_PATH) }
   end
 
   # TODO replace the absolute part below the file location with File.dirname(__FILE__)
-  test "Options.parse with glob argument expands correctly" do
-    casts = [{:long=>"foo", :short=>"f", :type=>"files!", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-    argv  = ["--foo", "/Users/maasha/unit_test/foo*,/Users/maasha/unit_test/my_dir/*.fna", "-I", __FILE__]
-    opt_parser = Options.new(casts)
-    options = opt_parser.parse(argv,SCRIPT_PATH)
+  test "Biopieces#parse with glob argument expands correctly" do
+    argv    = ["--foo", "/Users/maasha/unit_test/foo*,/Users/maasha/unit_test/my_dir/*.fna", "-I", __FILE__]
+    casts   = [{:long=>"foo", :short=>"f", :type=>"files!", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
+    options = @bp.parse(argv, casts, SCRIPT_PATH)
     assert_equal(options["foo"], ["/Users/maasha/unit_test/foo.fna", "/Users/maasha/unit_test/my_dir/bar.fna"])
   end
 
-  test "Options.parse with dir! cast and dir don't exists raises" do
+  test "Biopieces#parse with dir! cast and dir don't exists raises" do
+    argv  = ["--foo", "bleh", "-I", __FILE__]
     casts = [{:long=>"foo", :short=>"f", :type=>"dir!", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-    opt_parser = Options.new(casts)
-    assert_raise(ArgumentError) { opt_parser.parse(["--foo", "bleh", "-I", __FILE__],SCRIPT_PATH) }
+    assert_raise(ArgumentError) { @bp.parse(argv, casts, SCRIPT_PATH) }
   end
 
-  test "Options.parse with dir! cast and dir exists don't raise" do
+  test "Biopieces#parse with dir! cast and dir exists don't raise" do
+    argv  = ["--foo", "/", "-I", __FILE__]
     casts = [{:long=>"foo", :short=>"f", :type=>"dir!", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-    opt_parser = Options.new(casts)
-    assert_nothing_raised(ArgumentError) { opt_parser.parse(["--foo", "/", "-I", __FILE__],SCRIPT_PATH) }
+    assert_nothing_raised(ArgumentError) { @bp.parse(argv, casts, SCRIPT_PATH) }
   end
 
-  test "Options.parse with allowed cast and not allowed value raises" do
+  test "Biopieces#parse with allowed cast and not allowed value raises" do
     ["bleh", "2", "3.3"].each do |val|
+      argv  = ["--foo", "#{val}", "-I", __FILE__]
       casts = [{:long=>"foo", :short=>"f", :type=>"string", :mandatory=>false, :default=>nil, :allowed=>"0,-1,0.0,1,bar", :disallowed=>nil}]
-      opt_parser = Options.new(casts)
-      assert_raise(ArgumentError) { opt_parser.parse(["--foo", "#{val}", "-I", __FILE__],SCRIPT_PATH) }
+      assert_raise(ArgumentError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 
-  test "Options.parse with allowed cast and allowed values don't raise" do
+  test "Biopieces#parse with allowed cast and allowed values don't raise" do
     ["0", "-1", "0.0", "1", "bar"].each do |val|
+      argv  = ["--foo", "#{val}", "-I", __FILE__]
       casts = [{:long=>"foo", :short=>"f", :type=>"string", :mandatory=>false, :default=>nil, :allowed=>"0,-1,0.0,1,bar", :disallowed=>nil}]
-      opt_parser = Options.new(casts)
-      assert_nothing_raised(ArgumentError) { opt_parser.parse(["--foo", "#{val}", "-I", __FILE__],SCRIPT_PATH) }
+      assert_nothing_raised(ArgumentError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 
-  test "Options.parse with disallowed cast and disallowed value raises" do
+  test "Biopieces#parse with disallowed cast and disallowed value raises" do
     ["0", "-1", "0.0", "1", "bar"].each do |val|
+      argv  = ["--foo", "#{val}", "-I", __FILE__]
       casts = [{:long=>"foo", :short=>"f", :type=>"string", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>"0,-1,0.0,1,bar"}]
-      opt_parser = Options.new(casts)
-      assert_raise(ArgumentError) { opt_parser.parse(["--foo", "#{val}", "-I", __FILE__],SCRIPT_PATH) }
+      assert_raise(ArgumentError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 
-  test "Options.parse with disallowed cast and allowed values don't raise" do
+  test "Biopieces#parse with disallowed cast and allowed values don't raise" do
     ["bleh", "2", "3.3"].each do |val|
+      argv  = ["--foo", "#{val}", "-I", __FILE__]
       casts = [{:long=>"foo", :short=>"f", :type=>"string", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>"0,-1,0.0,1,bar"}]
-      opt_parser = Options.new(casts)
-      assert_nothing_raised(ArgumentError) { opt_parser.parse(["--foo", "#{val}", "-I", __FILE__],SCRIPT_PATH) }
+      assert_nothing_raised(ArgumentError) { @bp.parse(argv, casts, SCRIPT_PATH) }
     end
   end
 end