Sha256: 1c50c3eb46a388908671dc0969d6504c9d3409bd0e7de1211a8db3cb936f892f

Contents?: true

Size: 1.92 KB

Versions: 39

Compression:

Stored size: 1.92 KB

Contents

# -*- coding: utf-8 -*-

require 'spec_helper'
require 'profile'

describe "Profile::Service" do
  describe "GitHub" do
    before do
      require 'json'
      allow_any_instance_of(Profile::Service::GitHub).to receive(:fetch).and_return(JSON.parse(File.read("spec/fixtures/github.json")))

      # workaround for run spec on various environment.
      require 'openssl'
      OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE

      # http://develop.github.com/p/general.html
      @profile = Profile::Service::GitHub.new("schacon")
    end

    it "should include name, mail, image properties" do
      expect(@profile.name).to eq("Scott Chacon")
      expect(@profile.mail).to eq("schacon@gmail.com")
      expect(@profile.image).to eq("https://avatars.githubusercontent.com/u/70?v=3")
    end
  end

  describe "Gravatar" do
    # http://ja.gravatar.com/site/implement/hash/

    before do
      require 'json'
      allow_any_instance_of(Profile::Service::Gravatar).to receive(:fetch).and_return(JSON.parse(File.read("spec/fixtures/gravatar.json")))

      @profile = Profile::Service::Gravatar.new("iHaveAn@email.com")
    end
    it "should include name, mail, image properties" do
      expect(@profile.name).to eq("tDiary")
      expect(@profile.mail).to eq("iHaveAn@email.com")
      expect(@profile.image).to eq("http://2.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802")
    end

    context 'with options' do
      before do
        @profile = Profile::Service::Gravatar.new("iHaveAn@email.com", :size => 40)
      end

      it "should specify size option" do
        expect(@profile.image).to eq("http://2.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802?s=40")
      end
    end
  end

  describe "Hatena" do
    before do
      @profile = Profile::Service::Hatena.new("kmachu")
    end

    it "should include image property" do
      expect(@profile.image).to eq("http://www.hatena.ne.jp/users/km/kmachu/profile.gif")
    end
  end
end

Version data entries

39 entries across 34 versions & 2 rubygems

Version Path
tdiary-contrib-5.3.0 spec/profile_spec.rb
tdiary-contrib-5.2.4 spec/profile_spec.rb
tdiary-contrib-5.2.3 spec/profile_spec.rb
tdiary-contrib-5.2.2 spec/profile_spec.rb
tdiary-contrib-5.2.1 spec/profile_spec.rb
tdiary-contrib-5.2.0 spec/profile_spec.rb
tdiary-contrib-5.1.7 spec/profile_spec.rb
tdiary-contrib-5.1.6 spec/profile_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/bundler/gems/tdiary-contrib-d1e41204db13/spec/profile_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-contrib-5.1.4/spec/profile_spec.rb
tdiary-contrib-5.1.5 spec/profile_spec.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-contrib-5.1.4/spec/profile_spec.rb
tdiary-contrib-5.1.4 spec/profile_spec.rb
tdiary-contrib-5.1.3 spec/profile_spec.rb
tdiary-contrib-5.1.2 spec/profile_spec.rb
tdiary-contrib-5.1.1 spec/profile_spec.rb
tdiary-contrib-5.1.0 spec/profile_spec.rb
tdiary-contrib-5.0.13 spec/profile_spec.rb
tdiary-contrib-5.0.12 spec/profile_spec.rb
tdiary-contrib-5.0.11 spec/profile_spec.rb