Sha256: 6a0f865a62826fa60a57629cdca32c13e49068fbd3c471cb1868e990c219f4d9

Contents?: true

Size: 1.39 KB

Versions: 17

Compression:

Stored size: 1.39 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(test_image_file)
        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

17 entries across 17 versions & 1 rubygems

Version Path
bulldog-0.1.1 spec/unit/attachment_spec.rb
bulldog-0.1.0 spec/unit/attachment_spec.rb
bulldog-0.0.15 spec/unit/attachment_spec.rb
bulldog-0.0.14 spec/unit/attachment_spec.rb
bulldog-0.0.13 spec/unit/attachment_spec.rb
bulldog-0.0.12 spec/unit/attachment_spec.rb
bulldog-0.0.11 spec/unit/attachment_spec.rb
bulldog-0.0.10 spec/unit/attachment_spec.rb
bulldog-0.0.9 spec/unit/attachment_spec.rb
bulldog-0.0.8 spec/unit/attachment_spec.rb
bulldog-0.0.7 spec/unit/attachment_spec.rb
bulldog-0.0.6 spec/unit/attachment_spec.rb
bulldog-0.0.5 spec/unit/attachment_spec.rb
bulldog-0.0.3 spec/unit/attachment_spec.rb
bulldog-0.0.4 spec/unit/attachment_spec.rb
bulldog-0.0.2 spec/unit/attachment_spec.rb
bulldog-0.0.1 spec/unit/attachment_spec.rb