Accept mode as argument in `file_write' action

This commit is contained in:
Thibault Jouan
2014-04-24 23:46:43 +00:00
parent 47412d8bce
commit 5cb6296057
6 changed files with 64 additions and 5 deletions

View File

@@ -11,4 +11,18 @@ Feature: `file_write' task action
end
"""
When I successfully execute the recipe
And the remote file "some_file" must contain "some_content"
Then the remote file "some_file" must contain "some_content"
Scenario: creates file with given permissions
Given a recipe with:
"""
target 'some_host.test'
task :write_some_data do
file_write 'some_file_0600', 'some_content', 0600
file_write 'some_file_0700', 'some_content', 0700
end
"""
When I successfully execute the recipe
Then the remote file "some_file_0600" must have 0600 mode
And the remote file "some_file_0700" must have 0700 mode

View File

@@ -21,3 +21,10 @@ end
Then /^the remote file "([^"]+)" must contain exactly "([^"]+)"$/ do |path, content|
check_exact_file_content path, content
end
Then /^the remote file "([^"]+)" must have (\d+) mode$/ do |path, mode|
in_current_dir do
puts path, ('%o' % [File::Stat.new(path).mode])[-4, 4], mode
expect(('%o' % [File::Stat.new(path).mode])[-4, 4]).to match mode
end
end