lib/aruba/api/core.rb in aruba-0.8.0 vs lib/aruba/api/core.rb in aruba-0.8.1

- old
+ new

@@ -130,18 +130,20 @@ end if aruba.config.fixtures_path_prefix == prefix File.join aruba.fixtures_directory, rest elsif '~' == prefix - with_environment do - path = File.join(ENV['HOME'], aruba.current_directory.relative_path_from(Pathname.new(aruba.config.working_directory))) + path = with_environment do + ArubaPath.new(File.expand_path(file_name)) + end - fail 'Expanding "~/" to "/" is not allowed' if path == '/' + fail 'Expanding "~/" to "/" is not allowed' if path.to_s == '/' + fail %(Expanding "~/" to a relative path "#{path}" is not allowed) unless path.absolute? - Aruba::Platform.chdir(path) { Aruba::Platform.expand_path(file_name, dir_string) } - end + path.to_s else - Aruba::Platform.chdir(File.join(aruba.root_directory,aruba.current_directory)) { Aruba::Platform.expand_path(file_name, dir_string) } + directory = File.join(aruba.root_directory, aruba.current_directory) + ArubaPath.new(File.join(*[directory, dir_string, file_name].compact)).expand_path.to_s end end # rubocop:enable Metrics/MethodLength # rubocop:enable Metrics/CyclomaticComplexity