Sha256: d679943c63c7c2bd969f3d7d9bed83481ef8a9772e8ef10a07b14ffc7c798b1f

Contents?: true

Size: 1.63 KB

Versions: 39

Compression:

Stored size: 1.63 KB

Contents

require "spec_helper"
require_relative "../../../lib/octopolo/github"

module Octopolo
  module GitHub
    describe User do
      context ".new login" do
        it "remembers the given login" do
          user = User.new "foo"
          user.login.should == "foo"
        end
      end

      context "#author_name" do
        let(:octo) { stub }
        let(:login) { "joeuser" }
        let(:user) { User.new login }

        before do
          user.stub(user_data: octo)
        end

        it "fetches the real name from GitHub" do
          octo.stub(name: "Joe User")
          user.author_name.should == octo.name
        end

        it "returns the login if GitHub user has no name" do
          octo.stub(name: nil)
          user.author_name.should == user.login
        end
      end

      context "#user_data" do
        let(:login) { "joeuser" }
        let(:user) { User.new login }
        let(:octo) { stub }

        it "fetches the data from the User class" do
          User.should_receive(:user_data).with(login) { octo }
          user.user_data.should == octo
        end
      end

      context ".user_data login" do
        let(:base_login) { "joeuser" }
        let(:octo) { stub }

        it "fetches the data from GitHub" do
          login = "#{base_login}#{rand(100000)}"
          GitHub.should_receive(:user).with(login) { octo }
          User.user_data(login).should == octo
        end

        it "caches the data" do
          login = "#{base_login}#{rand(100000)}"
          GitHub.should_receive(:user).once { octo }
          User.user_data(login)
          User.user_data(login)
        end
      end

    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
octopolo-1.12.0 spec/octopolo/github/user_spec.rb
octopolo-1.11.4 spec/octopolo/github/user_spec.rb
octopolo-1.11.3 spec/octopolo/github/user_spec.rb
octopolo-1.11.1 spec/octopolo/github/user_spec.rb
octopolo-1.11.0 spec/octopolo/github/user_spec.rb
octopolo-1.9.0 spec/octopolo/github/user_spec.rb
octopolo-1.8.1 spec/octopolo/github/user_spec.rb
octopolo-1.8.0 spec/octopolo/github/user_spec.rb
octopolo-1.7.1 spec/octopolo/github/user_spec.rb
octopolo-1.7.0 spec/octopolo/github/user_spec.rb
octopolo-1.6.0 spec/octopolo/github/user_spec.rb
octopolo-1.5.3 spec/octopolo/github/user_spec.rb
octopolo-1.5.2 spec/octopolo/github/user_spec.rb
octopolo-1.5.1 spec/octopolo/github/user_spec.rb
octopolo-1.5.0 spec/octopolo/github/user_spec.rb
octopolo-1.4.0 spec/octopolo/github/user_spec.rb
octopolo-1.3.0 spec/octopolo/github/user_spec.rb
octopolo-1.2.1 spec/octopolo/github/user_spec.rb
octopolo-1.2.0 spec/octopolo/github/user_spec.rb
octopolo-1.1.1 spec/octopolo/github/user_spec.rb