何を以て同じファイルとみなすかに依る
単に内容だけ比較するなら FileUtils.#cmp を使うと良いよ

https://docs.ruby-lang.org/ja/latest/method/FileUtils/m/cmp.html