lib/aruba/api/core.rb in aruba-0.14.14 vs lib/aruba/api/core.rb in aruba-1.0.0.pre.alpha.1

- old
+ new

@@ -1,10 +1,12 @@ require 'rspec/expectations' require 'aruba/runtime' require 'aruba/errors' require 'aruba/setup' +require 'aruba/config/jruby' + # Aruba module Aruba # Api module Api # Core methods of aruba @@ -21,25 +23,16 @@ # Clean the working directory of aruba # # This will only clean up aruba's working directory to remove all # artifacts of your tests. This does NOT clean up the current working # directory. - def setup_aruba(clobber = true) - Aruba::Setup.new(aruba).call(clobber) + def setup_aruba + Aruba::Setup.new(aruba).call self end - # Execute block in Aruba's current directory - # - # @yield - # The block which should be run in current directory - def in_current_directory(&block) - create_directory '.' unless directory?('.') - cd('.', &block) - end - # Switch to directory # # @param [String] dir # The directory # @@ -66,11 +59,11 @@ old_dir = Aruba.platform.getwd Aruba.platform.chdir File.join(aruba.root_directory, aruba.current_directory) - result = with_environment( + result = Aruba.platform.with_environment( 'OLDPWD' => old_dir, 'PWD' => File.expand_path(File.join(aruba.root_directory, aruba.current_directory)), &block ) ensure @@ -137,21 +130,12 @@ # rubocop:disable Metrics/LineLength aruba.logger.warn %(`aruba`'s working directory does not exist. Maybe you forgot to run `setup_aruba` before using it's API. This warning will be an error from 1.0.0) unless Aruba.platform.directory? File.join(aruba.config.root_directory, aruba.config.working_directory) # rubocop:enable Metrics/LineLength - if RUBY_VERSION < '1.9' - prefix = file_name.chars.to_a[0].to_s - rest = if file_name.chars.to_a[2..-1].nil? - nil - else - file_name.chars.to_a[2..-1].join - end - else - prefix = file_name[0] - rest = file_name[2..-1] - end + prefix = file_name[0] + rest = file_name[2..-1] if aruba.config.fixtures_path_prefix == prefix path = File.join(*[aruba.fixtures_directory, rest].compact) # rubocop:disable Metrics/LineLength @@ -168,11 +152,10 @@ fail ArgumentError, %(Expanding "~/" to a relative path "#{path}" is not allowed) unless path.absolute? path.to_s else directory = File.join(aruba.root_directory, aruba.current_directory) - directory = File.expand_path(dir_string, directory) if dir_string - File.expand_path(file_name, 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