Sha256: 6b56ae11ad5da4df57e95568b1253b829c88104c8185379efe70927d6c23142d

Contents?: true

Size: 1.89 KB

Versions: 31

Compression:

Stored size: 1.89 KB

Contents

# Copyright (c) 2005 Zed A. Shaw 
# You can redistribute it and/or modify it under the same terms as Ruby.
#
# Additional work donated by contributors.  See http://mongrel.rubyforge.org/attributions.html 
# for more information.

require 'test/testhelp'

class TestCommand < GemPlugin::Plugin "/commands"
  include Mongrel::Command::Base

  def configure
    options [
      ["-e", "--environment ENV", "Rails environment to run as", :@environment, ENV['RAILS_ENV'] || "development"],
      ['', '--user USER', "User to run as", :@user, nil],
      ["-d", "--daemonize", "Whether to run in the background or not", :@daemon, false],
      ["-x", "--test", "Used to let the test run failures", :@test, false],
    ]
  end

  def validate
    valid_dir? ".", "Can't validate current directory."
    valid_exists? "Rakefile", "Rakefile not there, test is invalid."
    if @test
      valid_exist? "BADFILE", "Yeah, badfile"
      valid_file? "BADFILE", "Not even a file"
      valid_dir? "BADDIR", "No dir here"
      valid? false, "Total failure"
    end

    return @valid
  end


  def run
    $test_command_ran = true
  end
end

class CommandTest < Test::Unit::TestCase

  def setup
    $test_command_ran = false
  end

  def teardown
  end

  def run_cmd(args)
    Mongrel::Command::Registry.instance.run args
  end

  def test_run_command
    redirect_test_io do
      run_cmd ["testcommand"]
      assert $test_command_ran, "command didn't run"
    end
  end

  def test_command_error
    redirect_test_io do
      run_cmd ["crapcommand"]
    end
  end

  def test_command_listing
    redirect_test_io do
      run_cmd ["help"]
    end
  end

  def test_options
    redirect_test_io do
      run_cmd ["testcommand","-h"]
      run_cmd ["testcommand","--help"]
      run_cmd ["testcommand","-e","test","-d","--user"]
    end
  end

  def test_version
    redirect_test_io do
      run_cmd ["testcommand", "--version"]
    end
  end

end

Version data entries

31 entries across 31 versions & 7 rubygems

Version Path
freels-mongrel-1.1.2 test/test_command.rb
headius-mongrel-1.1.6.1 test/test_command.rb
phurley-mongrel-1.1.6.1 test/test_command.rb
mongrel-maglev--1.1.9.0.1 test/test_command.rb
merb-core-1.1.3 spec10/public/webrat/test_app/gems/gems/mongrel-1.1.5/test/test_command.rb
merb-core-1.1.2 spec10/public/webrat/test_app/gems/gems/mongrel-1.1.5/test/test_command.rb
merb-core-1.1.1 spec10/public/webrat/test_app/gems/gems/mongrel-1.1.5/test/test_command.rb
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/mongrel-1.1.5/test/test_command.rb
mongrel-1.2.0.pre2-x86-mswin32 test/test_command.rb
mongrel-1.2.0.pre2-x86-mingw32 test/test_command.rb
mongrel-1.2.0.pre2 test/test_command.rb
merb-core-1.1.0.rc1 spec10/public/webrat/test_app/gems/gems/mongrel-1.1.5/test/test_command.rb
sho-mongrel-1.1.5 test/test_command.rb
merb-core-1.1.0.pre spec10/public/webrat/test_app/gems/gems/mongrel-1.1.5/test/test_command.rb
mongrel-1.0.4 test/test_command.rb
mongrel-1.0.2 test/test_command.rb
mongrel-1.0.3 test/test_command.rb
mongrel-1.1.3-java test/test_command.rb
mongrel-1.0.5 test/test_command.rb
mongrel-1.1.3 test/test_command.rb