Sha256: 7f8ab93844fc9d6698da0c7a96cc584ac5ae5612d89261d091b714f28cc6b216
Contents?: true
Size: 1.23 KB
Versions: 27
Compression:
Stored size: 1.23 KB
Contents
require 'spec_helper' describe Aptible::CLI::Agent do before { subject.stub(:ask) } before { subject.stub(:save_token) } describe '#version' do it 'should print the version' do version = Aptible::CLI::VERSION expect(STDOUT).to receive(:puts).with "aptible-cli v#{version}" subject.version end end describe '#login' do let(:token) { double('Aptible::Auth::Token') } before { OAuth2::Error.send :define_method, :initialize, -> {} } before { token.stub(:access_token) { 'access_token' } } it 'should save a token to ~/.aptible/tokens' do Aptible::Auth::Token.stub(:create) { token } expect(subject).to receive(:save_token).with('access_token') subject.login end it 'should raise an error if authentication fails' do Aptible::Auth::Token.stub(:create).and_raise OAuth2::Error expect do subject.login end.to raise_error 'Could not authenticate with given credentials' end it 'should use command line arguments if passed' do options = { email: 'test@example.com', password: 'password' } subject.stub(:options) { options } expect(Aptible::Auth::Token).to receive(:create).with(options) { token } subject.login end end end
Version data entries
27 entries across 27 versions & 1 rubygems