debian-mirror-gitlab/spec/lib/bitbucket/connection_spec.rb

46 lines
1.2 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
describe Bitbucket::Connection do
before do
2020-01-01 13:55:28 +05:30
allow_next_instance_of(described_class) do |instance|
allow(instance).to receive(:provider).and_return(double(app_id: '', app_secret: ''))
end
2017-08-17 22:00:37 +05:30
end
describe '#get' do
it 'calls OAuth2::AccessToken::get' do
2020-01-01 13:55:28 +05:30
expect_next_instance_of(OAuth2::AccessToken) do |instance|
expect(instance).to receive(:get).and_return(double(parsed: true))
end
2017-08-17 22:00:37 +05:30
connection = described_class.new({})
connection.get('/users')
end
end
describe '#expired?' do
it 'calls connection.expired?' do
2020-01-01 13:55:28 +05:30
expect_next_instance_of(OAuth2::AccessToken) do |instance|
expect(instance).to receive(:expired?).and_return(true)
end
2017-08-17 22:00:37 +05:30
expect(described_class.new({}).expired?).to be_truthy
end
end
describe '#refresh!' do
it 'calls connection.refresh!' do
response = double(token: nil, expires_at: nil, expires_in: nil, refresh_token: nil)
2020-01-01 13:55:28 +05:30
expect_next_instance_of(OAuth2::AccessToken) do |instance|
expect(instance).to receive(:refresh!).and_return(response)
end
2017-08-17 22:00:37 +05:30
described_class.new({}).refresh!
end
end
end