summaryrefslogtreecommitdiff
path: root/spec/unit/provider/remote_file_spec.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@opscode.com>2013-03-20 14:57:18 -0700
committerLamont Granquist <lamont@opscode.com>2013-03-20 14:57:18 -0700
commitde0452180a1464d4a74992e0f9a83733ff4d8da2 (patch)
tree97db54bc4ebcf3629028ac4507f9e4040c6c176e /spec/unit/provider/remote_file_spec.rb
parent0e94bb48a688e7bb6b5488cb583af470d18acdda (diff)
downloadchef-de0452180a1464d4a74992e0f9a83733ff4d8da2.tar.gz
file provider spec work
Diffstat (limited to 'spec/unit/provider/remote_file_spec.rb')
-rw-r--r--spec/unit/provider/remote_file_spec.rb52
1 files changed, 37 insertions, 15 deletions
diff --git a/spec/unit/provider/remote_file_spec.rb b/spec/unit/provider/remote_file_spec.rb
index d055180a4a..7b7cd23b46 100644
--- a/spec/unit/provider/remote_file_spec.rb
+++ b/spec/unit/provider/remote_file_spec.rb
@@ -1,6 +1,7 @@
#
# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# Author:: Lamont Granquist (<lamont@opscode.com>)
+# Copyright:: Copyright (c) 2008-2013 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,22 +19,43 @@
require 'spec_helper'
-describe Chef::Provider::RemoteFile, "action_create" do
+require 'support/shared/unit/provider/file'
+
+
+describe Chef::Provider::RemoteFile do
+ let(:resource) do
+ resource = Chef::Resource::RemoteFile.new("seattle", @run_context)
+ resource.path(resource_path)
+ resource.source("http://foo")
+ resource
+ end
+
before(:each) do
- @resource = Chef::Resource::RemoteFile.new("seattle")
- @resource.path(File.expand_path(File.join(CHEF_SPEC_DATA, "seattle.txt")))
- @resource.source("http://foo")
- @node = Chef::Node.new
- @node.name "latte"
-
- @events = Chef::EventDispatch::Dispatcher.new
- @run_context = Chef::RunContext.new(@node, {}, @events)
-
- @provider = Chef::Provider::RemoteFile.new(@resource, @run_context)
- #To prevent the current_resource.checksum from being overridden.
- @provider.stub!(:load_current_resource)
+ ::File.stub!(:exists?).with("#{Chef::Config[:file_cache_path]}/remote_file/#{resource.name}").and_return(false)
+ end
+
+ let(:content) do
+ content = mock('Chef::Provider::File::Content::RemoteFile')
end
+ it_behaves_like Chef::Provider::File
+
+#describe Chef::Provider::RemoteFile, "action_create" do
+# before(:each) do
+# @resource = Chef::Resource::RemoteFile.new("seattle")
+# @resource.path(File.expand_path(File.join(CHEF_SPEC_DATA, "seattle.txt")))
+# @resource.source("http://foo")
+# @node = Chef::Node.new
+# @node.name "latte"
+#
+# @events = Chef::EventDispatch::Dispatcher.new
+# @run_context = Chef::RunContext.new(@node, {}, @events)
+#
+# @provider = Chef::Provider::RemoteFile.new(@resource, @run_context)
+# #To prevent the current_resource.checksum from being overridden.
+# @provider.stub!(:load_current_resource)
+# end
+
describe "when checking if the file is at the target version" do
it "considers the current file to be at the target version if it exists and matches the user-provided checksum" do
@provider.current_resource = @resource.dup
@@ -286,7 +308,7 @@ describe Chef::Provider::RemoteFile, "action_create" do
describe "and create_if_missing is invoked" do
it "should take no action" do
- @provider.should_not_receive(:action_create)
+ @provider.should_not_receive(:action_create)
@provider.run_action(:create_if_missing)
end
end