Sha256: c9d8ab8a8c91da337f53305197cbbc53d1e5718f0eabb252f3922d34fb50e2a8

Contents?: true

Size: 1.86 KB

Versions: 15

Compression:

Stored size: 1.86 KB

Contents

require 'spec_helper'

describe( Array ) do
  describe( 'to_s_for_cap' ) do
    context( 'with an element containing white space' ) do
      before( :all ) do
        @list = [ 'one', 'white space', 'three' ]
      end

      it( 'should format the list correctly' ) do
        @list.to_s_for_cap.should == 'one "white space" three'
      end
    end

    context( 'without an element containing white space' ) do
      before( :all ) do
        @list = [ 'one', 'two', 'three' ]
      end
      it( 'should format the list correctly' ) do
        @list.to_s_for_cap.should == 'one two three'
      end
    end
  end
end

describe( String ) do
  describe( 'for_cap_list' ) do
    context( 'with white space' ) do
      before( :all ) do
        @string = 'white space'
      end

      it( 'should format the string correctly' ) do
        @string.for_cap_list.should == '"white space"'
      end
    end

    context( 'without white space' ) do
      before( :all ) do
        @string= 'one'
      end
      it( 'should format the string correctly' ) do
        @string.for_cap_list.should == 'one'
      end
    end
  end

  describe( 'unpack_cap_list' ) do
    it( 'shoud unpack strings in quotes correctly' ) do
      'Item1 "Item 2" Item3'.unpack_cap_list.should == [ "Item1", "Item 2", "Item3" ]
    end

    it( 'should unpack strings correclty' ) do
      'Item1 Item2 Item3'.unpack_cap_list.should == [ "Item1", "Item2", "Item3" ]
    end
  end

  describe( 'attribute_values_to_hash' ) do
    it( 'should reject nil values' ) do
      RCAP.attribute_values_to_hash( ["a", nil ]).should == {}
    end

    it( 'should reject empty values' ) do
      RCAP.attribute_values_to_hash( ["a", []]).should == {}
    end

    it( 'should not reject non-nil and non-empty values' ) do
      RCAP.attribute_values_to_hash( [ "a", 1 ], [ "b", [ 2 ]]).should == { "a" => 1, "b" => [ 2 ]}
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rcap-2.0.2 spec/extensions_spec.rb
rcap-2.0.1 spec/extensions_spec.rb
rcap-2.0.0 spec/extensions_spec.rb
rcap-1.3.1 spec/utilities_spec.rb
rcap-1.3.0 spec/utilities_spec.rb
rcap-1.2.4 spec/utilities_spec.rb
rcap-1.2.3 spec/utilities_spec.rb
rcap-1.2.2 spec/utilities_spec.rb
rcap-1.2.1 spec/utilities_spec.rb
rcap-1.2.0 spec/utilities_spec.rb
rcap-1.1.1 spec/utilities_spec.rb
rcap-1.1.0 spec/utilities_spec.rb
rcap-1.0.1 spec/utilities_spec.rb
rcap-1.0.0 spec/utilities_spec.rb
rcap-1.0.0.rc.5 spec/utilities_spec.rb