From 671a346512369ec89e19135b6e58aa63e09018a0 Mon Sep 17 00:00:00 2001 From: Nick LaMuro Date: Wed, 14 Feb 2018 13:27:15 -0600 Subject: [PATCH] Fix automate specs after MulticastLogger changes Specs that used `stub_automate_workspace` would fail no because, previously, the calls to `resolve_automation_object`: def self.resolve_automation_object(uri, user_obj, attr = nil, options = {}, readonly = false) raise "User object not passed in" unless user_obj.kind_of?(User) uri = create_automation_object(uri, attr, options) if attr options[:uri] = uri MiqAeWorkspaceRuntime.instantiate(uri, user_obj, :readonly => readonly).tap do |ws| $miq_ae_logger.debug { ws.to_expanded_xml } end end Would trigger the `$miq_ae_logger.debug` line and just no-op, because the underlying logger would be set to info. This change allows the `double` that is instantiated in `stub_automate_workspace` to also receive `#to_expanded_xml` optionally, so that line won't cause failures. --- spec/support/workflow_spec_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/support/workflow_spec_helper.rb b/spec/support/workflow_spec_helper.rb index 9d2907bf12b..3f2b0eefc38 100644 --- a/spec/support/workflow_spec_helper.rb +++ b/spec/support/workflow_spec_helper.rb @@ -40,9 +40,10 @@ def assert_automate_vm_name_lookup(user, vm_name = 'vm_name') end def stub_automate_workspace(url, user, *result) - workspace_stub = double + workspace_stub = double("Double for #stub_automate_workspace") expect(workspace_stub).to receive(:instantiate).with(url, user, nil) expect(workspace_stub).to receive(:root).and_return(*result) + allow(workspace_stub).to receive(:to_expanded_xml).and_return(*result) expect(MiqAeEngine::MiqAeWorkspaceRuntime).to receive(:new).and_return(workspace_stub) end end