module Rspeckled::Helpers::Filepaths
Public Instance Methods
fixture_filepath(filepath)
click to toggle source
# File lib/rspeckled/helpers/filepaths.rb, line 18 def fixture_filepath(filepath) "#{root_filepath}/spec/fixtures/#{filepath}" end
parse_fixture(filepath)
click to toggle source
# File lib/rspeckled/helpers/filepaths.rb, line 26 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
read_fixture(filepath)
click to toggle source
# File lib/rspeckled/helpers/filepaths.rb, line 22 def read_fixture(filepath) ::File.read(fixture_filepath(filepath)) end
root_filepath()
click to toggle source
# File lib/rspeckled/helpers/filepaths.rb, line 6 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