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
/
have_sub_directory.feature
110 lines (84 loc) · 3.14 KB
/
have_sub_directory.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
97
98
99
100
101
102
103
104
105
106
107
108
109
Feature: Check if directory has given sub directories
If you need to check if a given directory has given sub dirctories, you can
use the `have_sub_directory`-matcher.
```ruby
require 'spec_helper'
RSpec.describe 'Check if directory has sub-directory', :type => :aruba do
let(:file) { 'file.txt' }
before(:each) { touch(file) }
it { expect(file).to be_an_existing_file }
end
```
Background:
Given I use a fixture named "cli-app"
Scenario: Expect existing sub directory
Given a file named "spec/existing_file_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if directory has sub-directory', :type => :aruba do
let(:directory) { 'dir.d' }
let(:sub_directory) { 'sub-dir.d' }
before(:each) { create_directory(File.join(directory, sub_directory)) }
it { expect(directory).to have_sub_directory sub_directory }
end
"""
When I run `rspec`
Then the specs should all pass
Scenario: Expect multiple existing sub directories
Given a file named "spec/existing_file_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if directory has sub-directory', :type => :aruba do
let(:directory) { 'dir.d' }
let(:sub_directories) { %w(sub-dir1.d sub-dir2.d) }
before(:each) do
sub_directories.each { |d| create_directory(File.join(directory, d)) }
end
it { expect(directory).to have_sub_directory sub_directories }
end
"""
When I run `rspec`
Then the specs should all pass
Scenario: Expect non-existing sub directory
Given a file named "spec/existing_file_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if directory has sub-directory', :type => :aruba do
let(:directory) { 'dir.d' }
let(:sub_directory) { 'sub-dir.d' }
before(:each) { create_directory(directory) }
it { expect(directory).not_to have_sub_directory sub_directory }
end
"""
When I run `rspec`
Then the specs should all pass
Scenario: Expect multiple directories have sub directory
Given a file named "spec/existing_file_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if directory has sub-directory', :type => :aruba do
let(:directories) { %w(dir1.d dir2.d) }
let(:sub_directory) { 'sub-dir.d' }
before(:each) do
directories.each { |d| create_directory(File.join(d, sub_directory)) }
end
it { expect(directories).to all have_sub_directory sub_directory }
end
"""
When I run `rspec`
Then the specs should all pass
Scenario: Expect a least one directory has sub directory
Given a file named "spec/existing_file_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if directory has sub-directory', :type => :aruba do
let(:directories) { %w(dir1.d dir2.d) }
let(:sub_directory) { 'sub-dir.d' }
before(:each) do
create_directory(File.join(directories.first, sub_directory))
end
it { expect(directories).to include a_directory_having_sub_directory sub_directory }
end
"""
When I run `rspec`
Then the specs should all pass