lib/aruba/api/core.rb in aruba-0.11.0.pre vs lib/aruba/api/core.rb in aruba-0.11.0.pre2

- old
+ new

@@ -1,14 +1,15 @@ require 'rspec/expectations' -require 'aruba/announcer' require 'aruba/runtime' require 'aruba/errors' +require 'aruba/setup' require 'aruba/config/jruby' -require 'aruba/aruba_logger' +# Aruba module Aruba + # Api module Api # Core methods of aruba # # Those methods do not depend on any other API method of aruba module Core @@ -23,13 +24,11 @@ # # 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 - Aruba.platform.rm File.join(Aruba.config.root_directory, Aruba.config.working_directory), :force => true - Aruba.platform.mkdir File.join(Aruba.config.root_directory, Aruba.config.working_directory) - Aruba.platform.chdir Aruba.config.root_directory + Aruba::Setup.new(aruba).call self end # Switch to directory @@ -50,13 +49,16 @@ def cd(dir, &block) if block_given? begin fail ArgumentError, "#{expand_path(dir)} is not a directory or does not exist." unless Aruba.platform.directory? expand_path(dir) + old_directory = expand_path('.') aruba.current_directory << dir - announcer.announce :directory, expand_path(dir) + new_directory = expand_path('.') + aruba.event_bus.notify Events::ChangedWorkingDirectory.new(:old => old_directory, :new => new_directory) + old_dir = Aruba.platform.getwd Aruba.platform.chdir File.join(aruba.root_directory, aruba.current_directory) result = Aruba.platform.with_environment( @@ -72,13 +74,16 @@ return result end fail ArgumentError, "#{expand_path(dir)} is not a directory or does not exist." unless Aruba.platform.directory? expand_path(dir) + old_directory = expand_path('.') aruba.current_directory << dir - announcer.announce :directory, expand_path(dir) + new_directory = expand_path('.') + aruba.event_bus.notify Events::ChangedWorkingDirectory.new(:old => old_directory, :new => new_directory) + self end # rubocop:enable Metrics/MethodLength # Expand file name @@ -168,10 +173,10 @@ # # @param [Hash] env (optional) # The variables to be used for block. # # @yield - # The block of code which should be run with the modified environment variables + # The block of code which should be run with the changed environment variables def with_environment(env = {}, &block) old_aruba_env = aruba.environment.to_h Aruba.platform.with_environment aruba.environment.update(env).to_h, &block ensure