Sha256: ab9ba65bae347d63dfd111d9805dc95b1acf07b003f4246c2d47e285edc29041
Contents?: true
Size: 726 Bytes
Versions: 4
Compression:
Stored size: 726 Bytes
Contents
# frozen_string_literal: true def root_filepath @root_filepath ||= begin current_directory = Dir.pwd current_directory += '/..' until Dir.exist?(current_directory + '/spec') 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
4 entries across 4 versions & 1 rubygems