Sha256: 3c3ca7b8c5f3455346bd2afb0f68e8b2679699d087b57d29bbd3b91c79816129

Contents?: true

Size: 1.74 KB

Versions: 22

Compression:

Stored size: 1.74 KB

Contents

require File.dirname(__FILE__) + '/test_helper'

class ExecutableParamTest < Test::Unit::TestCase
  include SproutTestCase

  context "a new, simple Executable::Param" do

    setup do 
      @param = Sprout::Executable::Param.new
    end

    should "be invisible until value set" do
      assert !@param.visible?
    end

    should "return empty string with no value" do
      assert_equal '', @param.to_shell
    end

    should "raise if required and nil" do
      @param.required = true
      assert_raises Sprout::Errors::MissingArgumentError do
        @param.to_shell
      end
    end

    context "with simple values" do

      setup do
        @param.name = :foo
        @param.value = 'bar'
      end

      should "not raise if required and has value" do
        @param.required = true
        assert @param.to_shell
      end

      should "accept a name and value" do
        assert_equal '--foo=bar', @param.to_shell
      end

      should "accept space delimiter" do
        @param.delimiter = ' '
        assert_equal '--foo bar', @param.to_shell
      end

      should "accept arbitrary delimiter" do
        @param.delimiter = ' ||= '
        assert_equal '--foo ||= bar', @param.to_shell
      end

      should "accept empty prefix" do
        @param.prefix = ''
        assert_equal 'foo=bar', @param.to_shell
      end

      should "accept arbitrary prefix" do
        @param.prefix = '++++'
        assert_equal '++++foo=bar', @param.to_shell
      end

      should "accept hidden_name attribute" do
        @param.hidden_name = true
        assert_equal 'bar', @param.to_shell
      end

      should "accept hidden_value attribute" do
        @param.hidden_value = true
        assert_equal '--foo', @param.to_shell
      end

    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
sprout-1.0.26.pre test/unit/executable_param_test.rb
sprout-1.0.25.pre test/unit/executable_param_test.rb
sprout-1.0.24.pre test/unit/executable_param_test.rb
sprout-1.0.23.pre test/unit/executable_param_test.rb
sprout-1.0.22.pre test/unit/executable_param_test.rb
sprout-1.0.20.pre test/unit/executable_param_test.rb
sprout-1.0.19.pre test/unit/executable_param_test.rb
sprout-1.0.18.pre test/unit/executable_param_test.rb
sprout-1.0.17.pre test/unit/executable_param_test.rb
sprout-1.0.16.pre test/unit/executable_param_test.rb
sprout-1.0.15.pre test/unit/executable_param_test.rb
sprout-1.0.14.pre test/unit/executable_param_test.rb
sprout-1.0.13.pre test/unit/executable_param_test.rb
sprout-1.0.11.pre test/unit/executable_param_test.rb
sprout-1.0.9.pre test/unit/executable_param_test.rb
sprout-1.0.8.pre test/unit/executable_param_test.rb
sprout-1.0.5.pre test/unit/executable_param_test.rb
sprout-1.0.4.pre test/unit/executable_param_test.rb
sprout-1.0.3.pre test/unit/executable_param_test.rb
sprout-1.0.2.pre test/unit/executable_param_test.rb