Sha256: b31b9139af2a631226edde06e413361a66f1b53b1301d4ba9419abbe9b36eb1e

Contents?: true

Size: 1.85 KB

Versions: 7

Compression:

Stored size: 1.85 KB

Contents

require File.dirname(__FILE__) + '/../helper.rb'

class TestOptions < Test::Unit::TestCase

  def setup
    @defaults = {
      :database => :sqlite,
      :template => :stable,
      :profile  => :complete,
    }
    @databases = [ :postgresql, :mysql, :sqlite ]
    @templates = [ :stable, :edge ]
    @profiles  = [ :complete, :minimal ]
  end
  
  def test_should_set_the_default_options
    opts = Options.new(%w[ appname ])
    @defaults.each { |k,v| assert_equal v, opts[k] }
  end

  def test_should_be_able_to_set_options
    opts = Options.new(%w[ --mysql --edge --minimal myapp ])
    assert_equal :mysql,   opts[:database]
    assert_equal :edge,    opts[:template]
    assert_equal :minimal, opts[:profile]
    assert_equal "myapp",  opts[:app_name]
  end

  def test_should_merge_options
    opts = Options.new(%w[ --mysql myapp ])
    env_opts = Options.new(%w[ --edge ])
    options = opts.merge(env_opts)
    assert_equal :mysql,    options[:database]
    assert_equal :edge,     options[:template]
    assert_equal :complete, options[:profile]
    assert_equal "myapp",   options[:app_name]
  end

  def test_should_detect_invalid_arguments
    opts = Options.new(%w[ --wrong ])
    assert_equal "invalid option: --wrong", opts[:invalid_argument]
  end

  def test_should_have_a_version
    opts = Options.new(%w[ --version myapp])
    version_file = File.dirname(__FILE__) + "/../../VERSION"
    version = File.read(version_file).strip
    assert_equal version, opts[:version]
  end

  def test_should_be_able_to_set_default_locale
    opts = Options.new(%w[ --ca myaapp ])
    assert_equal :ca, opts[:locale]
  end

  def test_should_be_able_to_set_exception_notification_options
    opts = Options.new(%w[ --recipient r@r.com --sender s@s.com myapp])
    assert_equal "r@r.com", opts[:exception_recipient]
    assert_equal "s@s.com", opts[:sender_address]
  end
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ubiquo-0.2.7 test/ubiquo/options_test.rb
ubiquo-0.1.12 test/ubiquo/options_test.rb
ubiquo-0.1.9 test/ubiquo/options_test.rb
ubiquo-0.1.8 test/ubiquo/options_test.rb
ubiquo-0.1.7 test/ubiquo/options_test.rb
ubiquo-0.1.6 test/ubiquo/options_test.rb
ubiquo-0.1.5 test/ubiquo/options_test.rb