Sha256: f7d54014987ac0a29c4b16a30bb05c25dad960601f3111da93089e0d25deda02

Contents?: true

Size: 1.27 KB

Versions: 68

Compression:

Stored size: 1.27 KB

Contents

require 'test_helper'
require 'tins/go'

module Tins
  class GoTest < Test::Unit::TestCase
    include Tins::GO


    def test_empty_string
      r = go '', args = %w[a b c]
      assert_equal({}, r)
      assert_equal %w[a b c], args
    end

    def test_empty_args
      r = go 'ab:', args = []
      assert_equal({ 'a' => false, 'b' => nil }, r)
      assert_equal [], args
    end

    def test_simple
      r = go 'ab:', args = %w[-b hello -a -c rest]
      assert_equal({ 'a' => 1, 'b' => 'hello' }, r)
      assert_equal %w[-c rest], args
    end

    def test_complex
      r = go 'ab:', args = %w[-a -b hello -a -bworld -c rest]
      assert_equal({ 'a' => 2, 'b' => 'hello' }, r)
      assert_equal %w[hello world], r['b'].to_a
      assert_equal %w[-c rest], args
    end

    def test_complex2
      r = go 'ab:', args = %w[-b hello -aa -b world -c rest]
      assert_equal({ 'a' => 2, 'b' => 'hello' }, r)
      assert_equal %w[hello world], r['b'].to_a
      assert_equal %w[-c rest], args
    end

    def test_complex_frozen
      args = %w[-b hello -aa -b world -c rest]
      args = args.map(&:freeze)
      r = go 'ab:', args
      assert_equal({ 'a' => 2, 'b' => 'hello' }, r)
      assert_equal %w[hello world], r['b'].to_a
      assert_equal %w[-c rest], args
    end
  end
end

Version data entries

68 entries across 66 versions & 7 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/tins-0.13.2/tests/go_test.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/tins-0.13.2/tests/go_test.rb
tdiary-5.0.8 vendor/bundle/gems/tins-0.13.2/tests/go_test.rb
tdiary-5.0.8 vendor/bundle/ruby/2.5.0/gems/tins-0.13.2/tests/go_test.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/tins-1.6.0/tests/go_test.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/tins-1.6.0/tests/go_test.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/tins-1.6.0/tests/go_test.rb
logstash-filter-cache-redis-0.1.0 vendor/bundle/jruby/1.9/gems/tins-1.6.0/tests/go_test.rb
tins-1.9.0 tests/go_test.rb
tins-1.8.2 tests/go_test.rb
tins-1.8.1 tests/go_test.rb
tins-1.8.0 tests/go_test.rb
tins-1.7.0 tests/go_test.rb
suzuko-0.1.8 vendor/bundle/ruby/2.0.0/gems/tins-1.6.0/tests/go_test.rb
suzuko-0.1.7 vendor/bundle/ruby/2.0.0/gems/tins-1.6.0/tests/go_test.rb
mastermind_adeybee-0.1.4 vendor/bundle/ruby/2.2.0/gems/tins-1.6.0/tests/go_test.rb
mastermind_adeybee-0.1.3 vendor/bundle/ruby/2.2.0/gems/tins-1.6.0/tests/go_test.rb
mastermind_adeybee-0.1.2 vendor/bundle/ruby/2.2.0/gems/tins-1.6.0/tests/go_test.rb
mastermind_adeybee-0.1.1 vendor/bundle/ruby/2.2.0/gems/tins-1.6.0/tests/go_test.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/tins-1.6.0/tests/go_test.rb