Sha256: 3ddc263409d4db0669cc3f5a657d09cfe70391cf75e75911fb19e25c5d959dcf

Contents?: true

Size: 937 Bytes

Versions: 14

Compression:

Stored size: 937 Bytes

Contents

require "spec_helper"

describe Paperclip::AttachmentRegistry do
  context "for" do
    before do
      class AdapterTest
        def initialize(_target, _ = {}); end
      end
      @subject = Paperclip::AdapterRegistry.new
      @subject.register(AdapterTest) { |t| Symbol === t }
    end

    it "returns the class registered for the adapted type" do
      assert_equal AdapterTest, @subject.for(:target).class
    end
  end

  context "registered?" do
    before do
      class AdapterTest
        def initialize(_target, _ = {}); end
      end
      @subject = Paperclip::AdapterRegistry.new
      @subject.register(AdapterTest) { |t| Symbol === t }
    end

    it "returns true when the class of this adapter has been registered" do
      assert @subject.registered?(AdapterTest.new(:target))
    end

    it "returns false when the adapter has not been registered" do
      assert !@subject.registered?(Object)
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
kt-paperclip-7.2.2 spec/paperclip/io_adapters/registry_spec.rb
kt-paperclip-7.2.1 spec/paperclip/io_adapters/registry_spec.rb
kt-paperclip-7.2.0 spec/paperclip/io_adapters/registry_spec.rb
kt-paperclip-6.4.2 spec/paperclip/io_adapters/registry_spec.rb
kt-paperclip-7.1.1 spec/paperclip/io_adapters/registry_spec.rb
kt-paperclip-7.1.0 spec/paperclip/io_adapters/registry_spec.rb
kt-paperclip-7.0.1 spec/paperclip/io_adapters/registry_spec.rb
kt-paperclip-7.0.0 spec/paperclip/io_adapters/registry_spec.rb
kt-paperclip-6.4.1 spec/paperclip/io_adapters/registry_spec.rb
kt-paperclip-6.4.0 spec/paperclip/io_adapters/registry_spec.rb
kt-paperclip-6.3.0 spec/paperclip/io_adapters/registry_spec.rb
kt-paperclip-6.2.2 spec/paperclip/io_adapters/registry_spec.rb
kt-paperclip-6.2.1 spec/paperclip/io_adapters/registry_spec.rb
kt-paperclip-6.2.0 spec/paperclip/io_adapters/registry_spec.rb