From 49118f86cfd1949b82fc0a80b5a01b29e9db36e7 Mon Sep 17 00:00:00 2001 From: Tomas Coufal Date: Wed, 18 Jul 2018 13:07:12 +0200 Subject: [PATCH] Move spec to shared codebase --- .../automation_manager/job_spec.rb | 52 ++++--------------- 1 file changed, 11 insertions(+), 41 deletions(-) diff --git a/spec/models/manageiq/providers/embedded_ansible/automation_manager/job_spec.rb b/spec/models/manageiq/providers/embedded_ansible/automation_manager/job_spec.rb index d9add37a37ed..9b9fa20b42b1 100644 --- a/spec/models/manageiq/providers/embedded_ansible/automation_manager/job_spec.rb +++ b/spec/models/manageiq/providers/embedded_ansible/automation_manager/job_spec.rb @@ -1,49 +1,19 @@ describe ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Job do let(:job) { FactoryGirl.create(:embedded_ansible_job) } + let(:role_enabled) { true } - it_behaves_like 'ansible job' - - describe '#raw_stdout_via_worker' do - before do - EvmSpecHelper.create_guid_miq_server_zone - region = MiqRegion.seed - allow(region).to receive(:role_active?).with("embedded_ansible").and_return(role_enabled) - allow(MiqRegion).to receive(:my_region).and_return(region) - end - - context 'when embedded_ansible role is enabled' do - let(:role_enabled) { true } - - before do - allow(described_class).to receive(:find).and_return(job) - - allow(MiqTask).to receive(:wait_for_taskid) do - request = MiqQueue.find_by(:class_name => described_class.name) - request.update_attributes(:state => MiqQueue::STATE_DEQUEUE) - request.delivered(*request.deliver) - end - end - - it 'gets stdout from the job' do - expect(job).to receive(:raw_stdout).and_return('A stdout from the job') - taskid = job.raw_stdout_via_worker('user') - MiqTask.wait_for_taskid(taskid) - expect(MiqTask.find(taskid)).to have_attributes( - :task_results => 'A stdout from the job', - :status => 'Ok' - ) - end + before do + region = MiqRegion.seed + allow(region).to receive(:role_active?).with("embedded_ansible").and_return(role_enabled) + allow(MiqRegion).to receive(:my_region).and_return(region) + end - it 'returns the error message' do - expect(job).to receive(:raw_stdout).and_throw('Failed to get stdout from the job') - taskid = job.raw_stdout_via_worker('user') - MiqTask.wait_for_taskid(taskid) - expect(MiqTask.find(taskid).message).to include('Failed to get stdout from the job') - expect(MiqTask.find(taskid).status).to eq('Error') - end - end + context 'when embedded_ansible role is enabled' do + it_behaves_like 'ansible job' + end - context 'when embedded_ansible role is disabled' do + context 'when embedded_ansible role is disabled' do + describe '#raw_stdout_via_worker' do let(:role_enabled) { false } it 'returns an error message' do