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_permissions.feature
118 lines (93 loc) · 3.24 KB
/
have_permissions.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
110
111
112
113
114
115
116
117
118
Feature: Check if path has permissions in filesystem
If you need to check if a given path has some permissions in filesystem, you
can use the `have_permissions`-matcher. It fails if the file or directory
does not exist. You need to pass it the permissions either as `Octal`
(`0700`) or `String` (`'0700'`).
```ruby
require 'spec_helper'
RSpec.describe 'Check if path has permissions', :type => :aruba do
context 'when is file' do
let(:file) { 'file.txt' }
let(:permissions) { 0700 }
before(:each) { touch(file) }
before(:each) { chmod(permissions, file }
it { expect(file).to have_permissions permissions }
end
end
```
Background:
Given I use a fixture named "cli-app"
Scenario: Expect file with permissions
Given a file named "spec/path_with_permissions_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if path has permissions', :type => :aruba do
let(:file) { 'file.txt' }
let(:permissions) { 0600 }
before(:each) { touch(file) }
before(:each) { chmod(permissions, file) }
it { expect(file).to have_permissions permissions }
end
"""
When I run `rspec`
Then the specs should all pass
Scenario: Expect directory with permissions
Given a file named "spec/path_with_permissions_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if path has permissions', :type => :aruba do
let(:directory) { 'directory.d' }
let(:permissions) { 0700 }
before(:each) { create_directory(directory) }
before(:each) { chmod(permissions, directory) }
it { expect(directory).to have_permissions permissions }
end
"""
When I run `rspec`
Then the specs should all pass
Scenario: Expect multiple files with given permissions
Given a file named "spec/path_with_permissions_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if path has permissions', :type => :aruba do
let(:files) { %w(file1.txt file2.txt) }
let(:permissions) { 0600 }
before :each do
files.each do |f|
touch(f)
chmod(permissions, f)
end
end
it { expect(files).to all have_permissions permissions }
end
"""
When I run `rspec`
Then the specs should all pass
Scenario: Expect a least one file with permissions
Given a file named "spec/path_with_permissions_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if path has permissions', :type => :aruba do
let(:files) { %w(file1.txt file2.txt) }
let(:permissions) { 0600 }
before :each do
touch(files.first)
chmod(permissions, files.first)
end
it { expect(files).to include a_path_having_permissions permissions }
end
"""
When I run `rspec`
Then the specs should all pass
Scenario: Fails if path does not exist
Given a file named "spec/path_with_permissions_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if path has permissions', :type => :aruba do
let(:path) { 'file.txt' }
let(:permissions) { 0700 }
it { expect(path).to have_permissions permissions }
end
"""
When I run `rspec`
Then the specs should not all pass