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_existing_executable.feature
88 lines (70 loc) · 2.41 KB
/
be_existing_executable.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
Feature: Check if path exists and is an executable file
If you need to check if a given path exists and is a file, you can use the
`be_an_existing_executable`-matcher.
```ruby
require 'spec_helper'
RSpec.describe 'Check if file exists and is an executable file', :type => :aruba do
let(:file) { 'file.txt' }
before(:each) { touch(file) }
before(:each) { chmod(0755, file) }
it { expect(file).to be_an_existing_executable }
end
```
Background:
Given I use a fixture named "cli-app"
Scenario: Expect single existing executable file
Given a file named "spec/existing_executable_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if file exists and is an executable file', :type => :aruba do
let(:file) { 'file.txt' }
before(:each) { touch(file) }
before(:each) { chmod(0755, file) }
it { expect(file).to be_an_existing_executable }
end
"""
When I run `rspec`
Then the specs should all pass
Scenario: Expect single non-existing executable file
Given a file named "spec/existing_executable_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if file exists and is an executable file', :type => :aruba do
let(:file) { 'file.txt' }
it { expect(file).not_to be_an_existing_executable }
end
"""
When I run `rspec`
Then the specs should all pass
Scenario: Expect multiple existing executable files
Given a file named "spec/existing_executable_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if file exists and is an executable file', :type => :aruba do
let(:files) { %w(file1.txt file2.txt) }
before :each do
files.each do |f|
touch(f)
chmod(0755, f)
end
end
it { expect(files).to all be_an_existing_executable }
end
"""
When I run `rspec`
Then the specs should all pass
Scenario: Expect a least one existing executable file
Given a file named "spec/existing_executable_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if file exists and is an executable file', :type => :aruba do
let(:files) { %w(file1.txt file2.txt) }
before :each do
touch(files.first)
chmod(0755, files.first)
end
it { expect(files).to include an_existing_executable }
end
"""
When I run `rspec`
Then the specs should all pass