Sha256: 68e39919c335f34183902b0e1729ec9fa13f4d431fa0ee5ee38fcc3889ed71c5

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

require 'coveralls'
Coveralls.wear!

require 'minitest/autorun'
require 'minitest/pride'
require 'minitest/spec'
require 'minitest-spec-context'
require 'mocha/setup'

require 'rupert'
require 'rupert/errors'

# Returns the absolute path for the given fixture filename, or the path of
# fixture directory if no argument present.
def fixture(filename='')
  File.join(File.dirname(__FILE__), 'fixtures', filename)
end

# Forces the string to be encoded as 8 bit ASCII (instead of, for example,
# UTF-8). This is to be used whenever a (binary) string is manually hardcoded
# in tests, since using a different encoding (e.g. UTF-8) breaks
# parsing/generating the IO stream.
def ascii(string)
  string.force_encoding(Encoding::ASCII_8BIT)
end

# Pads a string with nulls to fill given length
def pad(string, length)
  ("%-#{length}.#{length}s" % string).gsub(" ", "\x00")
end

# A string of nulls of given length
def null(length)
  pad("", length)
end

# Returns 128-bit MD5 checksum of given string
def md5(str)
  Digest::MD5.digest(str)
end

# Transforms given string into an IO object.
def io(string)
  StringIO.new(string)
end

# Helpers that builds a lead header from a plain string. Use it to make tests
# more readable.
def lead_from(string)
  Rupert::RPM::Lead.new(io(string))
end

def lead_with(string)
  lead_from(string)
end

# Helpers that builds a signature header from a plain string. Use it to make tests
# more readable.
def signature_from(string)
  Rupert::RPM::Signature.new(io(string))
end

def signature_with(string)
  signature_from(string)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rupert-0.0.1 test/test_helper.rb