Sha256: 3eca5607f38998ff3e9833a18220d935fb6985e96233d405f593f177d25ae67e
Contents?: true
Size: 1.83 KB
Versions: 1
Compression:
Stored size: 1.83 KB
Contents
require_relative '../../helper' describe GitDuplicator::Services::BitbucketRepository do let(:credentials) do { consumer_key: ENV['BITBUCKET_CONSUMER_KEY'], consumer_secret: ENV['BITBUCKET_CONSUMER_SECRET'], token: ENV['BITBUCKET_TOKEN'], token_secret: ENV['BITBUCKET_TOKEN_SECRET'] } end let(:name) { ENV['TESTING_REPO'] } let(:owner) { ENV['BITBUCKET_USER'] } let(:options) do { scm: 'git', is_private: true, fork_policy: 'no_public_forks' } end let(:repo) { described_class.new(name, owner, credentials, options) } describe '#delete' do it 'deletes the repo in case it exists' do stub_request(:delete, described_class::BASE_URI + "/repositories/#{owner}/#{name}") .to_return(body: '', status: 204) expect { repo.delete }.not_to raise_error end it 'raises an exception in case of unknow problem' do stub_request(:delete, described_class::BASE_URI + "/repositories/#{owner}/#{name}") .to_return(body: 'something wrong', status: 401) expect { repo.delete } .to raise_error(GitDuplicator::RepositoryDeletionError, /something wrong/) end end describe '#create' do it 'creates the repository in case of not defined' do stub_request(:post, described_class::BASE_URI + "/repositories/#{owner}/#{name}") .with(body: options.to_json) .to_return(body: '', status: 200) expect { repo.create }.not_to raise_error end it 'raises an exception in case of errors' do stub_request(:post, described_class::BASE_URI + "/repositories/#{owner}/#{name}") .with(body: options.to_json) .to_return(body: 'something wrong', status: 401) expect { repo.create } .to raise_error(GitDuplicator::RepositoryCreationError, /something wrong/) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
git_duplicator-0.0.1 | spec/git_duplicator/services/bitbucket_spec.rb |