To add a collaborator to this project you will need to use the Relish gem to add the collaborator via a terminal command. Soon you'll be able to also add collaborators here!
More about adding a collaboratorExpand paths with aruba
There are quite a few uses cases why you want to expand a path. aruba
helps
you with this by providing you the expand_path
-method. This method expands
paths relative to the aruba.current_directory
-directory.
- Background
-
- Given
- I use the fixture "cli-app"
- Scenarios
-
- Use relative path
- Change directory using cd
- Warn if aruba's working directory does not exist
- Use ~ in path
- Use relative path
-
- Given
-
a file named "spec/expand_path_spec.rb" with:
require 'spec_helper' RSpec.describe 'Expand path', :type => :aruba do let(:path) { 'path/to/dir' } it { expect(expand_path(path)).to eq File.join(aruba.root_directory, aruba.current_directory, path) } end
- When
-
I run
rspec
- Then
- the specs should all pass
- Change directory using cd
-
- Given
-
a file named "spec/expand_path_spec.rb" with:
require 'spec_helper' RSpec.describe 'Expand path', :type => :aruba do let(:path) { 'path/to/dir' } let(:directory) { 'dir1' } before(:each) { create_directory(directory) } before(:each) { cd(directory) } it { expect(expand_path(path)).to eq File.join(aruba.root_directory, aruba.current_directory, path) } end
- When
-
I run
rspec
- Then
- the specs should all pass
- Warn if aruba's working directory does not exist
-
- Given
-
a file named "spec/expand_path_spec.rb" with:
require 'spec_helper' RSpec.describe 'Expand path', :type => :aruba do before(:each) { remove('.') } let(:path) { 'path/to/dir' } it { expect { expand_path(path) }.to output(/working directory does not exist/).to_stderr } end
- When
-
I run
rspec
- Then
- the specs should all pass
- Use ~ in path
-
Now this useses the HOME-variable from your normal shell HOME-variable.
From 1.0.0 on HOME will beFile.join(aruba.config.root_directory,
. If you want HOME have some other value,
aruba.config.working_directory)
you need to configure it explicitly viaAruba.configure {}
.- Given
-
a file named "spec/expand_path_spec.rb" with:
require 'spec_helper' # Old before 1.0.0 RSpec.describe 'Expand path', :type => :aruba do let(:path) { '~/path/to/dir' } it { expect(expand_path(path)).to match %r</home/[^/]+/path/to/dir> } end # New from 1.0.0 RSpec.describe 'Expand path', :type => :aruba do let(:path) { '~/path/to/dir' } before(:each) do set_environment_variable('HOME', File.join(aruba.config.root_directory, aruba.config.working_directory)) end it { expect(expand_path(path)).to eq File.join(aruba.config.root_directory, aruba.config.working_directory, 'path/to/dir') } end
- When
-
I run
rspec
- Then
- the specs should all pass
Last published over 7 years ago by Max Meyer.