module ProcessHelpers def successful_process_status process_status_double(true) end def failed_process_status process_status_double(false) end def process_status_double(success_boolean) instance_double(Process::Status).tap do |status| allow(status).to receive(:success?).and_return success_boolean end end def which_success(command) # The kind of response that Open3 will return if `which command` was successful ["/usr/local/bin/#{command}\n", successful_process_status] end def which_failure # The kind of response that Open3 will return if `which command` failed ["", failed_process_status] end end