Sha256: 41fa1f437943a63664de779a11e68d6a3b5032f76e8f4dbae7a1cf96e03c9f37

Contents?: true

Size: 1.4 KB

Versions: 5

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

describe Attachment do
  use_model_class(:Thing)

  before do
    Thing.has_attachment :attachment
  end

  describe ".of_type" do
    before do
      @thing = Thing.new
    end

    describe "when the type is nil" do
      before do
        @type = nil
      end

      describe "when the stream is nil" do
        before do
          @stream = nil
        end

        it "should return a None attachment" do
          attachment = Attachment.of_type(@type, @thing, :attachment, @stream)
          attachment.should be_a(Attachment::None)
        end
      end

      describe "when the stream is not nil" do
        before do
          @stream = Stream.new(temporary_file('test.jpg'))
        end

        it "should return a Base attachment" do
          attachment = Attachment.of_type(@type, @thing, :attachment, @stream)
          attachment.should be_a(Attachment::Base)
        end
      end
    end

    describe "when the type is not nil" do
      before do
        @type = :video
      end

      it "should return an attachment of the specified type" do
        attachment = Attachment.of_type(@type, @thing, :attachment, @stream)
        attachment.should be_a(Attachment::Video)
      end
    end
  end

  describe ".none" do
    it "should return a None attachment" do
      attachment = Attachment.none(Thing.new, :attachment)
      attachment.should be_a(Attachment::None)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bulldog-0.2.4 spec/unit/attachment_spec.rb
bulldog-0.2.3 spec/unit/attachment_spec.rb
bulldog-0.2.2 spec/unit/attachment_spec.rb
bulldog-0.2.1 spec/unit/attachment_spec.rb
bulldog-0.2.0 spec/unit/attachment_spec.rb