Sha256: 77182923194c9bf3e43630488cff3766aaa32b038c1884496fe648bce8964ee3

Contents?: true

Size: 1.77 KB

Versions: 9

Compression:

Stored size: 1.77 KB

Contents

require "spec_helper"

describe SocialAvatarProxy::PathHelpers do
  subject do
    Class.new do
      include SocialAvatarProxy::PathHelpers
    end.new
  end
  
  describe "#avatar_base_path" do
    it "should return empty string as default" do
      expect(subject.avatar_base_path).to eq("")
    end
  end
  
  describe "#avatar_base_path=" do
    it "should update the #avatar_base_path" do
      subject.avatar_base_path = "/test"
      expect(subject.avatar_base_path).to eq("/test")
    end
    
    it "should remove trailing slashes" do
      subject.avatar_base_path = "/test/"
      expect(subject.avatar_base_path).to eq("/test")
    end
    
    it "should prepend a slash if missing" do
      subject.avatar_base_path = "test"
      expect(subject.avatar_base_path).to eq("/test")
    end
  end
  
  describe "#twitter_avatar_path" do
    context "with no #avatar_base_path" do
      it "should join the service and identifier" do
        expect(subject.twitter_avatar_path("dave")).to eq "/twitter/dave"
      end
    end
    
    context "with a custom #avatar_base_path" do
      it "should join the base path, service and identifier" do
        subject.avatar_base_path = "avatars"
        expect(subject.twitter_avatar_path("dave")).to eq "/avatars/twitter/dave"
      end
    end
  end
  
  describe "#facebook_avatar_path" do
    context "with no #avatar_base_path" do
      it "should join the service and identifier" do
        expect(subject.facebook_avatar_path("dave")).to eq "/facebook/dave"
      end
    end
    
    context "with a custom #avatar_base_path" do
      it "should join the base path, service and identifier" do
        subject.avatar_base_path = "avatars"
        expect(subject.facebook_avatar_path("dave")).to eq "/avatars/facebook/dave"
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
social-avatar-proxy-2.0.1 spec/social_avatar_proxy/path_helpers_spec.rb
social-avatar-proxy-2.0.0 spec/social_avatar_proxy/path_helpers_spec.rb
social-avatar-proxy-1.2.0 spec/social_avatar_proxy/path_helpers_spec.rb
social-avatar-proxy-1.1.0 spec/social_avatar_proxy/path_helpers_spec.rb
social-avatar-proxy-1.0.1 spec/social_avatar_proxy/path_helpers_spec.rb
social-avatar-proxy-1.0.0 spec/social_avatar_proxy/path_helpers_spec.rb
social-avatar-proxy-0.0.9 spec/social_avatar_proxy/path_helpers_spec.rb
social-avatar-proxy-0.0.8 spec/social_avatar_proxy/path_helpers_spec.rb
social-avatar-proxy-0.0.7 spec/social_avatar_proxy/path_helpers_spec.rb