Sha256: 775f9c4ad8db6c5dc6e34670e6f76e94a838bc015158ca2a7f426549cf7bad9c

Contents?: true

Size: 1.88 KB

Versions: 4

Compression:

Stored size: 1.88 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Dimelo::CCP::User do
  describe "#avatar_url" do
    before :each do
      @user = Dimelo::CCP::User.new
    end
    describe "with avatar" do
      before :each do
        @user.avatar = {
          "id" => 1076212,
          "original" => {
            "height" => 960,
            "width" => 640,
            "url" => "http://dimelo.machin.amazonaws.com/identity_avatars/c567/avata.png"
          },
          "small" => {
            "height" => 32,
            "width" => 32,
            "url" => "http://dimelo.machin.amazonaws.com/identity_avatars/c567/avatar_small.png"
          },
          "normal" => {
            "height" => 48,
            "width" => 48,
            "url" => "http://dimelo.machin.amazonaws.com/identity_avatars/c567/avatar_normal.png"
          }
        }
      end

      describe "with avatar_url" do
        before :each do
          @user.avatar_url = "http://dimelo.machin/other_avatar.png"
        end

        it "should return avatar_url" do
          expect(@user.avatar_url).to eq("http://dimelo.machin/other_avatar.png")
        end
      end

      it "should return normal avatar" do
        expect(@user.avatar_url).to eq("http://dimelo.machin.amazonaws.com/identity_avatars/c567/avatar_normal.png")
      end

      it "should return asked size avatar" do
        expect(@user.avatar_url("small")).to eq("http://dimelo.machin.amazonaws.com/identity_avatars/c567/avatar_small.png")
      end
    end

    describe "without avatar" do
      describe "with avatar_url" do
        before :each do
          @user.avatar_url = "http://dimelo.machin/other_avatar.png"
        end

        it "should return avatar_url" do
          expect(@user.avatar_url).to eq("http://dimelo.machin/other_avatar.png")
        end
      end

      it "should return nil" do
        expect(@user.avatar_url).to eq(nil)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dimelo_ccp_api-0.5.0 spec/lib/dimelo/ccp/api/model/user_spec.rb
dimelo_ccp_api-0.4.4 spec/lib/dimelo/ccp/api/model/user_spec.rb
dimelo_ccp_api-0.4.3 spec/lib/dimelo/ccp/api/model/user_spec.rb
dimelo_ccp_api-0.4.2 spec/lib/dimelo/ccp/api/model/user_spec.rb