Sha256: 1f410ccc7b158f4f13f6409a7c918a5f80faab0d222a9ee43842719289f07033

Contents?: true

Size: 1.54 KB

Versions: 23

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

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

module Geet
  describe Services::OpenRepo do
    let(:git_client) { Utils::GitClient.new }
    let(:repository) { Git::Repository.new(git_client: git_client) }

    OWNER = 'donaldduck'
    REPOSITORY_NAME = 'testrepo'

    REMOTE_URLS = {
      'git' => "git@github.com:#{OWNER}/#{REPOSITORY_NAME}",
      'https' => "https://github.com/#{OWNER}/#{REPOSITORY_NAME}",
    }

    context 'should open the PR for the current branch' do
      REMOTE_URLS.each do |protocol, remote_url|
        it "with #{protocol} protocol" do
          allow(git_client).to receive(:remote).with(no_args).and_return(remote_url)

          expected_url = "https://github.com/#{OWNER}/#{REPOSITORY_NAME}"
          expected_output = ""

          actual_output = StringIO.new
          service_instance = described_class.new(repository, out: actual_output, git_client: git_client)

          expect(service_instance).to receive(:open_file_with_default_application).with(expected_url) do
            # do nothing; just don't open the browser
          end

          execution_result = VCR.use_cassette('github_com/open_repo') do
            service_instance.execute
          end

          expect(actual_output.string).to eql(expected_output)
          expect(execution_result).to eql(expected_url)
        end
      end
    end # context 'should open the PR for the current branch'
  end # describe Services::OpenRepo
end # module Geet

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
geet-0.22.0 spec/integration/open_repo_spec.rb
geet-0.21.0 spec/integration/open_repo_spec.rb
geet-0.19.0 spec/integration/open_repo_spec.rb
geet-0.18.0 spec/integration/open_repo_spec.rb
geet-0.17.0 spec/integration/open_repo_spec.rb
geet-0.16.0 spec/integration/open_repo_spec.rb
geet-0.15.0 spec/integration/open_repo_spec.rb
geet-0.14.0 spec/integration/open_repo_spec.rb
geet-0.13.0 spec/integration/open_repo_spec.rb
geet-0.12.0 spec/integration/open_repo_spec.rb
geet-0.11.0 spec/integration/open_repo_spec.rb
geet-0.10.0 spec/integration/open_repo_spec.rb
geet-0.9.0 spec/integration/open_repo_spec.rb
geet-0.8.0 spec/integration/open_repo_spec.rb
geet-0.7.0 spec/integration/open_repo_spec.rb
geet-0.6.0 spec/integration/open_repo_spec.rb
geet-0.5.0 spec/integration/open_repo_spec.rb
geet-0.4.4 spec/integration/open_repo_spec.rb
geet-0.4.3 spec/integration/open_repo_spec.rb
geet-0.4.2 spec/integration/open_repo_spec.rb