Sha256: 485b7ceacca3bceeed1b9b579780403230105b19db8c0c3dbf3d316d057f95c1

Contents?: true

Size: 1 KB

Versions: 11

Compression:

Stored size: 1 KB

Contents

require 'test_helper'

class BooleanParamTest < Test::Unit::TestCase
  include Sprout::TestHelper

  context "a new, simple BooleanParam" do

    setup do 
      @param = Sprout::Executable::Boolean.new
      @param.name = 'foo'
    end

    should "be hidden when false" do
      @param.value = false
      assert_equal '', @param.to_shell
    end

    should "default to false" do
      assert_equal false, @param.value
    end

    should "show on true" do
      @param.value = true
      assert_equal '--foo', @param.to_shell
    end

    context "when configuring option parser" do
      
      should "update correctly" do
        @param.show_on_false = true
        @param.default = true
        @param.hidden_value = false
        assert_equal "--[no-]foo [BOOL]", @param.option_parser_declaration
      end

      should "not insert [no] param modifier unless default true" do
        @param.name = 'something_off'
        assert_equal "--something-off", @param.option_parser_declaration
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sprout-1.1.18.pre test/unit/boolean_param_test.rb
sprout-1.1.17.pre test/unit/boolean_param_test.rb
sprout-1.1.16.pre test/unit/boolean_param_test.rb
sprout-1.1.15.pre test/unit/boolean_param_test.rb
sprout-1.1.14.pre test/unit/boolean_param_test.rb
sprout-1.1.13.pre test/unit/boolean_param_test.rb
sprout-1.1.11.pre test/unit/boolean_param_test.rb
sprout-1.1.10.pre test/unit/boolean_param_test.rb
sprout-1.1.7.pre test/unit/boolean_param_test.rb
sprout-1.1.5.pre test/unit/boolean_param_test.rb
sprout-1.1.4.pre test/unit/boolean_param_test.rb