Sha256: 8871176fc3d722b2a1c80c95105f7c3cb3478c6539b6f2982cd0398d07d3dece

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe Reviewlette::GithubConnection do
  subject { described_class.new(repo, token) }
  let(:repo) { 'test' }
  let(:token) { 'foo' }
  let(:member1) { double(name: 'test1', github_handle: 'githubtest1') }
  let(:member2) { double(name: 'test2', github_handle: 'githubtest2') }

  describe '.new' do
    it 'initializes octokit client and repo' do
      expect(Octokit::Client).to receive(:new).with(:access_token => token)
      expect(subject.repo).to eq(repo)
    end
  end

  describe '#add_assignees' do
    it 'adds assignees to the GitHub issue' do
      expect(subject.client).to receive(:update_issue).with(repo, 11, assignees: ['test'])
      subject.add_assignees(11, ['test'])
    end
  end

  describe '#comment_reviewers' do
    it 'comments on a given issue' do
      card      = Trello::Card.new
      reviewers = [member1, member2]

      allow(card).to receive(:url).and_return('url')
      expect(subject.client).to receive(:add_comment).with(repo, 11, anything)

      subject.comment_reviewers(11, reviewers, card)
    end
  end

  describe '#pull_requests' do
    it 'lists all pullrequests for a given repository' do
      expect(subject.client).to receive(:pull_requests).with(repo)
      subject.pull_requests
    end
  end

  describe '#repo_exists?' do
    it 'checks if a certain repository exists' do
      expect(subject.client).to receive(:repository?).with(repo)
      subject.repo_exists?
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reviewlette-1.0.0 spec/github_connection_spec.rb