require 'minitest/autorun' require 'fileutils' require 'diff/lcs' require_relative "../lib/lib_add_head_tail_html.rb" class Test_lib_src_file < Minitest::Test include FileUtils def test_add_head_tail_html sec1_html = <<~'EOS'

Prerequisite and License

Prerequisite

Gtk4 on a Linux OS

This tutorial is about Gtk4 libraries. It is originally used on Linux with C compiler, but now it is used more widely, on Windows and MacOS, with Vala, Python and so on. However, this tutorial describes only C programs on Linux.

EOS expected_sec1_html = <<~'EOS' Gtk4 tutorial for beginners

Prerequisite and License

Prerequisite

Gtk4 on a Linux OS

This tutorial is about Gtk4 libraries. It is originally used on Linux with C compiler, but now it is used more widely, on Windows and MacOS, with Vala, Python and so on. However, this tutorial describes only C programs on Linux.

EOS directory = "temp_"+Time.now.to_f.to_s.gsub(/\./,'') Dir.mkdir(directory) unless Dir.exist?(directory) File.write("#{directory}/sec1.html", sec1_html) add_head_tail_html("#{directory}/sec1.html") actual_sec1_html = File.read("#{directory}/sec1.html") remove_entry_secure(directory) # If you want to see the difference # Diff::LCS.diff(expected_sec1_html.each_line.to_a, actual_sec1_html.each_line.to_a).each do |array| # array.each do |change| # print "#{change.action} #{change.position.to_s.chomp}: #{change.element.to_s.chomp}\n" # end # end assert_equal expected_sec1_html, actual_sec1_html end end