Sha256: 5e4e3f92f33307706d17285a073804cb0d31ee67d75a2a83afb0536eaba7fe9c

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

shared_examples_for GroupDocs::Api::Entity do
  before(:each) do
    # make sure necessary attribute exist
    described_class.class_eval('attr_accessor :id, :test')
    # stub required attributes
    case described_class.name
    when 'GroupDocs::Document'
      described_class.any_instance.stub(:file => GroupDocs::Storage::File.new)
    when 'GroupDocs::Document::Annotation'
      GroupDocs::Document.any_instance.stub(:file => GroupDocs::Storage::File.new)
      described_class.any_instance.stub(:document => GroupDocs::Document.new)
    when 'GroupDocs::Document::Annotation::Reply'
      GroupDocs::Document.any_instance.stub(:file => GroupDocs::Storage::File.new)
      GroupDocs::Document::Annotation.any_instance.stub(:document => GroupDocs::Document.new)
      described_class.any_instance.stub(:annotation => GroupDocs::Document::Annotation.new)
    when 'GroupDocs::Questionnaire::Collector'
      described_class.any_instance.stub(:questionnaire => GroupDocs::Questionnaire.new)
    end
  end

  it { should be_a(GroupDocs::Api::Entity) }

  describe '#initialize' do
    it 'allows passing options' do
      object = described_class.new(:id => 1, :test => 'Test')
      object.id.should == 1
      object.test.should == 'Test'
    end

    it 'calls passed block for self' do
      object = described_class.new do |object|
        object.id = 1
        object.test = 'Test'
      end
      object.id.should == 1
      object.test.should == 'Test'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
groupdocs-2.3.0 spec/support/shared_examples/api/entity.rb