diff --git a/lib/dry/files/error.rb b/lib/dry/files/error.rb index c7f4857..7ec617d 100644 --- a/lib/dry/files/error.rb +++ b/lib/dry/files/error.rb @@ -116,21 +116,5 @@ def initialize(path) super("not a memory file `#{path}'") end end - - # Internal file system adapters can only take - # strings as arguments to their `write` methods. - # (The public API can take string or array of strings) - # - # @since x.x.x - # @api private - class CanOnlyWriteStringError < Error - # Instantiate a new error - # - # @since x.x.x - # @api private - def initialize - super("Can only write a String (use `join` or `to_s`)") - end - end end end diff --git a/lib/dry/files/file_system.rb b/lib/dry/files/file_system.rb index ab5a0cb..f1cf063 100644 --- a/lib/dry/files/file_system.rb +++ b/lib/dry/files/file_system.rb @@ -129,13 +129,10 @@ def touch(path, **kwargs) # @param content [String] the content to write # # @raise [Dry::Files::IOError] in case of I/O error - # @raise [CanOnlyWriteStringError] if content param isn't a String # # @since 0.1.0 # @api private def write(path, content) - raise CanOnlyWriteStringError unless content.is_a?(String) - mkdir_p(path) self.open(path, WRITE_MODE) do |f| diff --git a/spec/unit/dry/files/file_system_spec.rb b/spec/unit/dry/files/file_system_spec.rb index 56dce25..abc95fa 100644 --- a/spec/unit/dry/files/file_system_spec.rb +++ b/spec/unit/dry/files/file_system_spec.rb @@ -217,14 +217,6 @@ path.chmod(mode) end end - - it "raises error when trying to write non-string" do - path = root.join("write") - expect { subject.write(path, %w[new words]) }.to raise_error do |exception| - expect(exception).to be_kind_of(Dry::Files::CanOnlyWriteStringError) - expect(exception.message).to eq("Can only write a String (use `join` or `to_s`)") - end - end end describe "#join" do diff --git a/spec/unit/dry/files/memory_file_system_spec.rb b/spec/unit/dry/files/memory_file_system_spec.rb index f99c6d0..228646c 100644 --- a/spec/unit/dry/files/memory_file_system_spec.rb +++ b/spec/unit/dry/files/memory_file_system_spec.rb @@ -188,14 +188,6 @@ path.chmod(mode) end end - - it "raises error when trying to write non-string" do - path = subject.join("write") - expect { subject.write(path, %w[new words]) }.to raise_error do |exception| - expect(exception).to be_kind_of(Dry::Files::CanOnlyWriteStringError) - expect(exception.message).to eq("Can only write a String (use `join` or `to_s`)") - end - end end describe "#join" do