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

Version Path
rspeckled-1.3.0 lib/rspeckled/helpers/filepaths.rb
rspeckled-1.2.1 lib/rspeckled/helpers/filepaths.rb
rspeckled-1.2.0 lib/rspeckled/helpers/filepaths.rb
rspeckled-1.1.3 lib/rspeckled/helpers/filepaths.rb
rspeckled-1.1.2 lib/rspeckled/helpers/filepaths.rb
rspeckled-1.1.1 lib/rspeckled/helpers/filepaths.rb
rspeckled-1.1.0 lib/rspeckled/helpers/filepaths.rb
rspeckled-1.0.5 lib/rspeckled/helpers/filepaths.rb
rspeckled-1.0.4 lib/rspeckled/helpers/filepaths.rb
rspeckled-1.0.3 lib/rspeckled/helpers/filepaths.rb
rspeckled-1.0.2 lib/rspeckled/helpers/filepaths.rb
rspeckled-1.0.1 lib/rspeckled/helpers/filepaths.rb
rspeckled-1.0.0 lib/rspeckled/helpers/filepaths.rb
rspeckled-0.0.64 lib/rspeckled/helpers/filepaths.rb
rspeckled-0.0.63 lib/rspeckled/helpers/filepaths.rb