Sha256: 0f813c6dbb8a0dbe7b038f2f8cfbc5bf9f77a2f1eb580b4b1ecadccce25a732d

Contents?: true

Size: 1.02 KB

Versions: 6

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require 'travis/client/auto_login'
require 'spec_helper'

describe Travis::Client::AutoLogin do
  let(:auto_login_with_token) { described_class.new(Travis::Client.new, { config_file: travis_config }) }
  let(:auto_login_without_token) { described_class.new(Travis::Client.new) }
  let(:travis_config) { File.expand_path('../support/fake_travis_config.yml', File.dirname(__FILE__)) }

  context 'when user authenticates' do
    context 'when user has a token in cli config' do
      it 'does not call Tools::Github#with_token' do
        expect_any_instance_of(Travis::Tools::Github).not_to receive(:with_token)
        auto_login_with_token.authenticate
      end
    end

    context 'when user does not have a token in cli config' do
      before { auto_login_without_token.github.stub(:with_token).and_return(true) }

      it 'calls Tools::Github#with_token' do
        expect(auto_login_without_token.github).to receive(:with_token)
        auto_login_without_token.authenticate
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
travis-1.14.0 spec/client/auto_login_spec.rb
travis-1.13.3 spec/client/auto_login_spec.rb
travis-1.13.2 spec/client/auto_login_spec.rb
travis-1.13.1 spec/client/auto_login_spec.rb
travis-1.13.0 spec/client/auto_login_spec.rb
travis-1.12.0 spec/client/auto_login_spec.rb