Sha256: 3fa0d4256c63a8fbe5499a824f360b0621397404231eb226cc88001377ec459b

Contents?: true

Size: 1.35 KB

Versions: 16

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'
module Finitio
  describe Heading, "to_name" do

    let(:red)       { Attribute.new(:red,  intType)        }
    let(:blue)      { Attribute.new(:blue, intType)        }
    let(:maybe_blue){ Attribute.new(:blue, intType, false) }

    let(:heading){ Heading.new(attributes) }

    subject{ heading.to_name }

    context 'with no attribute' do
      let(:attributes){
        [ ]
      }

      it{ should eq('') }
    end

    context 'with one attribute' do
      let(:attributes){
        [ red ]
      }

      it{ should eq('red: intType') }
    end

    context 'with multiple attributes' do
      let(:attributes){
        [ red, blue ]
      }

      it{ should eq('red: intType, blue: intType') }
    end

    context 'with some optional attributes' do
      let(:attributes){
        [ red, maybe_blue ]
      }

      it{ should eq('red: intType, blue :? intType') }
    end

    context 'when allowing extra' do
      let(:heading){ Heading.new([red], allow_extra: true) }

      it{ should eq('red: intType, ...') }
    end

    context 'when allowing extra to a type' do
      let(:heading){ Heading.new([red], allow_extra: intType) }

      it{ should eq('red: intType, ...: intType') }
    end

    context 'when allowing extra only' do
      let(:heading){ Heading.new([], allow_extra: true) }

      it{ should eq('...') }
    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
finitio-0.12.0 spec/heading/test_to_name.rb
finitio-0.11.4 spec/heading/test_to_name.rb
finitio-0.11.3 spec/heading/test_to_name.rb
finitio-0.11.2 spec/heading/test_to_name.rb
finitio-0.11.1 spec/heading/test_to_name.rb
finitio-0.10.0 spec/heading/test_to_name.rb
finitio-0.9.1 spec/heading/test_to_name.rb
finitio-0.9.0 spec/heading/test_to_name.rb
finitio-0.8.0 spec/heading/test_to_name.rb
finitio-0.7.0 spec/heading/test_to_name.rb
finitio-0.7.0.pre.rc4 spec/heading/test_to_name.rb
finitio-0.7.0.pre.rc3 spec/heading/test_to_name.rb
finitio-0.7.0.pre.rc2 spec/heading/test_to_name.rb
finitio-0.7.0.pre.rc1 spec/heading/test_to_name.rb
finitio-0.6.1 spec/heading/test_to_name.rb
finitio-0.6.0 spec/heading/test_to_name.rb