RSpec.shared_context 'stubbed calls to KnifeFactory.instance', stubbed_knife: true do let(:stubbed_knife) { instance_double(KnifeCommands) } before do allow(KnifeFactory).to receive(:instance) { stubbed_knife } end end