Sha256: 7b1319d175a3318273f92da564fd83d1d528f2d543d31b255cf1d2cbdff56eac

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 KB

Contents

require 'spec_helper'

require_relative '../../lib/geet/git/repository'
require_relative '../../lib/geet/services/list_issues'

describe Geet::Services::ListIssues do
  let(:repository) { Geet::Git::Repository.new }
  let(:upstream_repository) { Geet::Git::Repository.new(upstream: true) }

  it 'should list the issues' do
    allow(repository).to receive(:remote).with('origin').and_return('git@github.com:donaldduck/testrepo')

    expected_output = <<~STR
      5. Title 2 (https://github.com/donaldduck/testrepo/issues/5)
      4. Title 1 (https://github.com/donaldduck/testrepo/issues/4)
    STR
    expected_issue_numbers = [5, 4]

    actual_output = StringIO.new

    service_result = VCR.use_cassette("list_issues") do
      described_class.new.execute(repository, output: actual_output)
    end

    actual_issue_numbers = service_result.map(&:number)

    expect(actual_output.string).to eql(expected_output)
    expect(actual_issue_numbers).to eql(expected_issue_numbers)
  end

  it 'should list the upstream issues' do
    allow(upstream_repository).to receive(:remote).with('origin').and_return('git@github.com:donaldduck/testrepo_2f')
    allow(upstream_repository).to receive(:remote).with('upstream').and_return('git@github.com:donald-fr/testrepo_u')

    expected_output = <<~STR
      2. Title 2 U (https://github.com/donald-fr/testrepo_u/issues/2)
      1. Title 1 U (https://github.com/donald-fr/testrepo_u/issues/1)
    STR
    expected_issue_numbers = [2, 1]

    actual_output = StringIO.new

    service_result = VCR.use_cassette("list_issues_upstream") do
      described_class.new.execute(upstream_repository, output: actual_output)
    end

    actual_issue_numbers = service_result.map(&:number)

    expect(actual_output.string).to eql(expected_output)
    expect(actual_issue_numbers).to eql(expected_issue_numbers)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geet-0.1.11 spec/integration/list_issues_spec.rb