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 collaboratorCheck if path exists
If you need to check if a given path exists, you can use the
be_an_existing_path
-matcher. It doesn't care if the path is a directory or
a path.
require 'spec_helper'
RSpec.describe 'Check if path exists', :type => :aruba do
let(:path) { 'file.txt' }
before(:each) { touch(path) }
it { expect(path).to be_an_existing_path }
end
- Background
-
- Given
- I use a fixture named "cli-app"
- Scenarios
-
- Expect single existing path
- Expect single existing directory
- Expect single non-existing path
- Expect multiple existing paths
- Expect a least one existing path
- Expect single existing path
-
- Given
-
a file named "spec/existing_path_spec.rb" with:
require 'spec_helper' RSpec.describe 'Check if path exists', :type => :aruba do let(:path) { 'file.txt' } before(:each) { touch(path) } it { expect(path).to be_an_existing_path } end
- When
-
I run
rspec
- Then
- the specs should all pass
- Expect single existing directory
-
- Given
-
a file named "spec/existing_path_spec.rb" with:
require 'spec_helper' RSpec.describe 'Check if path exists', :type => :aruba do let(:path) { 'dir.d' } before(:each) { create_directory(path) } it { expect(path).to be_an_existing_path } end
- When
-
I run
rspec
- Then
- the specs should all pass
- Expect single non-existing path
-
- Given
-
a file named "spec/existing_path_spec.rb" with:
require 'spec_helper' RSpec.describe 'Check if path exists', :type => :aruba do let(:path) { 'file.txt' } it { expect(path).not_to be_an_existing_path } end
- When
-
I run
rspec
- Then
- the specs should all pass
- Expect multiple existing paths
-
- Given
-
a file named "spec/existing_path_spec.rb" with:
require 'spec_helper' RSpec.describe 'Check if path exists', :type => :aruba do let(:paths) { %w(path1.txt path2.txt) } before :each do paths.each { |f| touch(f) } end it { expect(paths).to all be_an_existing_path } end
- When
-
I run
rspec
- Then
- the specs should all pass
- Expect a least one existing path
-
- Given
-
a file named "spec/existing_path_spec.rb" with:
require 'spec_helper' RSpec.describe 'Check if path exists', :type => :aruba do let(:paths) { %w(path1.txt path2.txt) } before :each do touch(paths.first) end it { expect(paths).to include an_existing_path } end
- When
-
I run
rspec
- Then
- the specs should all pass
Last published almost 6 years ago by philoserf.