Sha256: 672a0fe54ac55fa09d1836ba9213b2e57f37ac1911f99134705663f1edbe4698

Contents?: true

Size: 1.42 KB

Versions: 10

Compression:

Stored size: 1.42 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

10 entries across 10 versions & 1 rubygems

Version Path
groupdocs-1.2.11 spec/support/shared_examples/api/entity.rb
groupdocs-1.2.10 spec/support/shared_examples/api/entity.rb
groupdocs-1.2.9 spec/support/shared_examples/api/entity.rb
groupdocs-1.2.8 spec/support/shared_examples/api/entity.rb
groupdocs-1.2.7 spec/support/shared_examples/api/entity.rb
groupdocs-1.2.6 spec/support/shared_examples/api/entity.rb
groupdocs-1.2.3 spec/support/shared_examples/api/entity.rb
groupdocs-1.2.2 spec/support/shared_examples/api/entity.rb
groupdocs-1.2.1 spec/support/shared_examples/api/entity.rb
groupdocs-1.2.0 spec/support/shared_examples/api/entity.rb