Sha256: d50fb5379196ee85a1afcb607210eb7babad230be769d7484334a8a56660efb1

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 KB

Contents

require "spec_helper"

describe SocialAvatarProxy::Config do
  subject { SocialAvatarProxy::Config }
  
  around(:each) do
    SocialAvatarProxy.send(:remove_const, :Config)
    SocialAvatarProxy.const_set(:Config, SocialAvatarProxy::Configuration.new)
  end
  
  let(:image_path) do
    File.join(File.dirname(__FILE__), "../fixtures/image.jpg")
  end

  describe "::default_image" do
    it "should default to nil" do
      expect(subject.default_image).to be_nil
    end

    it "should store a path" do
      subject.configure do
        default_image(image_path)
      end
      expect(subject.default_image.path).to eq(image_path)
    end
  end
  
  describe "::default_image_content_type" do
    it "should default to nil" do
      expect(subject.default_image_content_type).to be_nil
    end
    
    context "with an overridden content type" do
      it "should return the value set" do
        subject.configure do
          default_image(image_path)
          default_image_content_type("something/banana")
        end
        expect(subject.default_image_content_type).to eq("something/banana")
      end
    end
  
    context "with a default_image set" do
      before(:each) do
        subject.configure do
          default_image(image_path)
        end
      end
    
      it "should return the calculated content type" do
        expect(subject.default_image_content_type).to eq("image/jpeg")
      end
    
      it "should set the content type on the image" do
        expect(subject.default_image.content_type).to eq("image/jpeg")
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
social-avatar-proxy-2.0.1 spec/social_avatar_proxy/config_spec.rb
social-avatar-proxy-2.0.0 spec/social_avatar_proxy/config_spec.rb