From 2383a90aa18c7313bae4d92e9ad4c096fc654782 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 3 May 2021 19:13:25 +1000 Subject: [PATCH] Chomp lines for readline This is so when they're read out, they do not contain line breaks at the end of each line's string. Later on, when this content is passed to write, it is joined with , which will add newlines --- lib/dry/files/memory_file_system/node.rb | 2 +- spec/unit/dry/files/memory_file_system/node_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dry/files/memory_file_system/node.rb b/lib/dry/files/memory_file_system/node.rb index 7be84a3..5842e8c 100644 --- a/lib/dry/files/memory_file_system/node.rb +++ b/lib/dry/files/memory_file_system/node.rb @@ -203,7 +203,7 @@ def readlines raise NotMemoryFileError, segment unless file? @content.rewind - @content.readlines + @content.readlines(chomp: true) end # Write file contents diff --git a/spec/unit/dry/files/memory_file_system/node_spec.rb b/spec/unit/dry/files/memory_file_system/node_spec.rb index adffa30..9543f34 100644 --- a/spec/unit/dry/files/memory_file_system/node_spec.rb +++ b/spec/unit/dry/files/memory_file_system/node_spec.rb @@ -145,7 +145,7 @@ expect(subject.readlines).to eq(["foo"]) subject.write(%w[foo bar]) - expect(subject.readlines).to eq(["foo#{newline}", "bar"]) + expect(subject.readlines).to eq(["foo", "bar"]) end it "raises error when not file" do