Permalink
Browse files

Add support for remote_file.

  • Loading branch information...
1 parent 3509365 commit 23f4b34caea530398c545b4f04dcb6178d0d461f @guitsaru guitsaru committed with acrmp May 25, 2012
@@ -51,6 +51,17 @@
}
end
+Given /^a Chef cookbook with a recipe that creates a remote file$/ do
+ steps %q{
+ Given a file named "cookbooks/example/recipes/default.rb" with:
+ """ruby
+ remote_file "hello-world.txt" do
+ action :create
+ end
+ """
+ }
+end
+
Given /^a Chef cookbook with a recipe that sets file ownership$/ do
steps %q{
Given a file named "cookbooks/example/recipes/default.rb" with:
@@ -162,6 +173,22 @@
}
end
+Given /^the recipe has a spec example that expects the remote file to be created/ do
+ steps %q{
+ Given a file named "cookbooks/example/spec/default_spec.rb" with:
+ """ruby
+ require "chefspec"
+
+ describe "example::default" do
+ let(:chef_run) {ChefSpec::ChefRunner.new.converge 'example::default'}
+ it "should create the remote file" do
+ chef_run.should create_remote_file 'hello-world.txt'
+ end
+ end
+ """
+ }
+end
+
Given /^the recipe has a spec example that expects the file to be set to be owned by a specific user$/ do
steps %q{
Given a file named "cookbooks/example/spec/default_spec.rb" with:
@@ -42,6 +42,12 @@ Feature: Write examples for files
When the recipe example is successfully run
Then the directory will not have been deleted
+ Scenario: Create a remote file
+ Given a Chef cookbook with a recipe that creates a remote file
+ And the recipe has a spec example that expects the remote file to be created
+ When the recipe example is successfully run
+ Then the file will not have been created
+
Scenario: Check file ownership
Given a Chef cookbook with a recipe that sets file ownership
And the recipe has a spec example that expects the file to be set to be owned by a specific user
@@ -4,11 +4,12 @@ module ChefSpec
module Matchers
define_resource_matchers([:create, :delete], [:file, :directory, :cookbook_file], :path)
+ define_resource_matchers([:create], [:remote_file], :path)
RSpec::Matchers.define :be_owned_by do |user, group|
match do |file|
file.nil? ? false : file.owner == user and file.group == group
end
end
end
-end
+end

0 comments on commit 23f4b34

Please sign in to comment.