Sha256: d535c589f5b9d00e619ffb469c9dce5003c406537cda7ccd692fdd424c8826eb

Contents?: true

Size: 1.02 KB

Versions: 19

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'
module Finitio
  describe TypeFactory, "DSL#attribute" do

    let(:factory){ TypeFactory.new }

    shared_examples_for "The a:Integer attribute" do

      it{ should be_a(Attribute) }

      it 'should have the correct name' do
        expect(subject.name).to eq(:a)
      end

      it 'should have the correct type' do
        expect(subject.type).to eq(intType)
      end
    end

    context 'when used with a ruby class' do
      subject{
        factory.attribute(:a, Integer)
      }

      it_should_behave_like "The a:Integer attribute"

      it{ should be_required }
    end

    context 'when used with a type' do
      subject{
        factory.attribute(:a, intType)
      }

      it_should_behave_like "The a:Integer attribute"

      it{ should be_required }
    end

    context 'when used for an optional attribute' do
      subject{
        factory.attribute(:a, intType, false)
      }

      it_should_behave_like "The a:Integer attribute"

      it{ should_not be_required }
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
finitio-0.12.0 spec/type_factory/dsl/test_attribute.rb
finitio-0.11.4 spec/type_factory/dsl/test_attribute.rb
finitio-0.11.3 spec/type_factory/dsl/test_attribute.rb
finitio-0.11.2 spec/type_factory/dsl/test_attribute.rb
finitio-0.11.1 spec/type_factory/dsl/test_attribute.rb
finitio-0.10.0 spec/type_factory/dsl/test_attribute.rb
finitio-0.9.1 spec/type_factory/dsl/test_attribute.rb
finitio-0.9.0 spec/type_factory/dsl/test_attribute.rb
finitio-0.8.0 spec/type_factory/dsl/test_attribute.rb
finitio-0.7.0 spec/type_factory/dsl/test_attribute.rb
finitio-0.7.0.pre.rc4 spec/type_factory/dsl/test_attribute.rb
finitio-0.7.0.pre.rc3 spec/type_factory/dsl/test_attribute.rb
finitio-0.7.0.pre.rc2 spec/type_factory/dsl/test_attribute.rb
finitio-0.7.0.pre.rc1 spec/type_factory/dsl/test_attribute.rb
finitio-0.6.1 spec/type_factory/dsl/test_attribute.rb
finitio-0.6.0 spec/type_factory/dsl/test_attribute.rb
finitio-0.5.2 spec/type_factory/dsl/test_attribute.rb
finitio-0.5.1 spec/type_factory/dsl/test_attribute.rb
finitio-0.5.0 spec/type_factory/dsl/test_attribute.rb