Sha256: 1459fbfa5e382c4f4b868f79c6bdd1906b233ff44caa8e8902821a93f6bda358

Contents?: true

Size: 729 Bytes

Versions: 1

Compression:

Stored size: 729 Bytes

Contents

require 'minitest/autorun'
require 'expletive'
require 'stringio'

include Expletive

describe Dump do
  def endump(input)
    in_io = StringIO.new(input)
    out_io = StringIO.new
    Dump.new(in_io, out_io).run
    out_io.string
  end
 
  describe "#dump" do
    it "passes text unchanged" do
      input = "hello world"
      assert_equal input, endump(input)
    end

    it "encodes binary into hex" do
      input = "\01\02\03xyz"
      assert_equal '\\01\\02\\03xyz', endump(input)
    end

    it "escapes backslashes" do
      input = 'abc\\def'
      assert_equal 'abc\\\\def', endump(input)
    end

    it "escapes newlines" do
      input = "abc\ndef"
      assert_equal 'abc\\ndef', endump(input)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
expletive-0.0.1 spec/dump_spec.rb