Sha256: 6baf014ede405bbd63f6b1d77db5cf7eb2f6918ac441035b544b45c9a0b27c98
Contents?: true
Size: 778 Bytes
Versions: 15
Compression:
Stored size: 778 Bytes
Contents
# frozen_string_literal: true def root_filepath @root_filepath ||= begin current_directory = Dir.pwd until Dir.exist?(current_directory + '/spec') current_directory += '/..' end File.expand_path(current_directory) end end def fixture_filepath(filepath) "#{root_filepath}/spec/fixtures/#{filepath}" end def read_fixture(filepath) ::File.read(fixture_filepath(filepath)) end def parse_fixture(filepath) contents = read_fixture(filepath) case filepath[/\.\w+\z/] when '.json' ::JSON.parse(contents) when '.eml' ::Mail.new(contents) else fail ArgumentError, "I don't know how to parse #{filepath}." end end
Version data entries
15 entries across 15 versions & 1 rubygems