This repository has been archived by the owner on Mar 1, 2019. It is now read-only.
forked from cucumber/aruba
-
Notifications
You must be signed in to change notification settings - Fork 1
/
be_an_existing_path.feature
97 lines (77 loc) · 2.43 KB
/
be_an_existing_path.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Feature: Check 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.
```ruby
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"
Scenario: 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
Scenario: 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
Scenario: 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
Scenario: 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
Scenario: 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