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_a_command_found_in_path.feature
115 lines (88 loc) · 3.34 KB
/
be_a_command_found_in_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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
Feature: Check if command can be found in PATH
If you need to check if a given command can be found in path, you can use the
`be_an_existing_executable`-matcher.
```ruby
require 'spec_helper'
RSpec.describe 'Check if command can be found in PATH', :type => :aruba do
let(:file) { 'file.sh' }
before(:each) { touch(file) }
before(:each) { chmod(0755, file) }
before(:each) { prepend_environment_variable('PATH', format('%s:', expand_path('.')) }
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 command can be found in PATH', :type => :aruba do
let(:file) { 'file.sh' }
before(:each) { touch(file) }
before(:each) { chmod(0755, file) }
before(:each) { prepend_environment_variable('PATH', format('%s:', expand_path('.'))) }
it { expect(file).to be_a_command_found_in_path }
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 command can be found in PATH', :type => :aruba do
let(:file) { 'file.sh' }
before(:each) { prepend_environment_variable('PATH', format('%s:', expand_path('.'))) }
it { expect(file).not_to be_a_command_found_in_path }
end
"""
When I run `rspec`
Then the specs should all pass
Scenario: Expect single non-executable file
Given a file named "spec/existing_executable_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if command can be found in PATH', :type => :aruba do
let(:file) { 'file.sh' }
before(:each) { touch(file) }
before(:each) { prepend_environment_variable('PATH', format('%s:', expand_path('.'))) }
it { expect(file).not_to be_a_command_found_in_path }
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.sh file2.sh) }
before :each do
files.each do |f|
touch(f)
chmod(0755, f)
end
end
before(:each) { prepend_environment_variable('PATH', format('%s:', expand_path('.'))) }
it { expect(files).to all be_a_command_found_in_path }
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.sh file2.sh) }
before :each do
touch(files.first)
chmod(0755, files.first)
end
before(:each) { prepend_environment_variable('PATH', format('%s:', expand_path('.'))) }
it { expect(files).to include a_command_found_in_path }
end
"""
When I run `rspec`
Then the specs should all pass