Sha256: ce21665530616f77a150d0f3d5777bf53c11bd9e9bfafa65155a170fc4bba645
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
require_relative '../../helper' describe GitDuplicator::Services::GithubRepository do let(:credentials) do { oauth2_token: ENV['GITHUB_ACCESS_TOKEN'] } end let(:name) { ENV['TESTING_REPO'] } let(:owner) { ENV['GITHUB_USER'] } let(:options) do { has_issues: false, has_wiki: false } 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 + "/repos/#{owner}/#{name}") .with( headers: { 'Authorization' => "token #{credentials[:oauth2_token]}" } ) .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 + "/repos/#{owner}/#{name}") .to_return(body: 'something wrong', status: 401) expect { repo.delete } .to raise_error(GitDuplicator::RepositoryDeletionError) end end describe '#create' do it 'creates the repository in case of not defined' do stub_request(:post, described_class::BASE_URI + '/user/repos') .with( body: options.merge(name: name).to_json, headers: { 'Authorization' => "token #{credentials[:oauth2_token]}" } ) .to_return(body: '', status: 201) expect { repo.create }.not_to raise_error end it 'raises an exception in case of errors' do stub_request(:post, described_class::BASE_URI + '/user/repos') .with(body: options.merge(name: name).to_json) .to_return(body: 'something wrong', status: 401) expect { repo.create } .to raise_error(GitDuplicator::RepositoryCreationError) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
git_duplicator-0.0.1 | spec/git_duplicator/services/github_spec.rb |