Sha256: 383db6ae4e5387cb2686c5699c5227a61a83acb2d9e721a8ca88a03f3f6ed87e

Contents?: true

Size: 1.95 KB

Versions: 37

Compression:

Stored size: 1.95 KB

Contents

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(:each) { touch(path) }

    it { expect(path).to be_an_absolute_path }
  end
  ```

  Background:
    Given I use a fixture named "cli-app"

  Scenario: Expect single 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(: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 }
    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

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
aruba-0.14.14 features/05_use_rspec_matchers/path/be_an_absolute_path.feature
aruba-0.14.13 features/05_use_rspec_matchers/path/be_an_absolute_path.feature
aruba-0.14.12 features/05_use_rspec_matchers/path/be_an_absolute_path.feature
aruba-0.14.11 features/05_use_rspec_matchers/path/be_an_absolute_path.feature
aruba-0.14.10 features/05_use_rspec_matchers/path/be_an_absolute_path.feature
aruba-0.14.9 features/matchers/path/be_an_absolute_path.feature
aruba-0.14.8 features/matchers/path/be_an_absolute_path.feature
aruba-0.14.7 features/matchers/path/be_an_absolute_path.feature
aruba-0.14.6 features/matchers/path/be_an_absolute_path.feature
aruba-0.14.5 features/matchers/path/be_an_absolute_path.feature
aruba-0.14.4 features/matchers/path/be_an_absolute_path.feature
aruba-0.14.3 features/matchers/path/be_an_absolute_path.feature
aruba-win-fix-0.14.2 features/matchers/path/be_an_absolute_path.feature
aruba-0.14.2 features/matchers/path/be_an_absolute_path.feature
aruba-0.14.1 features/matchers/path/be_an_absolute_path.feature
aruba-0.14.0 features/matchers/path/be_an_absolute_path.feature
aruba-0.13.0 features/matchers/path/be_an_absolute_path.feature
aruba-0.12.0 features/matchers/path/be_an_absolute_path.feature
aruba-0.11.2 features/matchers/path/be_an_absolute_path.feature
aruba-0.11.1 features/matchers/path/be_an_absolute_path.feature