diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-04-10 13:01:10 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-04-10 13:01:10 +0200 |
commit | 046f4086e4e1ba7c4f47215d30c9c470bb0a67a4 (patch) | |
tree | 6293962a0487c8aaee2512e765753f1d2c650be4 | |
parent | 5fbeb73a76ca21db02146a7686dc13a7c961cc87 (diff) | |
download | gitlab-ce-046f4086e4e1ba7c4f47215d30c9c470bb0a67a4.tar.gz |
Improve test examples for container repository class
-rw-r--r-- | spec/models/container_repository_spec.rb | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/spec/models/container_repository_spec.rb b/spec/models/container_repository_spec.rb index cfb1645f751..6d6c9f2adfc 100644 --- a/spec/models/container_repository_spec.rb +++ b/spec/models/container_repository_spec.rb @@ -4,7 +4,7 @@ describe ContainerRepository do let(:group) { create(:group, name: 'group') } let(:project) { create(:project, path: 'test', group: group) } - let(:container_repository) do + let(:repository) do create(:container_repository, name: 'my_image', project: project) end @@ -23,48 +23,48 @@ describe ContainerRepository do describe 'associations' do it 'belongs to the project' do - expect(container_repository).to belong_to(:project) + expect(repository).to belong_to(:project) end end describe '#tag' do it 'has a test tag' do - expect(container_repository.tag('test')).not_to be_nil + expect(repository.tag('test')).not_to be_nil end end describe '#path' do it 'returns a full path to the repository' do - expect(container_repository.path).to eq('group/test/my_image') + expect(repository.path).to eq('group/test/my_image') end end describe '#manifest' do - subject { container_repository.manifest } - - it { is_expected.not_to be_nil } + it 'returns non-empty manifest' do + expect(repository.manifest).not_to be_nil + end end describe '#valid?' do - subject { container_repository.valid? } - - it { is_expected.to be_truthy } + it 'is a valid repository' do + expect(repository).to be_valid + end end describe '#tags' do - subject { container_repository.tags } - - it { is_expected.not_to be_empty } + it 'returns non-empty tags list' do + expect(repository.tags).not_to be_empty + end end describe '#has_tags?' do it 'has tags' do - expect(container_repository).to have_tags + expect(repository).to have_tags end end describe '#delete_tags!' do - let(:container_repository) do + let(:repository) do create(:container_repository, name: 'my_image', tags: %w[latest rc1], project: project) @@ -72,21 +72,21 @@ describe ContainerRepository do context 'when action succeeds' do it 'returns status that indicates success' do - expect(container_repository.client) + expect(repository.client) .to receive(:delete_repository_tag) .and_return(true) - expect(container_repository.delete_tags!).to be_truthy + expect(repository.delete_tags!).to be_truthy end end context 'when action fails' do it 'returns status that indicates failure' do - expect(container_repository.client) + expect(repository.client) .to receive(:delete_repository_tag) .and_return(false) - expect(container_repository.delete_tags!).to be_falsey + expect(repository.delete_tags!).to be_falsey end end end @@ -100,7 +100,7 @@ describe ContainerRepository do end it 'returns a full location of the repository' do - expect(container_repository.location) + expect(repository.location) .to eq 'registry.gitlab:5000/group/test/my_image' end end @@ -117,7 +117,7 @@ describe ContainerRepository do context 'when repository is not a root repository' do it 'returns false' do - expect(container_repository).not_to be_root_repository + expect(repository).not_to be_root_repository end end end |