0
我創建了一個創建新文本文件的類。當我嘗試將其與現有文件進行比較時,似乎RSpec認爲創建的文件是空的。RSpec認爲創建的文件爲空
expect(open @expected).to eq(open @result)
結果:
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-[]
+["The expected output\n"]
下面是創建該文件的代碼:
FileUtils.touch out_path
target = File.new out_path, 'w+'
File.open(in_path, "r") do |file_handle|
file_handle.each_line do |line|
target.puts line
end
end
向我們展示創建文件的代碼。 – mudasobwa
新增,該文件是絕對創建並具有正確的內容 – keoghpe