Sha256: 4ece3d92b74f0dc4976380c653700a8864ebcb2d7b1c7f22da3b3ec36b00ea37

Contents?: true

Size: 860 Bytes

Versions: 1

Compression:

Stored size: 860 Bytes

Contents

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

include Expletive

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

    it "decodes hex into equivalent binary" do
      input = "\\01\\02\\03xyz"
      output = "\01\02\03xyz"
      assert_equal output, dedump(input)
    end

    it "turns backslash backslash into a single backslash" do
      input = 'abc\\\\def'
      output = 'abc\\def'
      assert_equal output, dedump(input)
    end

    it "turns backslash n into a real newline" do
      input = "abc\\ndef"
      output = "abc\ndef"
      assert_equal output, dedump(input)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
expletive-0.0.1 spec/undump_spec.rb