debian-mirror-gitlab/qa/spec/resource/events/project_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

76 lines
2.2 KiB
Ruby
Raw Permalink Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2021-01-03 14:25:43 +05:30
RSpec.describe QA::Resource::Events::Project do
2019-07-07 11:18:12 +05:30
let(:resource) do
Class.new(QA::Resource::Base) do
def api_get_path
'/foo'
end
2021-02-22 17:27:13 +05:30
def default_branch
'master'
end
2019-07-07 11:18:12 +05:30
end
end
2020-10-24 23:57:45 +05:30
2019-07-07 11:18:12 +05:30
let(:all_events) do
[
{
"action_name": "pushed",
"push_data": {
"commit_title": "foo commit"
}
},
{
"action_name": "pushed",
"push_data": {
"ref": "master"
}
},
{
"action_name": "pushed",
"push_data": {
"ref": "another-branch"
}
}
]
end
before do
allow(subject).to receive(:max_wait).and_return(0.01)
2020-03-13 15:44:24 +05:30
allow(subject).to receive(:raise_on_failure).and_return(false)
2019-07-07 11:18:12 +05:30
allow(subject).to receive(:parse_body).and_return(all_events)
end
subject { resource.tap { |f| f.include(described_class) }.new }
describe "#wait_for_push" do
it 'waits for a push with a specified commit message' do
expect(subject).to receive(:api_get_from).with('/foo/events?action=pushed')
expect { subject.wait_for_push('foo commit') }.not_to raise_error
end
it 'raises an error if a push with the specified commit message is not found' do
expect(subject).to receive(:api_get_from).with('/foo/events?action=pushed').at_least(:once)
expect { subject.wait_for_push('bar') }.to raise_error(QA::Resource::Events::EventNotFoundError)
end
end
describe "#wait_for_push_new_branch" do
2021-02-22 17:27:13 +05:30
it 'waits for a push to the default branch if no branch is given' do
2019-07-07 11:18:12 +05:30
expect(subject).to receive(:api_get_from).with('/foo/events?action=pushed')
expect { subject.wait_for_push_new_branch }.not_to raise_error
end
it 'waits for a push to the given branch' do
expect(subject).to receive(:api_get_from).with('/foo/events?action=pushed')
expect { subject.wait_for_push_new_branch('another-branch') }.not_to raise_error
end
it 'raises an error if a push with the specified branch is not found' do
expect(subject).to receive(:api_get_from).with('/foo/events?action=pushed').at_least(:once)
expect { subject.wait_for_push_new_branch('bar') }.to raise_error(QA::Resource::Events::EventNotFoundError)
end
end
end