diff --git a/features/04_aruba_api/core/expand_path.feature b/features/04_aruba_api/core/expand_path.feature index 04ece3a86..4c49ab4f3 100644 --- a/features/04_aruba_api/core/expand_path.feature +++ b/features/04_aruba_api/core/expand_path.feature @@ -2,27 +2,33 @@ Feature: Expand 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. Use of absolute - paths is discouraged, since the intent is to only access the isolated Aruba - working directory. + paths relative to the `aruba.current_directory`-directory. + + Use of absolute paths is discouraged, since the intent is to only access the + isolated Aruba working directory. Background: Given I use the fixture "cli-app" - Scenario: Use relative path + Scenario: Using a relative path Given a file named "spec/expand_path_spec.rb" with: """ruby 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.config.home_directory, path) } + + it "expands relative to Aruba's home directory" do + expected_path = File.join(aruba.config.home_directory, path) + + expect(expand_path(path)).to eq expected_path + end end """ When I run `rspec` Then the specs should all pass - Scenario: Change directory using cd + Scenario: Using a relative path after changing directory using cd Given a file named "spec/expand_path_spec.rb" with: """ruby require 'spec_helper' @@ -33,10 +39,14 @@ Feature: Expand paths with aruba before do create_directory directory - cd directory end - it { expect(expand_path(path)).to eq File.join(aruba.config.home_directory, directory, path) } + it "expands relative to the new directory" do + cd directory + expected_path = File.join(aruba.config.home_directory, directory, path) + + expect(expand_path(path)).to eq expected_path + end end """ When I run `rspec` diff --git a/features/04_aruba_api/filesystem/check_if_path_is_absolute.feature b/features/04_aruba_api/filesystem/check_if_path_is_absolute.feature index dbea5d3f0..7e69c81ac 100644 --- a/features/04_aruba_api/filesystem/check_if_path_is_absolute.feature +++ b/features/04_aruba_api/filesystem/check_if_path_is_absolute.feature @@ -2,20 +2,6 @@ Feature: Check if path is absolute Use the `#absolute?`-method to check if a path is an absolute path. - ```ruby - require 'spec_helper' - - RSpec.configure do |config| - config.include Aruba::Api - end - - RSpec.describe 'Check if directory or file is absolute' do - let(:path) { '/path/to/file.txt' } - - it { expect(absolute?(path)).to be true } - end - ``` - Background: Given I use a fixture named "cli-app" @@ -24,10 +10,12 @@ Feature: Check if path is absolute """ruby require 'spec_helper' - RSpec.describe 'Check if directory or file is absolute', :type => :aruba do + RSpec.describe 'the absolute? method', :type => :aruba do let(:path) { '/path/to/file.txt' } - it { expect(absolute?(path)).to be true } + it "returns true for an absolute path" do + expect(absolute?(path)).to be true + end end """ When I run `rspec` diff --git a/features/05_use_rspec_matchers/path/be_an_absolute_path.feature b/features/05_use_rspec_matchers/path/be_an_absolute_path.feature index 37cf4259b..39a0511d6 100644 --- a/features/05_use_rspec_matchers/path/be_an_absolute_path.feature +++ b/features/05_use_rspec_matchers/path/be_an_absolute_path.feature @@ -2,73 +2,23 @@ Feature: Check if path is absolute If you need to check if a given path is absolute , you can use the `be_an_absolute_path`-matcher. It doesn't care if the path is a directory or - a path. - - ```ruby - require 'spec_helper' - - RSpec.describe 'Check if path is absolute', :type => :aruba do - let(:path) { 'file.txt' } - before { touch(path) } - - it { expect(path).to be_an_absolute_path } - end - ``` + a file. Background: Given I use a fixture named "cli-app" - Scenario: Expect single existing path + Scenario: Checking an absolute path Given a file named "spec/absolute_path_spec.rb" with: """ require 'spec_helper' - RSpec.describe 'Check if path is absolute', :type => :aruba do + RSpec.describe 'an absolute path', :type => :aruba do let(:path) { '/path/to/file.txt' } - it { expect(path).to be_an_absolute_path } - end - """ - When I run `rspec` - Then the specs should all pass - - Scenario: Expect multiple absolute paths - Given a file named "spec/absolute_path_spec.rb" with: - """ - require 'spec_helper' - - RSpec.describe 'Check if path is absolute', :type => :aruba do - let(:paths) { %w(/path/to/path1.txt /path/to/path2.txt) } - it { expect(paths).to all be_an_absolute_path } + it "is absolute" do + expect(path).to be_an_absolute_path + end end """ When I run `rspec` Then the specs should all pass - - Scenario: Expect a least one existing path - Given a file named "spec/absolute_path_spec.rb" with: - """ - require 'spec_helper' - - RSpec.describe 'Check if path is absolute', :type => :aruba do - let(:paths) { %w(/path/to/path1.txt path2.txt) } - - it { expect(paths).to include an_absolute_path } - end - """ - When I run `rspec` - Then the specs should all pass - - Scenario: Expect failure on relative path - Given a file named "spec/absolute_path_spec.rb" with: - """ - require 'spec_helper' - - RSpec.describe 'Check if path is absolute', :type => :aruba do - let(:paths) { %w(path2.txt) } - - it { expect(paths).to be_an_absolute_path } - end - """ - When I run `rspec` - Then the specs should not all pass