Sha256: c821ceb16a28d4ce94b7da9e76d6ba8fda585fe806921ddad4bc67cb23ab66fd

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

# encoding: utf-8

class FlexturesTest < Test::Unit::TestCase
  context "Array#to_hash" do
    context "when column size is equal data size" do
      setup do
        @keys   = %W[id name hp]
        @values = %W[1 hoge 100]
        @h = @values.extend(Flextures::Extensions::Array).to_hash(@keys)
      end
      should "return hash" do
        assert_equal @h, { "id"=>"1", "name"=>"hoge", "hp"=>"100" }
      end
    end
    context "when column size is bigger than data size" do
      setup do
        @keys   = %W[id name hp]
        @values = %W[1 hoge]
        @h = @values.extend(Flextures::Extensions::Array).to_hash(@keys)
      end
      should "return hash, overflow key is filled 'nil'" do
        assert_equal @h, { "id"=>"1", "name"=>"hoge", "hp"=> nil }
      end
    end
    context "when column size is smaller than data size" do
      setup do
        @keys   = %W[id name]
        @values = %W[1 hoge 200]
        @h = @values.extend(Flextures::Extensions::Array).to_hash(@keys)
      end
      should "return hash, overflow value is cut offed" do
        assert_equal @h, { "id"=>"1", "name"=>"hoge" }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
flextures-3.1.2 test/unit/test_flextures_extention_modules.rb
flextures-3.1.1 test/unit/test_flextures_extention_modules.rb
flextures-3.1.0 test/unit/test_flextures_extention_modules.rb
flextures-3.0.1 test/unit/test_flextures_extention_modules.rb
flextures-3.0.0 test/unit/test_flextures_extention_modules.rb