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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
|
# frozen_string_literal: true
Given(/^I use (?:a|the) fixture(?: named)? "([^"]*)"$/) do |name|
copy File.join(aruba.config.fixtures_path_prefix, name), name
cd name
end
Given(/^I copy (?:a|the) (?:file|directory)(?: (?:named|from))? "([^"]*)" to "([^"]*)"$/) \
do |source, destination|
copy source, destination
end
Given(/^I move (?:a|the) (?:file|directory)(?: (?:named|from))? "([^"]*)" to "([^"]*)"$/) \
do |source, destination|
move source, destination
end
Given(/^(?:a|the|(?:an empty)) directory(?: named)? "([^"]*)"$/) do |dir_name|
create_directory(dir_name)
end
Given(/^(?:a|the) directory(?: named)? "([^"]*)" with mode "([^"]*)"$/) \
do |dir_name, dir_mode|
create_directory(dir_name)
chmod(dir_mode, dir_name)
end
Given(/^(?:a|the) file(?: named)? "([^"]*)" with:$/) do |file_name, file_content|
write_file(file_name, file_content)
end
Given(/^(?:an|the) executable(?: named)? "([^"]*)" with:$/) do |file_name, file_content|
step %(a file named "#{file_name}" with mode "0o755" and with:), file_content
end
Given(/^(?:a|the) file(?: named)? "([^"]*)" with "([^"]*)"$/) do |file_name, file_content|
write_file(file_name, unescape_text(file_content))
end
Given(/^(?:a|the) file(?: named)? "([^"]*)" with mode "([^"]*)" and with:$/) \
do |file_name, file_mode, file_content|
write_file(file_name, unescape_text(file_content))
chmod(file_mode, file_name)
end
Given(/^(?:a|the) (\d+) byte file(?: named)? "([^"]*)"$/) do |file_size, file_name|
write_fixed_size_file(file_name, file_size.to_i)
end
Given(/^(?:an|the) empty file(?: named)? "([^"]*)"$/) do |file_name|
write_file(file_name, '')
end
Given(/^(?:an|the) empty file(?: named)? "([^"]*)" with mode "([^"]*)"$/) \
do |file_name, file_mode|
write_file(file_name, '')
chmod(file_mode, file_name)
end
When(/^I write to "([^"]*)" with:$/) do |file_name, file_content|
write_file(file_name, file_content)
end
When(/^I overwrite(?: (?:a|the) file(?: named)?)? "([^"]*)" with:$/) \
do |file_name, file_content|
overwrite_file(file_name, file_content)
end
When(/^I append to "([^"]*)" with:$/) do |file_name, file_content|
append_to_file(file_name, file_content)
end
When(/^I append the following lines to "([^"]*)":$/) do |file_name, file_content|
append_lines_to_file(file_name, file_content)
end
When(/^I append to "([^"]*)" with "([^"]*)"$/) do |file_name, file_content|
append_to_file(file_name, file_content)
end
When(/^I remove (?:a|the) (?:file|directory)(?: named)? "([^"]*)"( with full force)?$/) \
do |name, force_remove|
remove(name, force: !force_remove.nil?)
end
Given(/^(?:a|the) (?:file|directory)(?: named)? "([^"]*)" does not exist$/) do |name|
remove(name, force: true)
end
When(/^I cd to "([^"]*)"$/) do |dir|
cd(dir)
end
Then(/^the following files should (not )?exist:$/) do |negated, files|
files = files.raw.flatten
if negated
expect(files).not_to include an_existing_file
else
expect(files).to all be_an_existing_file
end
end
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?exist(?: anymore)?$/) \
do |path, expect_match|
if expect_match
expect(path).not_to be_an_existing_file
else
expect(path).to be_an_existing_file
end
end
Then(/^(?:a|the) directory(?: named)? "([^"]*)" should (not )?exist(?: anymore)?$/) \
do |path, expect_match|
if expect_match
expect(path).not_to be_an_existing_directory
else
expect(path).to be_an_existing_directory
end
end
Then(/^(?:a|the) file matching %r<(.*?)> should (not )?exist$/) do |pattern, expect_match|
if expect_match
expect(all_paths).not_to include a_file_name_matching(pattern)
else
expect(all_paths).to include match a_file_name_matching(pattern)
end
end
Then(/^(?:a|the) (\d+) byte file(?: named)? "([^"]*)" should (not )?exist$/) \
do |size, file, negated|
if negated
expect(file).not_to have_file_size(size)
else
expect(file).to have_file_size(size)
end
end
Then(/^the following directories should (not )?exist:$/) do |negated, directories|
directories = directories.rows.flatten
if negated
expect(directories).not_to include an_existing_directory
else
expect(directories).to all be_an_existing_directory
end
end
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain "([^"]*)"$/) \
do |file, negated, content|
if negated
expect(file).not_to have_file_content file_content_including(content.chomp)
else
expect(file).to have_file_content file_content_including(content.chomp)
end
end
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain:$/) \
do |file, negated, content|
if negated
expect(file).not_to have_file_content file_content_including(content.chomp)
else
expect(file).to have_file_content file_content_including(content.chomp)
end
end
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain exactly:$/) \
do |file, negated, content|
if negated
expect(file).not_to have_file_content content
else
expect(file).to have_file_content content
end
end
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?match %r<([^>]*)>$/) \
do |file, negated, content|
if negated
expect(file).not_to have_file_content file_content_matching(content)
else
expect(file).to have_file_content file_content_matching(content)
end
end
Then(%r{^(?:a|the) file(?: named)? "([^"]*)" should (not )?match /([^/]*)/$}) \
do |file, negated, content|
if negated
expect(file).not_to have_file_content file_content_matching(content)
else
expect(file).to have_file_content file_content_matching(content)
end
end
Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?be equal to file "([^"]*)"/) \
do |file, negated, reference_file|
if negated
expect(file).not_to have_same_file_content_as(reference_file)
else
expect(file).to have_same_file_content_as(reference_file)
end
end
Then(
/^(?:a|the) (?:file|directory)(?: named)? "([^"]*)" should have permissions "([^"]*)"$/
) do |path, permissions|
expect(path).to have_permissions(permissions)
end
Then(
/^(?:a|the) (?:file|directory)(?: named)? "([^"]*)" should not have permissions "([^"]*)"$/
) do |path, permissions|
expect(path).not_to have_permissions(permissions)
end
|