Sha256: a0c275b85bfd37474707e6c7d6c8a17bc78dedaf208fbfdeda5b2af6c01fac2d

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'
module Alf
  describe Heading do
    
    let(:h0){ Heading.new({}) }
    let(:h1){ Heading.new(:name => String) }
    let(:h2){ Heading.new(:name => String, :price => Float) }
    
    specify "coerce" do
      Heading.coerce(:name => String).should eq(h1)
      Heading.coerce([]).should eq(h0)
      Heading.coerce(["name", "String"]).should eq(h1)
    end
    
    specify "from_argv" do
      Heading.from_argv(["name", "String"]).should eq(h1)
    end
     
    specify "cardinality" do
      h0.cardinality.should eq(0)
      h1.cardinality.should eq(1)
      h2.cardinality.should eq(2)
    end
    
    specify "to_hash" do
      h0.to_hash.should eq({})
      h1.to_hash.should eq(:name => String)
      h2.to_hash.should eq(:name => String, :price => Float)
    end
    
    describe "EMPTY" do
      subject{ Heading::EMPTY }
      it_should_behave_like "A value" 
    end
    
    describe "h0" do
      subject{ h0 }
      it { should == Heading::EMPTY }
      it_should_behave_like "A value" 
    end
    
    describe "h1" do
      subject{ h1 }
      it_should_behave_like "A value" 
    end
    
  end 
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alf-0.10.1 spec/unit/types/test_heading.rb
alf-0.10.0 spec/unit/types/test_heading.rb