Sha256: 143cc9b090a33b471aae8b2dc721e063d6ac8df916f27508e45d59d3e1a9271e

Contents?: true

Size: 1.8 KB

Versions: 7

Compression:

Stored size: 1.8 KB

Contents

require 'rails_helper'

describe RepoAnalyzer::GithubExtractor, repo_analyzer_extractor_helpers: true do
  describe "#extract" do
    let(:commits) do
      [
        {
          commit: {
            author: {
              date: "1984-04-06"
            }
          },
          author: {
            login: "lean"
          }
        },
        {
          commit: {
            author: {
              date: "1983-03-02"
            }
          },
          author: {
            login: "lean"
          }
        },
        {
          commit: {
            author: {
              date: "1982-03-01"
            }
          },
          author: {
            login: "santi"
          }
        }
      ]
    end

    let(:contributors) do
      [
        {
          login: "lean",
          avatar_url: "http://lean@github.com",
          contributions: 200
        },
        {
          login: "matias",
          avatar_url: "http://mati@github.com",
          contributions: 100
        },
        {
          login: "santi",
          avatar_url: "http://santi@github.com",
          contributions: 700
        }
      ]
    end

    before do
      allow(project_data_bridge).to receive(:commits).and_return(commits)
      allow(project_data_bridge).to receive(:contributors).and_return(contributors)
    end

    def last_contributors_logins
      extract[:github_extractor][:last_contributors].map { |contributor| contributor[:login] }
    end

    def contributors_logins
      extract[:github_extractor][:contributors].map { |contributor| contributor[:login] }
    end

    it { expect(extract[:github_extractor][:last_commit_date]).to eq("1984-04-06") }
    it { expect(contributors_logins).to contain_exactly("lean", "matias", "santi") }
    it { expect(last_contributors_logins).to contain_exactly("lean", "santi") }
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
repo_analyzer-1.6.0 spec/extractors/github_extractor_spec.rb
repo_analyzer-1.5.0 spec/extractors/github_extractor_spec.rb
repo_analyzer-1.4.0 spec/extractors/github_extractor_spec.rb
repo_analyzer-1.3.0 spec/extractors/github_extractor_spec.rb
repo_analyzer-1.2.0 spec/extractors/github_extractor_spec.rb
repo_analyzer-1.1.0 spec/extractors/github_extractor_spec.rb
repo_analyzer-1.0.0 spec/extractors/github_extractor_spec.rb